Merged revisions 8123-8136 via svnmerge from
authormichi <none@none>
Fri, 22 Jun 2007 16:41:36 +0000 (16:41 +0000)
committermichi <none@none>
Fri, 22 Jun 2007 16:41:36 +0000 (16:41 +0000)
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.
........

--HG--
branch : exact-gc

45 files changed:
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

index a6c4c4cd25ab2df4d4e165a63b517a44b38f5667..3b57da342b20a528ca57ed2b13173ad7df33e8fd 100644 (file)
@@ -22,7 +22,7 @@ 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 
-dnl $Id: configure.ac 8123 2007-06-20 23:50:55Z michi $
+dnl $Id: configure.ac 8132 2007-06-22 11:15:47Z twisti $
 
 dnl Process this file with autoconf to produce a configure script.
 
@@ -223,6 +223,7 @@ AC_CHECK_HEADERS([sys/ioctl.h])
 AC_CHECK_HEADERS([sys/mman.h])
 AC_CHECK_HEADERS([sys/resource.h])
 AC_CHECK_HEADERS([sys/select.h])
+AC_CHECK_HEADERS([sys/socket.h])
 AC_CHECK_HEADERS([sys/stat.h])
 AC_CHECK_HEADERS([sys/time.h])
 AC_CHECK_HEADERS([sys/types.h])
@@ -253,21 +254,27 @@ AC_FUNC_MEMCMP
 AC_FUNC_MMAP
 
 dnl keep them alpha-sorted!
+AC_CHECK_FUNCS([accept])
 AC_CHECK_FUNCS([atoi])
 AC_CHECK_FUNCS([atol])
 AC_CHECK_FUNCS([calloc])
+AC_CHECK_FUNCS([close])
 AC_CHECK_FUNCS([confstr])
+AC_CHECK_FUNCS([connect])
 AC_CHECK_FUNCS([fflush])
 AC_CHECK_FUNCS([fopen])
 AC_CHECK_FUNCS([fprintf])
 AC_CHECK_FUNCS([free])
 AC_CHECK_FUNCS([fstat])
 AC_CHECK_FUNCS([getcwd])
+AC_CHECK_FUNCS([gethostname])
 AC_CHECK_FUNCS([getpagesize])
 AC_CHECK_FUNCS([getrusage])
+AC_CHECK_FUNCS([getsockname])
 AC_CHECK_FUNCS([gettimeofday])
 AC_CHECK_FUNCS([ioctl])
 AC_CHECK_FUNCS([isnan])
+AC_CHECK_FUNCS([listen])
 AC_CHECK_FUNCS([localtime])
 AC_CHECK_FUNCS([localtime_r])
 AC_CHECK_FUNCS([lseek])
@@ -276,6 +283,9 @@ AC_CHECK_FUNCS([mprotect])
 AC_CHECK_FUNCS([open])
 AC_CHECK_FUNCS([scandir])
 AC_CHECK_FUNCS([select])
+AC_CHECK_FUNCS([setsockopt])
+AC_CHECK_FUNCS([shutdown])
+AC_CHECK_FUNCS([socket])
 AC_CHECK_FUNCS([strchr])
 AC_CHECK_FUNCS([strdup])
 AC_CHECK_FUNCS([strerror])
@@ -953,6 +963,7 @@ AC_CONFIG_FILES([Makefile]
                [src/native/vm/Makefile]
                [src/native/vm/cldc1.1/Makefile]
                [src/native/vm/gnu/Makefile]
+               [src/native/vm/sun/Makefile]
                [src/scripts/Makefile]
                [src/scripts/java]
                [src/threads/Makefile]
index c54ef61209f6928a1414dafa15de5ad2082c7203..700c9685c84c09d5ebf67b54ea5fb28ddaf49e49 100644 (file)
@@ -22,7 +22,7 @@ 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 
-dnl $Id: configure.ac 7228 2007-01-19 01:13:48Z edwin $
+dnl $Id: classpath.m4 8133 2007-06-22 13:29:38Z twisti $
 
 
 dnl which Java core library should we use
@@ -30,7 +30,7 @@ dnl which Java core library should we use
 AC_DEFUN([AC_CHECK_WITH_CLASSPATH],[
 AC_MSG_CHECKING(which Java core library to use)
 AC_ARG_WITH([classpath],
-            [AS_HELP_STRING(--with-classpath=<type>,specifies which type of classpath to use as Java core library (cldc1.1,gnu) [[default=gnu]])],
+            [AS_HELP_STRING(--with-classpath=<type>,specifies which type of classpath to use as Java core library (cldc1.1,gnu,sun) [[default=gnu]])],
             [case "${withval}" in
                 cldc1.1)
                     WITH_CLASSPATH=cldc1.1
@@ -42,6 +42,11 @@ AC_ARG_WITH([classpath],
                     AC_DEFINE([WITH_CLASSPATH_GNU], 1, [use GNU Classpath])
                     AC_SUBST(WITH_CLASSPATH_GNU)
                     ;;
+                sun)
+                    WITH_CLASSPATH=sun
+                    AC_DEFINE([WITH_CLASSPATH_SUN], 1, [use Sun's Java SE classes])
+                    AC_SUBST(WITH_CLASSPATH_SUN)
+                    ;;
                 *)
                     AC_MSG_ERROR(unknown classpath ${withval})
                     ;;
@@ -52,6 +57,7 @@ AC_ARG_WITH([classpath],
 AC_MSG_RESULT(${WITH_CLASSPATH})
 AM_CONDITIONAL([WITH_CLASSPATH_CLDC1_1], test x"${WITH_CLASSPATH}" = "xcldc1.1")
 AM_CONDITIONAL([WITH_CLASSPATH_GNU], test x"${WITH_CLASSPATH}" = "xgnu")
+AM_CONDITIONAL([WITH_CLASSPATH_SUN], test x"${WITH_CLASSPATH}" = "xsun")
 ])
 
 
@@ -110,11 +116,19 @@ AC_ARG_WITH([classpath-includedir],
             [CLASSPATH_INCLUDEDIR=${CLASSPATH_PREFIX}/include])
 AC_MSG_RESULT(${CLASSPATH_INCLUDEDIR})
 
+if test x"${WITH_CLASSPATH}" = "xsun"; then
+    AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/${OS_DIR}/jni_md.h],
+                    [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_MD_H], "${CLASSPATH_INCLUDEDIR}/${OS_DIR}/jni_md.h", [Java core library jni_md.h header])],
+                    [AC_MSG_ERROR(cannot find jni_md.h)])
+else
+    AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/jni_md.h],
+                    [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_MD_H], "${CLASSPATH_INCLUDEDIR}/jni_md.h", [Java core library jni_md.h header])],
+                    [AC_MSG_ERROR(cannot find jni_md.h)])
+fi
+
 AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/jni.h],
                 [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_H], "${CLASSPATH_INCLUDEDIR}/jni.h", [Java core library jni.h header])],
-                [AC_MSG_ERROR(cannot find jni.h)])
-
-AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/jni_md.h],
-                [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_MD_H], "${CLASSPATH_INCLUDEDIR}/jni_md.h", [Java core library jni_md.h header])],
-                [AC_MSG_ERROR(cannot find jni_md.h)])
+                [AC_MSG_ERROR(cannot find jni.h)],
+                [#define __GCJ_JNI_MD_H__
+                 #include CLASSPATH_JNI_MD_H])
 ])
index 4584b73aac19247e930c64c482d3446a56f92b32..85b8cc724d3a5c7b196e673ffb9570b1b43bcc12 100644 (file)
@@ -24,7 +24,7 @@
 ##
 ## Contact: cacao@cacaojvm.org
 ##
-## $Id: Makefile.am 7338 2007-02-13 00:17:22Z twisti $
+## $Id: Makefile.am 8132 2007-06-22 11:15:47Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -49,6 +49,11 @@ lib_LTLIBRARIES = \
 libjvm_la_LDFLAGS = \
        -release $(PACKAGE_VERSION)
 
+if WITH_CLASSPATH_SUN
+libjvm_la_LDFLAGS += \
+       -Xlinker --version-script=$(top_srcdir)/contrib/mapfile-vers-product
+endif
+
 cacao_LDFLAGS += \
        -export-dynamic
 
index d1217d2a29f260d0d1f1004decc0a2c475cc5b01..efa9fb2ddad5036a06aeee48774d6754fe5a6f0b 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 7890 2007-05-09 16:05:58Z twisti $
+## $Id: Makefile.am 8132 2007-06-22 11:15:47Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -40,7 +40,10 @@ VM_JAVA_FILES = \
        $(top_srcdir)/src/lib/gnu/java/lang/VMString.java \
        $(top_srcdir)/src/lib/gnu/java/lang/VMThread.java \
        $(top_srcdir)/src/lib/gnu/java/lang/VMThrowable.java \
-       $(top_srcdir)/src/lib/gnu/java/security/VMAccessController.java
+       $(top_srcdir)/src/lib/gnu/java/lang/reflect/Field.java \
+       $(top_srcdir)/src/lib/gnu/java/lang/reflect/Method.java \
+       $(top_srcdir)/src/lib/gnu/java/security/VMAccessController.java \
+       $(top_srcdir)/src/lib/gnu/sun/misc/Unsafe.java
 
 VM_CLASS_FILES = \
        classes/gnu/classpath/VMStackWalker.class \
@@ -51,7 +54,10 @@ VM_CLASS_FILES = \
        classes/java/lang/VMString.class \
        classes/java/lang/VMThread.class \
        classes/java/lang/VMThrowable.class \
-       classes/java/security/VMAccessController.class
+       classes/java/lang/reflect/Field.class \
+       classes/java/lang/reflect/Method.class \
+       classes/java/security/VMAccessController.class \
+       classes/sun/misc/Unsafe.class
 
 if ENABLE_ZLIB
 pkgdata_DATA = vm.zip
index 4c65432b4e0a628de0919dc4561c3843e960e828..765df9c22388900fc6921257413e363efb2452ac 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 8123 2007-06-20 23:50:55Z michi $
+## $Id: Makefile.am 8132 2007-06-22 11:15:47Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -50,26 +50,37 @@ JAVASE_HEADER_FILES = \
        java_lang_ClassLoader.h \
        java_lang_Cloneable.h \
        java_lang_ThreadGroup.h \
-       java_lang_VMThread.h \
-       java_lang_VMThrowable.h \
        java_util_Properties.h \
        \
-       gnu_classpath_Pointer.h \
-       gnu_classpath_Pointer32.h \
-       gnu_classpath_Pointer64.h \
        java_io_File.h \
        java_lang_Process.h \
        java_lang_StackTraceElement.h \
-       java_lang_VMObject.h \
        java_lang_reflect_Constructor.h \
        java_lang_reflect_Field.h \
        java_lang_reflect_Method.h \
        java_nio_Buffer.h \
-       java_nio_DirectByteBufferImpl.h \
        java_security_ProtectionDomain.h \
        java_util_concurrent_atomic_AtomicLong.h \
        sun_misc_Unsafe.h
 
+if WITH_CLASSPATH_GNU
+JAVASE_HEADER_FILES += \
+       java_lang_VMThread.h \
+       java_lang_VMThrowable.h \
+       \
+       gnu_classpath_Pointer.h \
+       gnu_classpath_Pointer32.h \
+       gnu_classpath_Pointer64.h \
+       java_lang_VMObject.h \
+       java_nio_DirectByteBufferImpl.h
+endif
+
+if WITH_CLASSPATH_SUN
+JAVASE_HEADER_FILES += \
+       java_lang_AssertionStatusDirectives.h \
+       java_nio_ByteBuffer.h
+endif
+
 JAVAME_CLDC1_1_HEADER_FILES = \
        com_sun_cldc_io_ResourceInputStream.h \
        com_sun_cldc_io_j2me_socket_Protocol.h \
@@ -84,9 +95,9 @@ JVMTI_HEADER_FILES = \
        gnu_classpath_jdwp_VMMethod.h \
        gnu_classpath_jdwp_VMVirtualMachine.h \
        gnu_classpath_jdwp_event_EventRequest.h \
-       gnu_classpath_jdwp_util_VariableTable.h \
-       java_nio_ByteBuffer.h
+       gnu_classpath_jdwp_util_VariableTable.h
 
+if WITH_CLASSPATH_GNU
 ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
        gnu_classpath_VMStackWalker.h \
        gnu_classpath_VMSystemProperties.h \
@@ -99,11 +110,12 @@ ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \
        java_lang_VMRuntime.h \
        java_lang_VMString.h \
        java_lang_VMSystem.h \
-       java_lang_management_VMManagementFactory.h \
        java_lang_management_MemoryUsage.h \
        java_lang_management_ThreadInfo.h \
+       java_lang_management_VMManagementFactory.h \
        java_lang_reflect_VMProxy.h \
        java_security_VMAccessController.h
+endif
 
 ADDITIONAL_STATIC_CLASSPATH_HEADER_FILES = \
        java_net_DatagramPacket.h \
index 6d715ec8373d734b5b019543a14a85ed1fd220f7..6889b57345dfd0d6e14cb196d8b55db6856f768c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: jni.c 8137 2007-06-22 16:41:36Z michi $
 
 */
 
 #include "native/include/java_lang_Throwable.h"
 
 #if defined(ENABLE_JAVASE)
+# if defined(WITH_CLASSPATH_SUN)
+#  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_reflect_Constructor.h"
 # include "native/include/java_lang_reflect_Method.h"
 
 # include "native/include/java_nio_Buffer.h"
-# include "native/include/java_nio_DirectByteBufferImpl.h"
+
+# if defined(WITH_CLASSPATH_GNU)
+#  include "native/include/java_nio_DirectByteBufferImpl.h"
+# endif
 #endif
 
 #if defined(ENABLE_JVMTI)
@@ -183,6 +190,7 @@ bool jni_init(void)
                !link_class(class_java_nio_Buffer))
                return false;
 
+# if defined(WITH_CLASSPATH_GNU)
        if (!(class_java_nio_DirectByteBufferImpl =
                  load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) ||
                !link_class(class_java_nio_DirectByteBufferImpl))
@@ -199,7 +207,6 @@ bool jni_init(void)
                                                        utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V"))))
                return false;
 
-# if defined(WITH_CLASSPATH_GNU)
 #  if SIZEOF_VOID_P == 8
        if (!(class_gnu_classpath_Pointer64 =
                  load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) ||
@@ -334,7 +341,8 @@ static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o,
 
 static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o,
                                                                                                        vftbl_t *vftbl,
-                                                                                                       methodinfo *m, jvalue *args)
+                                                                                                       methodinfo *m,
+                                                                                                       const jvalue *args)
 {
        methodinfo        *resm;
        java_objectheader *ro;
@@ -428,7 +436,7 @@ static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl,
 *******************************************************************************/
 
 static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl,
-                                                                  methodinfo *m, jvalue *args)
+                                                                  methodinfo *m, const jvalue *args)
 {
        methodinfo *resm;
        jint        i;
@@ -520,7 +528,7 @@ static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl,
 *******************************************************************************/
 
 static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl,
-                                                                        methodinfo *m, jvalue *args)
+                                                                        methodinfo *m, const jvalue *args)
 {
        methodinfo *resm;
        jlong       l;
@@ -605,7 +613,7 @@ static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl,
 *******************************************************************************/
 
 static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl,
-                                                                          methodinfo *m, jvalue *args)
+                                                                          methodinfo *m, const jvalue *args)
 {
        methodinfo *resm;
        jfloat      f;
@@ -681,7 +689,7 @@ static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl,
 *******************************************************************************/
 
 static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl,
-                                                                                methodinfo *m, jvalue *args)
+                                                                                methodinfo *m, const jvalue *args)
 {
        methodinfo *resm;
        jdouble     d;
@@ -759,7 +767,7 @@ static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl,
 *******************************************************************************/
 
 static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
-                                                                       methodinfo *m, jvalue *args)
+                                                                       methodinfo *m, const jvalue *args)
 {      
        methodinfo *resm;
 
@@ -804,7 +812,7 @@ static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl,
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__M68K__) & !defined(__ARM__)
 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
                                                                                java_objectarray *params)
 {
@@ -1462,6 +1470,8 @@ jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
        STATISTICS(jniinvokation());
 
        c = (classinfo *) clazz;
+       if (msg == NULL)
+               msg = "";
        s = javastring_new_from_utf_string(msg);
 
        /* instantiate exception object */
@@ -1859,7 +1869,7 @@ jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
                
        o = builtin_new(c);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -1875,16 +1885,18 @@ jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
 jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
 {
        java_objectheader *o;
+       classinfo         *c;
        methodinfo        *m;
        va_list            ap;
 
        STATISTICS(jniinvokation());
 
+       c = (classinfo *) clazz;
        m = (methodinfo *) methodID;
 
        /* create object */
 
-       o = builtin_new(clazz);
+       o = builtin_new(c);
        
        if (o == NULL)
                return NULL;
@@ -1895,7 +1907,7 @@ jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
        _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
        va_end(ap);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -1913,15 +1925,17 @@ jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
                                                   va_list args)
 {
        java_objectheader *o;
+       classinfo         *c;
        methodinfo        *m;
 
        STATISTICS(jniinvokation());
 
+       c = (classinfo *) clazz;
        m = (methodinfo *) methodID;
 
        /* create object */
 
-       o = builtin_new(clazz);
+       o = builtin_new(c);
        
        if (o == NULL)
                return NULL;
@@ -1930,7 +1944,7 @@ jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
 
        _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -1945,18 +1959,20 @@ jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
 *******************************************************************************/
 
 jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
-                                                  jvalue *args)
+                                                  const jvalue *args)
 {
        java_objectheader *o;
+       classinfo         *c;
        methodinfo        *m;
 
        STATISTICS(jniinvokation());
 
+       c = (classinfo *) clazz;
        m = (methodinfo *) methodID;
 
        /* create object */
 
-       o = builtin_new(clazz);
+       o = builtin_new(c);
        
        if (o == NULL)
                return NULL;
@@ -1965,7 +1981,7 @@ jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
 
        _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -2025,35 +2041,38 @@ jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)
 jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method)
 {
 #if defined(ENABLE_JAVASE)
-       methodinfo *mi;
-       classinfo  *c;
-       s4          slot;
+       java_objectheader *o;
+       classinfo         *c;
+       methodinfo        *m;
+       s4                 slot;
 
        STATISTICS(jniinvokation());
 
-       if (method == NULL)
+       o = (java_objectheader *) method;
+
+       if (o == NULL)
                return NULL;
        
-       if (builtin_instanceof(method, class_java_lang_reflect_Method)) {
+       if (builtin_instanceof(o, class_java_lang_reflect_Method)) {
                java_lang_reflect_Method *rm;
 
-               rm = (java_lang_reflect_Method *) method;
-               c = (classinfo *) (rm->declaringClass);
+               rm   = (java_lang_reflect_Method *) method;
+               c    = (classinfo *) (rm->clazz);
                slot = rm->slot;
        }
-       else if (builtin_instanceof(method, class_java_lang_reflect_Constructor)) {
+       else if (builtin_instanceof(o, class_java_lang_reflect_Constructor)) {
                java_lang_reflect_Constructor *rc;
 
-               rc = (java_lang_reflect_Constructor *) method;
-               c = (classinfo *) (rc->clazz);
+               rc   = (java_lang_reflect_Constructor *) method;
+               c    = (classinfo *) (rc->clazz);
                slot = rc->slot;
        }
        else
                return NULL;
 
-       mi = &(c->methods[slot]);
+       m = &(c->methods[slot]);
 
-       return (jmethodID) mi;
+       return (jmethodID) m;
 #else
        vm_abort("_Jv_JNI_FromReflectedMethod: not implemented in this configuration");
 
@@ -2084,8 +2103,7 @@ jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field)
        if (rf == NULL)
                return NULL;
 
-       c = (classinfo *) rf->declaringClass;
-
+       c = (classinfo *) rf->clazz;
        f = &(c->fields[rf->slot]);
 
        return (jfieldID) f;
@@ -2161,7 +2179,7 @@ jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
 
        c = (classinfo *) clazz;
 
-       if (!c)
+       if (c == NULL)
                return NULL;
 
        if (!(c->state & CLASS_INITIALIZED))
@@ -2173,7 +2191,7 @@ jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
        uname = utf_new_char((char *) name);
        udesc = utf_new_char((char *) sig);
 
-       m = class_resolvemethod(clazz, uname, udesc);
+       m = class_resolvemethod(c, uname, udesc);
 
        if ((m == NULL) || (m->flags & ACC_STATIC)) {
                exceptions_throw_nosuchmethoderror(c, uname, udesc);
@@ -2202,7 +2220,7 @@ jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID,
        ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, ap);
        va_end(ap);
 
-       return _Jv_JNI_NewLocalRef(env, ret);
+       return _Jv_JNI_NewLocalRef(env, (jobject) ret);
 }
 
 
@@ -2218,12 +2236,12 @@ jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
        ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, ret);
+       return _Jv_JNI_NewLocalRef(env, (jobject) ret);
 }
 
 
 jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                                 jvalue *args)
+                                                                 const jvalue *args)
 {
        java_objectheader *o;
        methodinfo        *m;
@@ -2234,7 +2252,7 @@ jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
 
        ret = _Jv_jni_CallObjectMethodA(o, o->vftbl, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, ret);
+       return _Jv_JNI_NewLocalRef(env, (jobject) ret);
 }
 
 
@@ -2274,7 +2292,7 @@ jboolean _Jv_JNI_CallBooleanMethodV(JNIEnv *env, jobject obj,
 
 
 jboolean _Jv_JNI_CallBooleanMethodA(JNIEnv *env, jobject obj,
-                                                                       jmethodID methodID, jvalue *args)
+                                                                       jmethodID methodID, const jvalue *args)
 {
        java_objectheader *o;
        methodinfo        *m;
@@ -2325,7 +2343,7 @@ jbyte _Jv_JNI_CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jbyte _Jv_JNI_CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                         jvalue *args)
+                                                         const jvalue *args)
 {
        log_text("JNI-Call: CallByteMethodA: IMPLEMENT ME!");
 
@@ -2368,7 +2386,7 @@ jchar _Jv_JNI_CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jchar _Jv_JNI_CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                         jvalue *args)
+                                                         const jvalue *args)
 {
        log_text("JNI-Call: CallCharMethodA: IMPLEMENT ME!");
 
@@ -2412,7 +2430,7 @@ jshort _Jv_JNI_CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jshort _Jv_JNI_CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                               jvalue *args)
+                                                               const jvalue *args)
 {
        log_text("JNI-Call: CallShortMethodA: IMPLEMENT ME!");
 
@@ -2456,7 +2474,7 @@ jint _Jv_JNI_CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jint _Jv_JNI_CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                       jvalue *args)
+                                                       const jvalue *args)
 {
        log_text("JNI-Call: CallIntMethodA: IMPLEMENT ME!");
 
@@ -2500,7 +2518,7 @@ jlong _Jv_JNI_CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jlong _Jv_JNI_CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                         jvalue *args)
+                                                         const jvalue *args)
 {
        log_text("JNI-Call: CallLongMethodA: IMPLEMENT ME!");
 
@@ -2545,7 +2563,7 @@ jfloat _Jv_JNI_CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jfloat _Jv_JNI_CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                               jvalue *args)
+                                                               const jvalue *args)
 {
        log_text("JNI-Call: CallFloatMethodA: IMPLEMENT ME!");
 
@@ -2590,7 +2608,7 @@ jdouble _Jv_JNI_CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 jdouble _Jv_JNI_CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                                 jvalue *args)
+                                                                 const jvalue *args)
 {
        log_text("JNI-Call: CallDoubleMethodA: IMPLEMENT ME!");
 
@@ -2628,7 +2646,7 @@ void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID,
 
 
 void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID,
-                                                        jvalue *args)
+                                                        const jvalue *args)
 {
        java_objectheader *o;
        methodinfo        *m;
@@ -2659,7 +2677,7 @@ jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
        r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
        va_end(ap);
 
-       return _Jv_JNI_NewLocalRef(env, r);
+       return _Jv_JNI_NewLocalRef(env, (jobject) r);
 }
 
 
@@ -2678,13 +2696,13 @@ jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
 
        r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, r);
+       return _Jv_JNI_NewLocalRef(env, (jobject) r);
 }
 
 
 jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj,
                                                                                        jclass clazz, jmethodID methodID,
-                                                                                       jvalue *args)
+                                                                                       const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!");
 
@@ -2736,7 +2754,7 @@ jboolean _Jv_JNI_CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj,
 
 jboolean _Jv_JNI_CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj,
                                                                                          jclass clazz, jmethodID methodID,
-                                                                                         jvalue *args)
+                                                                                         const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualBooleanMethodA: IMPLEMENT ME!");
 
@@ -2784,7 +2802,7 @@ jbyte _Jv_JNI_CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz,
 
 
 jbyte _Jv_JNI_CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz, 
-                                                                               jmethodID methodID, jvalue *args)
+                                                                               jmethodID methodID, const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualByteMethodA: IMPLEMENT ME!");
 
@@ -2833,7 +2851,7 @@ jchar _Jv_JNI_CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz,
 
 
 jchar _Jv_JNI_CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                                                               jmethodID methodID, jvalue *args)
+                                                                               jmethodID methodID, const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualCharMethodA: IMPLEMENT ME!");
 
@@ -2884,7 +2902,7 @@ jshort _Jv_JNI_CallNonvirtualShortMethodV(JNIEnv *env, jobject obj,
 
 jshort _Jv_JNI_CallNonvirtualShortMethodA(JNIEnv *env, jobject obj,
                                                                                  jclass clazz, jmethodID methodID,
-                                                                                 jvalue *args)
+                                                                                 const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualShortMethodA: IMPLEMENT ME!");
 
@@ -2933,7 +2951,7 @@ jint _Jv_JNI_CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz,
 
 
 jint _Jv_JNI_CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                                                         jmethodID methodID, jvalue *args)
+                                                                         jmethodID methodID, const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualIntMethodA: IMPLEMENT ME!");
 
@@ -2982,7 +3000,7 @@ jlong _Jv_JNI_CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz,
 
 
 jlong _Jv_JNI_CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                                                               jmethodID methodID, jvalue *args)
+                                                                               jmethodID methodID, const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualLongMethodA: IMPLEMENT ME!");
 
@@ -3033,7 +3051,7 @@ jfloat _Jv_JNI_CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj,
 
 jfloat _Jv_JNI_CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj,
                                                                                  jclass clazz, jmethodID methodID,
-                                                                                 jvalue *args)
+                                                                                 const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!");
 
@@ -3085,7 +3103,7 @@ jdouble _Jv_JNI_CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj,
 
 jdouble _Jv_JNI_CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj,
                                                                                        jclass clazz, jmethodID methodID,
-                                                                                       jvalue *args)
+                                                                                       const jvalue *args)
 {
        log_text("JNI-Call: CallNonvirtualDoubleMethodA: IMPLEMENT ME!");
 
@@ -3128,7 +3146,7 @@ void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
 
 
 void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
-                                                                          jmethodID methodID, jvalue * args)
+                                                                          jmethodID methodID, const jvalue * args)
 {      
        java_objectheader *o;
        classinfo         *c;
@@ -3154,7 +3172,7 @@ void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
 *******************************************************************************/
 
 jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
-                                                       const char *sig) 
+                                                       const char *sig)
 {
        classinfo *c;
        fieldinfo *f;
@@ -3165,10 +3183,12 @@ jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
 
        c = (classinfo *) clazz;
 
+       /* XXX NPE check? */
+
        uname = utf_new_char((char *) name);
        udesc = utf_new_char((char *) sig);
 
-       f = class_findfield(clazz, uname, udesc); 
+       f = class_findfield(c, uname, udesc); 
        
        if (f == NULL)
                exceptions_throw_nosuchfielderror(c, uname);  
@@ -3193,7 +3213,7 @@ jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)
 
        o = GET_FIELD(obj, java_objectheader*, fieldID);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -3447,7 +3467,7 @@ jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz,
        o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
        va_end(ap);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -3461,12 +3481,12 @@ jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz,
 
        o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
 jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
-                                                                               jmethodID methodID, jvalue *args)
+                                                                               jmethodID methodID, const jvalue *args)
 {
        methodinfo        *m;
        java_objectheader *o;
@@ -3475,7 +3495,7 @@ jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz,
 
        o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args);
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -3511,7 +3531,7 @@ jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz,
 
 
 jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz,
-                                                                                 jmethodID methodID, jvalue *args)
+                                                                                 jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jboolean    b;
@@ -3556,7 +3576,7 @@ jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz,
 
 
 jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz,
-                                                                       jmethodID methodID, jvalue *args)
+                                                                       jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jbyte       b;
@@ -3601,7 +3621,7 @@ jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz,
 
 
 jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz,
-                                                                       jmethodID methodID, jvalue *args)
+                                                                       jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jchar       c;
@@ -3646,7 +3666,7 @@ jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz,
 
 
 jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz,
-                                                                         jmethodID methodID, jvalue *args)
+                                                                         jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jshort      s;
@@ -3691,7 +3711,7 @@ jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz,
 
 
 jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz,
-                                                                 jmethodID methodID, jvalue *args)
+                                                                 jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jint        i;
@@ -3736,7 +3756,7 @@ jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz,
 
 
 jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz,
-                                                                       jmethodID methodID, jvalue *args)
+                                                                       jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jlong       l;
@@ -3782,7 +3802,7 @@ jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz,
 
 
 jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz,
-                                                                         jmethodID methodID, jvalue *args)
+                                                                         jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jfloat      f;
@@ -3827,7 +3847,7 @@ jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz,
 
 
 jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz,
-                                                                               jmethodID methodID, jvalue *args)
+                                                                               jmethodID methodID, const jvalue *args)
 {
        methodinfo *m;
        jdouble     d;
@@ -3866,7 +3886,7 @@ void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz,
 
 
 void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz,
-                                                                  jmethodID methodID, jvalue * args)
+                                                                  jmethodID methodID, const jvalue * args)
 {
        methodinfo *m;
 
@@ -3902,7 +3922,7 @@ jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
        uname = utf_new_char((char *) name);
        usig  = utf_new_char((char *) sig);
 
-       f = class_findfield(clazz, uname, usig);
+       f = class_findfield(c, uname, usig);
        
        if (f == NULL)
                exceptions_throw_nosuchfielderror(c, uname);
@@ -4308,7 +4328,11 @@ static jchar emptyStringJ[]={0,0};
 
 jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str)
 {
-       return ((java_lang_String *) str)->count;
+       java_lang_String *s;
+
+       s = (java_lang_String *) str;
+
+       return s->count;
 }
 
 
@@ -4419,13 +4443,18 @@ jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes)
 
 /****************** returns the utf8 length in bytes of a string *******************/
 
-jsize _Jv_JNI_GetStringUTFLength (JNIEnv *env, jstring string)
+jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string)
 {   
-    java_lang_String *s = (java_lang_String*) string;
+    java_lang_String *s;
+       s4                length;
 
        STATISTICS(jniinvokation());
 
-    return (jsize) u2_utflength(s->value->data, s->count); 
+       s = (java_lang_String *) string;
+
+    length = u2_utflength(s->value->data, s->count);
+
+       return length;
 }
 
 
@@ -4507,17 +4536,22 @@ jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array)
 jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
                                                                        jclass elementClass, jobject initialElement)
 {
-       java_objectarray *oa;
-       s4                i;
+       classinfo         *c;
+       java_objectheader *o;
+       java_objectarray  *oa;
+       s4                 i;
 
        STATISTICS(jniinvokation());
 
+       c = (classinfo *) elementClass;
+       o = (java_objectheader *) initialElement;
+
        if (length < 0) {
                exceptions_throw_negativearraysizeexception();
                return NULL;
        }
 
-    oa = builtin_anewarray(length, elementClass);
+    oa = builtin_anewarray(length, c);
 
        if (oa == NULL)
                return NULL;
@@ -4525,7 +4559,7 @@ jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
        /* set all elements to initialElement */
 
        for (i = 0; i < length; i++)
-               oa->data[i] = initialElement;
+               oa->data[i] = o;
 
        return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa);
 }
@@ -4534,8 +4568,8 @@ jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
 jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
                                                                          jsize index)
 {
-       java_objectarray *oa;
-       jobject           o;
+       java_objectarray  *oa;
+       java_objectheader *o;
 
        STATISTICS(jniinvokation());
 
@@ -4548,7 +4582,7 @@ jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array,
 
        o = oa->data[index];
 
-       return _Jv_JNI_NewLocalRef(env, o);
+       return _Jv_JNI_NewLocalRef(env, (jobject) o);
 }
 
 
@@ -4574,7 +4608,7 @@ void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array,
        if (!builtin_canstore(oa, o))
                return;
 
-       oa->data[index] = val;
+       oa->data[index] = o;
 }
 
 
@@ -5216,7 +5250,7 @@ void _Jv_JNI_GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
 *******************************************************************************/
 
 void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
-                                                                  jsize start, jsize len, jboolean *buf)
+                                                                  jsize start, jsize len, const jboolean *buf)
 {
        java_booleanarray *ba;
 
@@ -5232,7 +5266,7 @@ void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array,
 
 
 void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
-                                                               jsize len, jbyte *buf)
+                                                               jsize len, const jbyte *buf)
 {
        java_bytearray *ba;
 
@@ -5248,7 +5282,7 @@ void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start,
 
 
 void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
-                                                               jsize len, jchar *buf)
+                                                               jsize len, const jchar *buf)
 {
        java_chararray *ca;
 
@@ -5264,7 +5298,7 @@ void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start,
 
 
 void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
-                                                                jsize len, jshort *buf)
+                                                                jsize len, const jshort *buf)
 {
        java_shortarray *sa;
 
@@ -5280,7 +5314,7 @@ void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
 
 
 void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
-                                                          jsize len, jint *buf)
+                                                          jsize len, const jint *buf)
 {
        java_intarray *ia;
 
@@ -5296,7 +5330,7 @@ void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start,
 
 
 void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start,
-                                                               jsize len, jlong *buf)
+                                                               jsize len, const jlong *buf)
 {
        java_longarray *la;
 
@@ -5312,7 +5346,7 @@ void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start,
 
 
 void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
-                                                                jsize len, jfloat *buf)
+                                                                jsize len, const jfloat *buf)
 {
        java_floatarray *fa;
 
@@ -5328,7 +5362,7 @@ void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
 
 
 void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
-                                                                 jsize len, jdouble *buf)
+                                                                 jsize len, const jdouble *buf)
 {
        java_doublearray *da;
 
@@ -5358,13 +5392,18 @@ void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
 jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
                                                         const JNINativeMethod *methods, jint nMethods)
 {
+       classinfo *c;
+
        STATISTICS(jniinvokation());
 
-    log_text("JNI-Call: RegisterNatives: IMPLEMENT ME!!!");
+       c = (classinfo *) 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;
 }
 
@@ -5492,12 +5531,40 @@ void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize 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_chararray   *ca;
+       s4                i;
+
        STATISTICS(jniinvokation());
 
-       log_text("JNI-Call: GetStringUTFRegion: IMPLEMENT ME!");
+       s  = (java_lang_String *) str;
+       ca = s->value;
+
+       if ((start < 0) || (len < 0) || (start > s->count) ||
+               (start + len > s->count)) {
+               exceptions_throw_stringindexoutofboundsexception();
+               return;
+       }
+
+       /* XXX not sure if this is correct */
+
+       for (i = 0; i < len; i++)
+               buf[i] = ca->data[start + i];
+
+       buf[i] = '\0';
 }
 
 
@@ -5517,7 +5584,7 @@ void *_Jv_JNI_GetPrimitiveArrayCritical(JNIEnv *env, jarray array,
 
        /* do the same as Kaffe does */
 
-       bp = _Jv_JNI_GetByteArrayElements(env, ba, isCopy);
+       bp = _Jv_JNI_GetByteArrayElements(env, (jbyteArray) ba, isCopy);
 
        return (void *) bp;
 }
@@ -5596,9 +5663,12 @@ jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
        hashtable_global_ref_entry *gre;
        u4   key;                           /* hashkey                            */
        u4   slot;                          /* slot in hashtable                  */
+       java_objectheader *o;
 
        STATISTICS(jniinvokation());
 
+       o = (java_objectheader *) obj;
+
        LOCK_MONITOR_ENTER(hashtable_global_ref->header);
 
        /* normally addresses are aligned to 4, 8 or 16 bytes */
@@ -5610,7 +5680,7 @@ jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
        /* search external hash chain for the entry */
 
        while (gre) {
-               if (gre->o == obj) {
+               if (gre->o == o) {
                        /* global object found, increment the reference */
 
                        gre->refs++;
@@ -5633,7 +5703,7 @@ jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj)
        gc_reference_register(&(gre->o));
 #endif
 
-       gre->o    = obj;
+       gre->o    = o;
        gre->refs = 1;
 
        /* insert entry into hashtable */
@@ -5664,9 +5734,12 @@ void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
        hashtable_global_ref_entry *prevgre;
        u4   key;                           /* hashkey                            */
        u4   slot;                          /* slot in hashtable                  */
+       java_objectheader          *o;
 
        STATISTICS(jniinvokation());
 
+       o = (java_objectheader *) globalRef;
+
        LOCK_MONITOR_ENTER(hashtable_global_ref->header);
 
        /* normally addresses are aligned to 4, 8 or 16 bytes */
@@ -5682,7 +5755,7 @@ void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef)
        /* search external hash chain for the entry */
 
        while (gre) {
-               if (gre->o == globalRef) {
+               if (gre->o == o) {
                        /* global object found, decrement the reference count */
 
                        gre->refs--;
@@ -5752,8 +5825,9 @@ jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
 
 jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
 {
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
        java_objectheader       *nbuf;
+
 # if SIZEOF_VOID_P == 8
        gnu_classpath_Pointer64 *paddress;
 # else
@@ -5805,7 +5879,7 @@ jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity)
 
 void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 {
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
        java_nio_DirectByteBufferImpl *nbuf;
 # if SIZEOF_VOID_P == 8
        gnu_classpath_Pointer64       *address;
@@ -5849,15 +5923,18 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
 jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf)
 {
-#if defined(ENABLE_JAVASE)
-       java_nio_Buffer *nbuf;
+#if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU)
+       java_objectheader *o;
+       java_nio_Buffer   *nbuf;
 
        STATISTICS(jniinvokation());
 
-       if (!builtin_instanceof(buf, class_java_nio_DirectByteBufferImpl))
+       o = (java_objectheader *) buf;
+
+       if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl))
                return -1;
 
-       nbuf = (java_nio_Buffer *) buf;
+       nbuf = (java_nio_Buffer *) o;
 
        return (jlong) nbuf->cap;
 #else
@@ -6054,7 +6131,7 @@ jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args)
 
 /* JNI invocation table *******************************************************/
 
-const struct JNIInvokeInterface _Jv_JNIInvokeInterface = {
+const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = {
        NULL,
        NULL,
        NULL,
@@ -6069,7 +6146,7 @@ const struct JNIInvokeInterface _Jv_JNIInvokeInterface = {
 
 /* JNI function table *********************************************************/
 
-struct JNINativeInterface _Jv_JNINativeInterface = {
+struct JNINativeInterface_ _Jv_JNINativeInterface = {
        NULL,
        NULL,
        NULL,
index 693f1e3de3e21ac52a14d2631011f54b1952ba69..8848d524577cfd27a692e1822d62f4d1c0e0c464 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.h 7921 2007-05-20 23:14:11Z michi $
+   $Id: jni.h 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
 
 #include "config.h"
 
-#include CLASSPATH_JNI_H
+/* XXX quick hack to not include GCJ's jni_md.h */
+#define __GCJ_JNI_MD_H__
 
+#include CLASSPATH_JNI_MD_H
+#include CLASSPATH_JNI_H
 
 #ifndef _JNI_H
 #define _JNI_H
@@ -66,7 +69,7 @@ typedef struct localref_table localref_table;
 typedef struct _Jv_JNIEnv _Jv_JNIEnv;
 
 struct _Jv_JNIEnv {
-       const struct JNINativeInterface *env;     /* This MUST be the first entry */
+       const struct JNINativeInterface_ *env;    /* This MUST be the first entry */
 };
 
 
@@ -75,7 +78,7 @@ struct _Jv_JNIEnv {
 typedef struct _Jv_JavaVM _Jv_JavaVM;
 
 struct _Jv_JavaVM {
-       const struct JNIInvokeInterface *functions;/* This MUST be the first entry*/
+       const struct JNIInvokeInterface_ *functions;/*This MUST be the first entry*/
 
        /* JVM instance-specific variables */
 
@@ -92,8 +95,8 @@ struct _Jv_JavaVM {
 
 /* CACAO related stuff ********************************************************/
 
-extern const struct JNIInvokeInterface _Jv_JNIInvokeInterface;
-extern struct JNINativeInterface _Jv_JNINativeInterface;
+extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface;
+extern struct JNINativeInterface_ _Jv_JNINativeInterface;
 
 
 /* local reference table ******************************************************/
index 7184bc7e0e54c1df5299571bafd07278aa4e6d07..77e9e249ccbd32d17ea25431f0ebfe96cfa890ab 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: native.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: native.c 8137 2007-06-22 16:41:36Z michi $
 
 */
 
@@ -36,6 +36,8 @@
 # include <ltdl.h>
 #endif
 
+#include <stdint.h>
+
 #include "vm/types.h"
 
 #include "mm/memory.h"
@@ -125,11 +127,6 @@ bool native_init(void)
 
        tree_native_methods = avl_create(&native_tree_native_methods_comparator);
 
-       /* register the intern native functions */
-
-       if (!nativevm_init())
-               return false;
-
        /* everything's ok */
 
        return true;
@@ -447,12 +444,13 @@ static utf *native_method_symbol(utf *classname, utf *methodname)
 
 *******************************************************************************/
 
-void native_method_register(utf *classname, JNINativeMethod *methods, s4 count)
+void native_method_register(utf *classname, const JNINativeMethod *methods,
+                                                       int32_t count)
 {
        native_methods_node_t *nmn;
        utf                   *name;
        utf                   *descriptor;
-       s4                     i;
+       int32_t                i;
 
        /* insert all methods passed */
 
@@ -523,6 +521,12 @@ 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);
@@ -756,6 +760,7 @@ functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
 
 functionptr native_resolve_function(methodinfo *m)
 {
+       java_objectheader              *cl;
        utf                            *name;
        utf                            *newname;
        functionptr                     f;
@@ -763,6 +768,12 @@ functionptr native_resolve_function(methodinfo *m)
        hashtable_library_name_entry   *ne;
        u4                              key;    /* hashkey                        */
        u4                              slot;   /* slot in hashtable              */
+#if defined(WITH_CLASSPATH_SUN)
+       methodinfo                     *method_findNative;
+       java_objectheader              *s;
+#endif
+
+       cl = m->class->classloader;
 
        /* verbose output */
 
@@ -789,7 +800,7 @@ functionptr native_resolve_function(methodinfo *m)
 
        /* normally addresses are aligned to 4, 8 or 16 bytes */
 
-       key  = ((u4) (ptrint) m->class->classloader) >> 4;    /* align to 16-byte */
+       key  = ((u4) (ptrint) cl) >> 4;                       /* align to 16-byte */
        slot = key & (hashtable_library->size - 1);
        le   = hashtable_library->ptr[slot];
 
@@ -812,6 +823,40 @@ functionptr native_resolve_function(methodinfo *m)
                le = le->hashlink;
        }
 
+#if defined(WITH_CLASSPATH_SUN)
+       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");
index 0373bbbbab4ef3f52a41d7f60b202f2d47242f96..4b64fb5ed646d422329797699e87d6a035868a1e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: native.h 8123 2007-06-20 23:50:55Z michi $
+   $Id: native.h 8137 2007-06-22 16:41:36Z michi $
 
 */
 
@@ -36,6 +36,8 @@
 # include <ltdl.h>
 #endif
 
+#include <stdint.h>
+
 #include "native/jni.h"
 
 #include "vm/global.h"
@@ -116,7 +118,8 @@ struct nativecompref {
 
 bool native_init(void);
 
-void native_method_register(utf *classname, JNINativeMethod *methods, s4 count);
+void native_method_register(utf *classname, const JNINativeMethod *methods,
+                                                       int32_t count);
 
 #if defined(WITH_STATIC_CLASSPATH)
 
index 5cd7dee95a3dfd33821c44042301d26555586f57..12c3aa9451913a3b62a66aa94137e99ead3e6f5a 100644 (file)
@@ -32,7 +32,8 @@ LIBS =
 
 DIST_SUBDIRS = \
        cldc1.1 \
-       gnu
+       gnu \
+       sun
 
 if WITH_CLASSPATH_CLDC1_1
 SUBDIRS = \
@@ -50,6 +51,14 @@ NATIVEVM_LIB = \
        gnu/libnativevmcore.la
 endif
 
+if WITH_CLASSPATH_SUN
+SUBDIRS = \
+       sun
+
+NATIVEVM_LIB = \
+       sun/libnativevmcore.la
+endif
+
 if ENABLE_JAVASE
 CLASSLOADER_SOURCES = \
        java_lang_ClassLoader.c \
index 66871ef729622d2cd25a74de1a34ec9b99f0b81d..af9fb08d89c11ac3aa0dd040051b6aa1a81182f8 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Field.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: java_lang_reflect_Field.c 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
@@ -127,7 +127,7 @@ static void *cacao_get_field_address(java_lang_reflect_Field *this,
        classinfo *c;
        fieldinfo *f;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* check field access */
@@ -186,7 +186,7 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getModifiersInternal(JNIE
        classinfo *c;
        fieldinfo *f;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &(c->fields[this->slot]);
 
        return f->flags;
@@ -204,7 +204,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv *
        typedesc  *desc;
        classinfo *ret;
 
-       c    = (classinfo *) this->declaringClass;
+       c    = (classinfo *) this->clazz;
        desc = c->fields[this->slot].parseddesc;
 
        if (desc == NULL)
@@ -228,7 +228,7 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Field_get(JNIEnv *env
        fieldinfo *f;
        void      *addr;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get address of the source field value */
@@ -358,7 +358,7 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getBoolean(JNIEnv *env, j
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -391,7 +391,7 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getByte(JNIEnv *env, java
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -424,7 +424,7 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getChar(JNIEnv *env, java
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -457,7 +457,7 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getShort(JNIEnv *env, jav
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -491,7 +491,7 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getInt(JNIEnv *env , java
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -527,7 +527,7 @@ JNIEXPORT int64_t JNICALL Java_java_lang_reflect_Field_getLong(JNIEnv *env, java
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -565,7 +565,7 @@ JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat(JNIEnv *env, java_
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -605,7 +605,7 @@ JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble(JNIEnv *env , ja
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -649,7 +649,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r
 
        /* get the class and the field */
 
-       dc = (classinfo *) this->declaringClass;
+       dc = (classinfo *) this->clazz;
        df = &dc->fields[this->slot];
 
        /* get the address of the destination field */
@@ -920,7 +920,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean(JNIEnv *env, java
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -955,7 +955,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte(JNIEnv *env, java_la
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1001,7 +1001,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar(JNIEnv *env, java_la
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1046,7 +1046,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort(JNIEnv *env, java_l
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1091,7 +1091,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt(JNIEnv *env, java_lan
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1135,7 +1135,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong(JNIEnv *env, java_la
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1176,7 +1176,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat(JNIEnv *env, java_l
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1214,7 +1214,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble(JNIEnv *env, java_
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        /* get the address of the field with an internal helper */
@@ -1249,7 +1249,7 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JN
 
        /* get the class and the field */
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        f = &c->fields[this->slot];
 
        if (f->signature == NULL)
index ea9ccaab842d5cec982c0ca1a773099e9fcb49f0..96888b0808aefea4d70538f3abe28eff2841c8c5 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Method.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: java_lang_reflect_Method.c 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
@@ -93,7 +93,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *
        classinfo  *c;
        methodinfo *m;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        m = &(c->methods[this->slot]);
 
        return m->flags;
@@ -111,7 +111,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(J
        methodinfo *m;
        classinfo  *result;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        m = &(c->methods[this->slot]);
 
        result = method_returntype_get(m);
@@ -130,7 +130,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTy
        classinfo  *c;
        methodinfo *m;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        m = &(c->methods[this->slot]);
 
        return method_get_parametertypearray(m);
@@ -147,7 +147,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTy
        classinfo  *c;
        methodinfo *m;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        m = &(c->methods[this->slot]);
 
        return method_get_exceptionarray(m);
@@ -159,11 +159,11 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTy
  * Method:    invokeNative
  * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
  */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *o, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *o, java_objectarray *args, java_lang_Class *clazz, s4 slot)
 {
        /* just to be sure */
 
-       assert(this->declaringClass == declaringClass);
+       assert(this->clazz == clazz);
        assert(this->slot           == slot);
 
        return _Jv_java_lang_reflect_Method_invoke(this, o, args);
@@ -181,7 +181,7 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(J
        methodinfo        *m;
        java_objectheader *o;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        m = &(c->methods[this->slot]);
 
        if (m->signature == NULL)
index c434a5afeab59848705b4069672a3bd79f2a9cf9..57f4d5ad14a79c42204438e944d32ff954e26aca 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_Class.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: java_lang_Class.c 8137 2007-06-22 16:41:36Z michi $
 
 */
 
 #include "native/jni.h"
 #include "native/native.h"
 
-#if defined(ENABLE_JAVAME_CLDC1_1)
-# include "native/include/java_lang_String.h"/* required by java_lang_Class.h */
+/* keep this order of the native includes */
+
+#include "native/include/java_lang_String.h"
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_CLASSPATH_SUN)
+#  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_Class.h"
 #include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
 
 #if defined(ENABLE_JAVASE)
-# 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"
 #endif
 
 #include "native/vm/java_lang_Class.h"
+#include "native/vm/java_lang_String.h"
 
 #include "toolbox/logging.h"
 
@@ -586,9 +593,32 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredFields(java_lang_Class *klass,
 
                        rf = (java_lang_reflect_Field *) o;
 
-                       rf->declaringClass = (java_lang_Class *) c;
-                       rf->name           = (java_lang_String *) javastring_new(f->name);
+#if defined(WITH_CLASSPATH_GNU)
+
+                       rf->clazz = (java_lang_Class *) c;
+
+                       /* The name needs to be interned */
+                       /* XXX implement me better! */
+
+                       rf->name           = _Jv_java_lang_String_intern((java_lang_String *) javastring_new(f->name));
+                       rf->slot           = i;
+
+#elif defined(WITH_CLASSPATH_SUN)
+
+                       rf->clazz          = (java_lang_Class *) c;
+
+                       /* The name needs to be interned */
+                       /* XXX implement me better! */
+
+                       rf->name           = _Jv_java_lang_String_intern((java_lang_String *) javastring_new(f->name));
+                       rf->type           = (java_lang_Class *) field_get_type(f);
+                       rf->modifiers      = f->flags;
                        rf->slot           = i;
+                       rf->signature      = f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL;
+                       rf->annotations    = NULL;
+#else
+# error unknown classpath configuration
+#endif
 
                        /* store object into array */
 
@@ -659,9 +689,37 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredMethods(java_lang_Class *klass,
 
                        rm = (java_lang_reflect_Method *) o;
 
-                       rm->declaringClass = (java_lang_Class *) m->class;
-                       rm->name           = (java_lang_String *) javastring_new(m->name);
-                       rm->slot           = i;
+#if defined(WITH_CLASSPATH_GNU)
+
+                       rm->clazz       = (java_lang_Class *) m->class;
+
+                       /* The name needs to be interned */
+                       /* XXX implement me better! */
+
+                       rm->name                 = _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name));
+                       rm->slot                 = i;
+
+#elif defined(WITH_CLASSPATH_SUN)
+
+                       rm->clazz                = (java_lang_Class *) m->class;
+
+                       /* The name needs to be interned */
+                       /* XXX implement me better! */
+
+                       rm->name                 = _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name));
+                       rm->parameterTypes       = method_get_parametertypearray(m);
+                       rm->returnType           = (java_lang_Class *) method_returntype_get(m);
+                       rm->exceptionTypes       = method_get_exceptionarray(m);
+                       rm->modifiers            = m->flags & ACC_CLASS_REFLECT_MASK;
+                       rm->slot                 = i;
+                       rm->signature            = m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL;
+                       rm->annotations          = NULL;
+                       rm->parameterAnnotations = NULL;
+                       rm->annotationDefault    = NULL;
+
+#else
+# error unknown classpath configuration
+#endif
 
                        /* store object into array */
 
@@ -721,8 +779,25 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredConstructors(java_lang_Class *k
 
                        rc = (java_lang_reflect_Constructor *) o;
 
-                       rc->clazz = (java_lang_Class *) c;
-                       rc->slot  = i;
+#if defined(WITH_CLASSPATH_GNU)
+
+                       rc->clazz                = (java_lang_Class *) c;
+                       rc->slot                 = i;
+
+#elif defined(WITH_CLASSPATH_SUN)
+
+                       rc->clazz                = (java_lang_Class *) c;
+                       rc->parameterTypes       = method_get_parametertypearray(m);
+                       rc->exceptionTypes       = method_get_exceptionarray(m);
+                       rc->modifiers            = m->flags & ACC_CLASS_REFLECT_MASK;
+                       rc->slot                 = i;
+                       rc->signature            = m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL;
+                       rc->annotations          = NULL;
+                       rc->parameterAnnotations = NULL;
+
+#else
+# error unknown classpath configuration
+#endif
 
                        /* store object into array */
 
@@ -969,7 +1044,14 @@ java_lang_reflect_Method *_Jv_java_lang_Class_getEnclosingMethod(java_lang_Class
 
        rm = (java_lang_reflect_Method *) o;
 
-       rm->declaringClass = (java_lang_Class *) m->class;
+#if defined(WITH_CLASSPATH_GNU)
+       rm->clazz          = (java_lang_Class *) m->class;
+#elif defined(WITH_CLASSPATH_SUN)
+       rm->clazz          = (java_lang_Class *) m->class;
+#else
+# error unknown classpath configuration
+#endif
+
        rm->name           = (java_lang_String *) javastring_new(m->name);
        rm->slot           = m - m->class->methods;      /* calculate method slot */
 
index 2c3f1d59961313c68d558dc62954c07a62ba00e8..e4d7ff1cfc5dedaa754327136ee370808def74fd 100644 (file)
 
 #include "native/jni.h"
 
+/* keep this order of the native includes */
+
 #include "native/include/java_lang_Object.h"
 
 #if defined(ENABLE_JAVASE)
-# include "native/include/java_lang_String.h"/* required by java_lang_Class.h */
+# include "native/include/java_lang_String.h"            /* required by j.l.C */
+
+# if defined(WITH_CLASSPATH_SUN)
+#  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_ClassLoader.h"
 # include "native/include/java_security_ProtectionDomain.h"
 #endif
 
@@ -72,6 +79,7 @@ java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl
        classinfo         *c;
        classloader       *loader;
        java_lang_Class   *o;
+
 #if defined(ENABLE_JVMTI)
        jint new_class_data_len = 0;
        unsigned char* new_class_data = NULL;
@@ -130,11 +138,15 @@ java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl
        if (c == NULL)
                return NULL;
 
-       /* set ProtectionDomain */
+       /* for convenience */
 
        o = (java_lang_Class *) c;
 
+#if defined(WITH_CLASSPATH_GNU)
+       /* set ProtectionDomain */
+
        o->pd = pd;
+#endif
 
        return o;
 }
index adadd0d0be95e9de84fa6abe5b779cc40170a863..be107dde0f1a04a3dc94808e025c658e6c6184bd 100644 (file)
 
 #include "native/jni.h"
 
-#if defined(ENABLE_JAVAME_CLDC1_1)
-# include "native/include/java_lang_String.h"/* required by java_lang_Class.h */
-#endif
-
-#include "native/include/java_lang_Class.h"
+#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_String.h"            /* required by j.l.CL */
 
 #if defined(ENABLE_JAVASE)
+# if defined(WITH_CLASSPATH_SUN)
+#  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_Cloneable.h"
 #endif
 
-#include "native/include/java_lang_Object.h"
+#include "native/include/java_lang_Class.h"
 
 #include "threads/lock-common.h"
 
 #include "vm/builtin.h"
+#include "vm/exceptions.h"
 
 #include "vmcore/options.h"
 
  */
 java_lang_Class *_Jv_java_lang_Object_getClass(java_lang_Object *obj)
 {
-       classinfo *c;
+       java_objectheader *o;
+       classinfo         *c;
+
+       o = (java_objectheader *) obj;
 
-       if (obj == NULL)
+       if (o == NULL) {
+               exceptions_throw_nullpointerexception();
                return NULL;
+       }
 
-       c = ((java_objectheader *) obj)->vftbl->class;
+       c = o->vftbl->class;
 
        return (java_lang_Class *) c;
 }
index 9d7146513d2ab5a7bb10adc5d699fddde388c1d5..a33e4bcfd7bc958ed6942ff2ea8ef211110990eb 100644 (file)
 
 #include "native/jni.h"
 
-#include "native/include/java_lang_Class.h"
-
 #if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_String.h"           /* required by j.l.CL */
+
+# if defined(WITH_CLASSPATH_SUN)
+#  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_Cloneable.h"
 #endif
 
+#include "native/include/java_lang_Class.h"
+
 #include "native/include/java_lang_Object.h"
 
 
index b13766677071e14210c201dd3f5b2217531ac86b..421c1823e3dee10dcf397c696c20a70ecaa536d9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_Thread.c 7833 2007-04-26 13:07:05Z twisti $
+   $Id: java_lang_Thread.c 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
 
 #if defined(ENABLE_JAVASE)
 # include "native/include/java_lang_ThreadGroup.h"
-# include "native/include/java_lang_VMThread.h"
+
+# if defined(WITH_CLASSPATH_GNU)
+#  include "native/include/java_lang_VMThread.h"
+# endif
 #endif
 
 #include "threads/lock-common.h"
@@ -123,15 +126,30 @@ void _Jv_java_lang_Thread_interrupt(java_lang_Thread *this)
 s4 _Jv_java_lang_Thread_isAlive(java_lang_Thread *this)
 {
 #if defined(ENABLE_THREADS)
-       threadobject *thread;
+       threadobject *t;
 
-#if defined(WITH_CLASSPATH_GNU)
-       thread = (threadobject *) this->vmThread->vmdata;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
-       thread = (threadobject *) this->vm_thread;
-#endif
+# if defined(WITH_CLASSPATH_GNU)
+       t = (threadobject *) this->vmThread->vmdata;
+# elif defined(WITH_CLASSPATH_SUN)
+       /* XXX this is just a quick hack */
 
-       return threads_thread_is_alive(thread);
+       for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+               if (t->object == this)
+                       break;
+       }
+
+       /* The threadobject is null when a thread is created in Java. The
+          priority is set later during startup. */
+
+       if (t == NULL)
+               return 0;
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+       t = (threadobject *) this->vm_thread;
+# else
+#  error unknown classpath configuration
+# endif
+
+       return threads_thread_is_alive(t);
 #else
        /* if threads are disabled, the only thread running is alive */
 
@@ -148,15 +166,24 @@ s4 _Jv_java_lang_Thread_isAlive(java_lang_Thread *this)
 s4 _Jv_java_lang_Thread_isInterrupted(java_lang_Thread *this)
 {
 #if defined(ENABLE_THREADS)
-       threadobject *thread;
+       threadobject *t;
 
-#if defined(WITH_CLASSPATH_GNU)
-       thread = (threadobject *) this->vmThread->vmdata;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
-       thread = (threadobject *) this->vm_thread;
-#endif
+# if defined(WITH_CLASSPATH_GNU)
+       t = (threadobject *) this->vmThread->vmdata;
+# elif defined(WITH_CLASSPATH_SUN)
+       /* XXX this is just a quick hack */
+
+       for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+               if (t->object == this)
+                       break;
+       }
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+       t = (threadobject *) this->vm_thread;
+# else
+#  error unknown classpath configuration
+# endif
 
-       return threads_thread_has_been_interrupted(thread);
+       return threads_thread_has_been_interrupted(t);
 #else
        return 0;
 #endif
@@ -195,21 +222,36 @@ void _Jv_java_lang_Thread_resume(java_lang_Thread *this)
 void _Jv_java_lang_Thread_setPriority(java_lang_Thread *this, s4 priority)
 {
 #if defined(ENABLE_THREADS)
-       threadobject *thread;
+       threadobject *t;
 
-#if defined(WITH_CLASSPATH_GNU)
-       thread = (threadobject *) this->vmThread->vmdata;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
-       thread = (threadobject *) this->vm_thread;
+# if defined(WITH_CLASSPATH_GNU)
+       t = (threadobject *) this->vmThread->vmdata;
+# elif defined(WITH_CLASSPATH_SUN)
+       /* XXX this is just a quick hack */
+
+       for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+               if (t->object == this)
+                       break;
+       }
 
        /* The threadobject is null when a thread is created in Java. The
           priority is set later during startup. */
 
-       if (thread == NULL)
+       if (t == NULL)
                return;
-#endif
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+       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;
+# else
+#  error unknown classpath configuration
+# endif
 
-       threads_set_thread_priority(thread->tid, priority);
+       threads_set_thread_priority(t->tid, priority);
 #endif
 }
 
index 9d3f3d12ba620a476f483ee738b6f5ea34db73d8..0830afd22627eb06a1e674501ffef71e7b18c6a1 100644 (file)
@@ -57,15 +57,24 @@ java_lang_Object *_Jv_java_lang_reflect_Method_invoke(java_lang_reflect_Method *
 {
        classinfo  *c;
        methodinfo *m;
+       s4          override;
 
-       c = (classinfo *) this->declaringClass;
+       c = (classinfo *) this->clazz;
        m = &(c->methods[this->slot]);
 
        /* check method access */
 
        /* check if we should bypass security checks (AccessibleObject) */
 
-       if (this->flag == false) {
+#if defined(WITH_CLASSPATH_GNU)
+       override = this->flag;
+#elif defined(WITH_CLASSPATH_SUN)
+       override = this->override;
+#else
+# error unknown classpath configuration
+#endif
+
+       if (override == false) {
                if (!access_check_method(m, 1))
                        return NULL;
        }
@@ -78,7 +87,7 @@ java_lang_Object *_Jv_java_lang_reflect_Method_invoke(java_lang_reflect_Method *
 
        /* call the Java method via a helper function */
 
-       return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
+       return (java_lang_Object *) _Jv_jni_invokeNative(m, (java_objectheader *) o, args);
 }
 
 
index 6c81da05559fe18c928b6a59c61d09a5882ff586..fdf4aa0635270d44d4ca1d0673560c8056d644b5 100644 (file)
 
 #include "native/vm/nativevm.h"
 
+#include "vmcore/method.h"
 
-/* nativevm_init ***************************************************************
+#if defined(WITH_CLASSPATH_SUN)
+# include "native/native.h"
 
-   Initialize the implementation specific native stuff.
+# include "vm/vm.h"
+
+# include "vmcore/class.h"
+# include "vmcore/utf8.h"
+#endif
+
+
+/* nativevm_preinit ************************************************************
+
+   Pre-initialize the implementation specific native stuff.
 
 *******************************************************************************/
 
-bool nativevm_init(void)
+bool nativevm_preinit(void)
 {
        /* register native methods of all classes implemented */
 
@@ -70,6 +81,18 @@ bool nativevm_init(void)
        _Jv_java_util_concurrent_atomic_AtomicLong_init();
        _Jv_sun_misc_Unsafe_init();
 
+# elif defined(WITH_CLASSPATH_SUN)
+
+       utf         *u;
+       lt_dlhandle  handle;
+
+       u = utf_new_char(CLASSPATH_LIBDIR"/libjava.so");
+
+       handle = native_library_open(u);
+       native_library_add(u, NULL, handle);
+
+       _Jv_sun_misc_Unsafe_init();
+
 # else
 
 #  error unknown classpath configuration
@@ -105,6 +128,57 @@ bool nativevm_init(void)
 }
 
 
+/* nativevm_init ***************************************************************
+
+   Initialize the implementation specific native stuff.
+
+*******************************************************************************/
+
+bool nativevm_init(void)
+{
+#if defined(ENABLE_JAVASE)
+
+# if defined(WITH_CLASSPATH_GNU)
+
+       /* nothing to do */
+
+# elif defined(WITH_CLASSPATH_SUN)
+
+       methodinfo *m;
+
+       m = class_resolveclassmethod(class_java_lang_System,
+                                                                utf_new_char("initializeSystemClass"),
+                                                                utf_void__void,
+                                                                class_java_lang_Object,
+                                                                false);
+
+       if (m == NULL)
+               return false;
+
+       (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
+
+       /* everything's ok */
+
+       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 edddff327941187fe862a33559e37fc920612c75..8920fa85955ff8873cde4c2d22297554380639ad 100644 (file)
@@ -38,6 +38,7 @@
 
 /* function prototypes ********************************************************/
 
+bool nativevm_preinit(void);
 bool nativevm_init(void);
 
 #if defined(ENABLE_JAVASE)
@@ -67,6 +68,10 @@ void _Jv_java_security_VMAccessController_init();
 void _Jv_java_util_concurrent_atomic_AtomicLong_init();
 void _Jv_sun_misc_Unsafe_init();
 
+# elif defined(WITH_CLASSPATH_SUN)
+
+void _Jv_sun_misc_Unsafe_init();
+
 # else
 
 #  error unknown classpath configuration
index 82c54860ec76022bf9aa27f75891bdb8887c0e0c..8854705b27dbed7ba68ed7c288b4498821b08ecc 100644 (file)
 
 #include <stdint.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_Object.h"                  /* before c.l.C */
+#include "native/include/java_lang_String.h"            /* required by j.l.CL */
+
+#if defined(WITH_CLASSPATH_SUN)
+# 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_CLASSPATH_SUN)
+# include "native/include/java_security_ProtectionDomain.h" /* required by smU*/
+#endif
 
 #include "native/include/sun_misc_Unsafe.h"
 
+#include "vm/exceptions.h"
+#include "vm/initialize.h"
+
 #include "vmcore/utf8.h"
 
 
 /* native methods implemented by this file ************************************/
 
 static JNINativeMethod methods[] = {
-       { "objectFieldOffset",    "(Ljava/lang/reflect/Field;)J",                               (void *) (intptr_t) &Java_sun_misc_Unsafe_objectFieldOffset    },
-       { "compareAndSwapInt",    "(Ljava/lang/Object;JII)Z",                                   (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt    },
-#if 0
-       { "compareAndSwapLong",   "(Ljava/lang/Object;JJJ)Z",                                   (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong   },
-       { "compareAndSwapObject", "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject },
-       { "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       },
-       { "putOrderedObject",     "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedObject     },
-       { "putIntVolatile",       "(Ljava/lang/Object;JI)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putIntVolatile       },
-       { "getIntVolatile",       "(Ljava/lang/Object;J)I",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getIntVolatile       },
-       { "putLongVolatile",      "(Ljava/lang/Object;JJ)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putLongVolatile      },
-       { "putLong",              "(Ljava/lang/Object;JJ)V",                                    (void *) (intptr_t) &Java_sun_misc_Unsafe_putLong              },
-       { "getLongVolatile",      "(Ljava/lang/Object;J)J",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getLongVolatile      },
-       { "getLong",              "(Ljava/lang/Object;J)J",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getLong              },
-       { "putObjectVolatile",    "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (intptr_t) &Java_sun_misc_Unsafe_putObjectVolatile    },
-       { "putObject",            "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (intptr_t) &Java_sun_misc_Unsafe_putObject            },
-       { "getObjectVolatile",    "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void *) (intptr_t) &Java_sun_misc_Unsafe_getObjectVolatile    },
-       { "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      },
-       { "unpark",               "(Ljava/lang/Thread;)V",                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_unpark               },
-       { "park",                 "(ZJ)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_park                 },
-#endif
+       { "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   },
+       { "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 },
+       { "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 },
+       { "getByte",                "(J)B",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getByte__J                     },
+       { "getInt",                 "(J)I",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getInt__J                      },
+       { "getLong",                "(J)J",                                                       (void *) (intptr_t) &Java_sun_misc_Unsafe_getLong__J                     },
+       { "putLong",                "(JJ)V",                                                      (void *) (intptr_t) &Java_sun_misc_Unsafe_putLong__JJ                    },
+       { "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                 },
+       { "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                    },
+       { "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              },
+       { "getIntVolatile",         "(Ljava/lang/Object;J)I",                                     (void *) (intptr_t) &Java_sun_misc_Unsafe_getIntVolatile                 },
 };
 
 
@@ -89,185 +112,306 @@ void _Jv_sun_misc_Unsafe_init(void)
 
 /*
  * Class:     sun/misc/Unsafe
- * Method:    objectFieldOffset
- * Signature: (Ljava/lang/reflect/Field;)J
+ * Method:    registerNatives
+ * Signature: ()V
  */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_registerNatives(JNIEnv *env, jclass clazz)
 {
-       classinfo *c;
-       fieldinfo *f;
+       /* The native methods of this function are already registered in
+          _Jv_sun_misc_Unsafe_init() which is called during VM
+          startup. */
+}
 
-       c = (classinfo *) field->declaringClass;
-       f = &c->fields[field->slot];
 
-       return (int64_t) f->offset;
+/*
+ * 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:    compareAndSwapInt
- * Signature: (Ljava/lang/Object;JII)Z
+ * Method:    getBoolean
+ * Signature: (Ljava/lang/Object;J)Z
  */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* this, java_lang_Object* obj, int64_t offset, int32_t expect, int32_t update)
+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 *) (((u1 *) obj) + offset);
-
-       /* XXX this should be atomic */
+       p = (int32_t *) (((uint8_t *) o) + offset);
 
        value = *p;
 
-       if (value == expect) {
-               *p = update;
+       return value;
+}
 
-               return true;
-       }
 
-       return false;
+/*
+ * 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;
 }
 
 
-#if 0
 /*
  * Class:     sun/misc/Unsafe
- * Method:    compareAndSwapLong
- * Signature: (Ljava/lang/Object;JJJ)Z
+ * Method:    getByte
+ * Signature: (Ljava/lang/Object;J)B
  */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, int64_t par3, int64_t par4)
+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:    compareAndSwapObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z
+ * Method:    putByte
+ * Signature: (Ljava/lang/Object;JB)V
  */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, struct java_lang_Object* par3, struct java_lang_Object* par4)
+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:    putOrderedInt
- * Signature: (Ljava/lang/Object;JI)V
+ * Method:    getChar
+ * Signature: (Ljava/lang/Object;J)C
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, int32_t par3)
+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:    putOrderedLong
- * Signature: (Ljava/lang/Object;JJ)V
+ * Method:    putChar
+ * Signature: (Ljava/lang/Object;JC)V
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, int64_t par3)
+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:    putOrderedObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ * Method:    getByte
+ * Signature: (J)B
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, struct java_lang_Object* par3)
+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:    putIntVolatile
- * Signature: (Ljava/lang/Object;JI)V
+ * Method:    getInt
+ * Signature: (J)I
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, int32_t par3)
+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:    getIntVolatile
- * Signature: (Ljava/lang/Object;J)I
+ * Method:    getLong
+ * Signature: (J)J
  */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2)
+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:    putLongVolatile
- * Signature: (Ljava/lang/Object;JJ)V
+ * Method:    putLong
+ * Signature: (JJ)V
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, int64_t par3)
+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:    putLong
- * Signature: (Ljava/lang/Object;JJ)V
+ * Method:    objectFieldOffset
+ * Signature: (Ljava/lang/reflect/Field;)J
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, int64_t par3)
+JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe* this, java_lang_reflect_Field* field)
 {
+       classinfo *c;
+       fieldinfo *f;
+
+       c = (classinfo *) field->clazz;
+       f = &c->fields[field->slot];
+
+       return (int64_t) f->offset;
 }
 
 
 /*
  * Class:     sun/misc/Unsafe
- * Method:    getLongVolatile
- * Signature: (Ljava/lang/Object;J)J
+ * Method:    allocateMemory
+ * Signature: (J)J
  */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2)
+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;
 }
 
 
 /*
  * Class:     sun/misc/Unsafe
- * Method:    getLong
- * Signature: (Ljava/lang/Object;J)J
+ * Method:    freeMemory
+ * Signature: (J)V
  */
-JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2)
+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:    putObjectVolatile
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ * Method:    staticFieldOffset
+ * Signature: (Ljava/lang/reflect/Field;)J
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, struct java_lang_Object* par3)
+JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *field)
 {
+       classinfo *c;
+       fieldinfo *f;
+
+       c = (classinfo *) field->clazz;
+       f = &(c->fields[field->slot]);
+
+       return (int64_t) (intptr_t) &(f->value);
 }
 
 
 /*
  * Class:     sun/misc/Unsafe
- * Method:    putObject
- * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V
+ * Method:    staticFieldBase
+ * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object;
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2, struct java_lang_Object* par3)
+JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *f)
 {
+       /* In CACAO we return the absolute address in staticFieldOffset. */
+
+       return NULL;
 }
 
 
 /*
  * Class:     sun/misc/Unsafe
- * Method:    getObjectVolatile
- * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
+ * Method:    ensureClassInitialized
+ * Signature: (Ljava/lang/Class;)V
  */
-JNIEXPORT struct java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Object* par1, int64_t par2)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *class)
 {
+       classinfo *c;
+
+       c = (classinfo *) class;
+
+       if (!(c->state & CLASS_INITIALIZED))
+               initialize_class(c);
 }
 
 
@@ -276,8 +420,21 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatil
  * Method:    arrayBaseOffset
  * Signature: (Ljava/lang/Class;)I
  */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
+JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *arrayClass)
 {
+       classinfo       *c;
+       arraydescriptor *ad;
+
+       c  = (classinfo *) arrayClass;
+       ad = c->vftbl->arraydesc;
+
+       if (ad == NULL) {
+               /* XXX does that exception exist? */
+               exceptions_throw_internalerror("java/lang/InvalidClassException");
+               return 0;
+       }
+
+       return ad->dataoffset;
 }
 
 
@@ -286,30 +443,162 @@ JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, stru
  * Method:    arrayIndexScale
  * Signature: (Ljava/lang/Class;)I
  */
-JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Class* par1)
+JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *arrayClass)
 {
+       classinfo       *c;
+       arraydescriptor *ad;
+
+       c  = (classinfo *) 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:    unpark
- * Signature: (Ljava/lang/Thread;)V
+ * Method:    addressSize
+ * Signature: ()I
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, struct sun_misc_Unsafe* this, struct java_lang_Thread* par1)
+JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, sun_misc_Unsafe *this)
 {
+       return SIZEOF_VOID_P;
 }
 
 
 /*
  * Class:     sun/misc/Unsafe
- * Method:    park
- * Signature: (ZJ)V
+ * Method:    throwException
+ * Signature: (Ljava/lang/Throwable;)V
  */
-JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, struct sun_misc_Unsafe* this, int32_t par1, int64_t par2)
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Throwable *ee)
 {
+       java_objectheader *o;
+
+       o = (java_objectheader *) 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)
+{
+       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;
+}
+
+
+/*
+ * 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* obj, int64_t offset, int32_t expect, int32_t update)
+{
+       int32_t *p;
+       int32_t  value;
+
+       p = (int32_t *) (((uint8_t *) obj) + offset);
+
+       /* XXX this should be atomic */
+
+       value = *p;
+
+       if (value == expect) {
+               *p = update;
+
+               return true;
+       }
+
+       return false;
+}
+
+
+/*
+ * 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:    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)
+{
+       volatile int32_t *p;
+       volatile int32_t  value;
+
+       p = (volatile int32_t *) (((uint8_t *) o) + offset);
+
+       value = *p;
+
+       return value;
 }
-#endif
 
 
 /*
index fe0c80ea7ae3bbc90e7e486bd67ca8f5b4f05a9b..69a122f568c68147bf960374c5fcabcfaa7134a9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: threads.c 8137 2007-06-22 16:41:36Z michi $
 
 */
 
@@ -955,7 +955,16 @@ bool threads_init(void)
 
        (void) vm_call_method(method_thread_init, o, vmt, threadname, NORM_PRIORITY,
                                                  false);
+
+#elif defined(WITH_CLASSPATH_SUN)
+
+       /* We trick java.lang.Thread.init, which sets the priority of the
+          current thread to the parent's one. */
+
+       t->priority = NORM_PRIORITY;
+
 #elif defined(WITH_CLASSPATH_CLDC1_1)
+
        /* set the thread */
 
        t->vm_thread = (java_lang_Object *) mainthread;
@@ -965,6 +974,8 @@ bool threads_init(void)
        o = (java_objectheader *) t;
 
        (void) vm_call_method(method_thread_init, o, threadname);
+#else
+# error unknown classpath configuration
 #endif
 
        if (exceptions_get_exception())
@@ -973,6 +984,7 @@ bool threads_init(void)
 #if defined(ENABLE_JAVASE)
        t->group = threadgroup;
 
+# if defined(WITH_CLASSPATH_GNU)
        /* add main thread to java.lang.ThreadGroup */
 
        m = class_resolveclassmethod(class_java_lang_ThreadGroup,
@@ -987,6 +999,9 @@ bool threads_init(void)
 
        if (exceptions_get_exception())
                return false;
+# else
+#  warning Do not know what to do here
+# endif
 #endif
 
        threads_set_thread_priority(pthread_self(), NORM_PRIORITY);
@@ -1125,9 +1140,11 @@ static void *threads_startup_thread(void *arg)
                   java.lang.VMThread. Since this is a final class, we can use
                   the class object directly. */
 
-               c   = class_java_lang_VMThread;
-#elif defined(WITH_CLASSPATH_CLDC1_1)
-               c   = thread->object->header.vftbl->class;
+               c = class_java_lang_VMThread;
+#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
+               c = thread->object->header.vftbl->class;
+#else
+# error unknown classpath configuration
 #endif
 
                m = class_resolveclassmethod(c, utf_run, utf_void__void, c, true);
@@ -1151,8 +1168,10 @@ static void *threads_startup_thread(void *arg)
                vmt = (java_lang_VMThread *) thread->object->vmThread;
                o   = (java_objectheader *) vmt;
 
-#elif defined(WITH_CLASSPATH_CLDC1_1)
+#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
                o   = (java_objectheader *) thread->object;
+#else
+# error unknown classpath configuration
 #endif
 
                /* run the thread */
@@ -1378,6 +1397,7 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
 #endif
 
 #if defined(WITH_CLASSPATH_GNU)
+
        /* create a java.lang.VMThread object */
 
        vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
@@ -1390,8 +1410,17 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
 
        vmt->thread = t;
        vmt->vmdata = (java_lang_Object *) thread;
+
+#elif defined(WITH_CLASSPATH_SUN)
+
+       vm_abort("threads_attach_current_thread: IMPLEMENT ME!");
+
 #elif defined(WITH_CLASSPATH_CLDC1_1)
+
        t->vm_thread = (java_lang_Object *) thread;
+
+#else
+# error unknown classpath configuration
 #endif
 
        if (vm_aargs != NULL) {
@@ -1478,11 +1507,21 @@ bool threads_detach_thread(threadobject *thread)
        /* XXX TWISTI: should all threads be in a ThreadGroup? */
 
        if (group != NULL) {
+# if defined(WITH_CLASSPATH_GNU)
                m = class_resolveclassmethod(group->header.vftbl->class,
                                                                         utf_removeThread,
                                                                         utf_java_lang_Thread__V,
                                                                         class_java_lang_ThreadGroup,
                                                                         true);
+# elif defined(WITH_CLASSPATH_SUN)
+               m = class_resolveclassmethod(group->header.vftbl->class,
+                                                                        utf_remove,
+                                                                        utf_java_lang_Thread__V,
+                                                                        class_java_lang_ThreadGroup,
+                                                                        true);
+# else
+#  error unknown classpath configuration
+# endif
 
                if (m == NULL)
                        return false;
index ce7d159ec44f4de530a23dbbadccee935266be51..5a0b8da5cabe26c53b70a00a4ddf4c6f6bb8164e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: threads-common.c 8137 2007-06-22 16:41:36Z michi $
 
 */
 
@@ -528,12 +528,14 @@ void threads_thread_print_info(threadobject *t)
        if (object != NULL) {
                /* get thread name */
 
-#if defined(ENABLE_JAVASE)
+#if defined(WITH_CLASSPATH_GNU)
                name = javastring_toutf((java_objectheader *) object->name, false);
-#elif defined(ENABLE_JAVAME_CLDC1_1)
+#elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
                /* FIXME: In cldc the name is a char[] */
 /*             name = object->name; */
                name = utf_null;
+#else
+# error unknown classpath configuration
 #endif
 
                printf("\"");
index bd7674707f20e56606152f2bbac1e7bf2106f143..8e1d70d1f14cb083faaf8c7e056ee4af67f36089 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: arch.h 7701 2007-04-15 00:38:00Z michi $
+   $Id: arch.h 8127 2007-06-21 11:55:56Z michi $
 
 */
 
 #endif
 
 
-#define HAS_4BYTE_STACKSLOT
 #define SUPPORT_COMBINE_INTEGER_REGISTERS
 #define SUPPORT_PASS_FLOATARGS_IN_INTREGS
 
-#define ALIGN_LONGS_IN_MEMORY       /* Align Longs and/or Doubles at          */
-#define ALIGN_DOUBLES_IN_MEMORY     /* 2*Stackslotsize relativ to stackframe  */
-/* Memory Positions for not Interface Stackslots (allocate_scratch_registers) */
-/* are not properly aligned in case HAS_4_BYTE_STACKSLOT is not defined!      */
-/* For HAS_4_BYTE_STACKSLOT archs no distinction is made between long and     */
-/* define SUPPORT_COMBINE_INTEGER_REGISTERS                                   */
-
 
 /* branches *******************************************************************/
 
index 5f2c9289af49ed51ae4bac7b203d37b300f0f4e0..99e16a9f3ea7ead2887203a86e5a1eebc3b8f97e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.S 7940 2007-05-23 09:42:08Z michi $
+   $Id: asmpart.S 8127 2007-06-21 11:55:56Z michi $
 
 */
 
@@ -70,9 +70,6 @@ asm_exceptionptr:
        .word _no_threads_exceptionptr
 #endif
 
-asm_jitcompilerptr:
-       .word asm_call_jit_compiler
-
 asm_criticalsections:
 #if defined(ENABLE_THREADS)
        .word _crit_begin
@@ -114,77 +111,45 @@ asm_vm_call_method_long:
 /* 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 recompute SP ...   */
-       mov   v1, #0                      /* ... when using stack arguments   */
-       ldr   ip, asm_jitcompilerptr
-       str   ip, [sp, #-4]!              /* store fake address               */
-       mov   mptr, sp                    /* set method pointer               */
+       stmfd sp!, {v1}                   /* V1 is used to remember SP        */
+       str   a0, [sp, #-4]!              /* store methods entrypoint         */
 
-       mov   itmp1, a0                   /* pass methodinfo* via ITMP1       */
+       mov   v1, sp                      /* remember SP                      */
 
-       cmp   a1, #0                      /* do we have arguments?            */
-       ble   asm_calljava_copyfinish     /* no -> do not care :-)            */
+       mov   itmp1, a1                   /* address of data structure        */
+       mov   itmp3, a2                   /* stack argument count             */
 
-       /* REMEMBER: stack space for arguments is reserved here! */
-       /* TODO: we possibly reserve to much here */
-       mov   v1, a1, lsl #3              /* how much stack do we alloc?      */
-       sub   sp, sp, v1                  /* allocate stack for arguments!    */
+       ldr   a0, [itmp1], #8             /* load argument registers          */
+       ldr   a1, [itmp1], #8
+       ldr   a2, [itmp1], #8
+       ldr   a3, [itmp1], #8
+
+       cmp   itmp3, #0                   /* do we have stack arguments?      */
+       ble   asm_calljava_copyfinish     /* no -> do not care :-)            */
 
-       mov   itmp3, #0                   /* stack position                   */
+       mov   itmp2, #0
+       sub   sp, sp, itmp3, lsl #3       /* create stackframe for arguments  */
 asm_calljava_copyloop:                /* reorder stack arguments!         */
-#if defined(__ARMEL__)
-       ldr   ip, [a2,#offvmargtype]      /* align 2_WORD_TYPEs               */
-       tst   ip, #1
-       tstne itmp3, #4
-       addne itmp3, itmp3, #4
-       ldr   ip, [a2,#offvmargdata]      /* get LOW word of argument         */
-       str   ip, [sp, itmp3]
-       add   itmp3, itmp3, #4
-       ldr   ip, [a2,#offvmargtype]      /* is it a 2_WORD_TYPE?             */
-       tst   ip, #1
-       ldrne ip, [a2,#offvmargdata + 4]  /* yes -> get HIGH word of argument */
-       strne ip, [sp, itmp3]
-       addne itmp3, itmp3, #4
-#else /* defined(__ARMEB__) */
-       ldr   ip, [a2,#offvmargtype + 4]  /* get our item type (it is u8)    */
-       tst   ip, #1                      /* align 2_WORD_TYPEs               */
-       tstne itmp3, #4
-       addne itmp3, itmp3, #4
-       teq   ip, #2                      /* is it a TYPE_FLOAT?              */
-       ldreq ip, [a2,#offvmargdata]      /* yes -> get LOW word of float     */
-       streq ip, [sp, itmp3]
-       addeq itmp3, itmp3, #4
-       beq   asm_calljava_copydone
-       tst   ip, #1                      /* is it a 2_WORD_TYPE?             */
-       ldrne ip, [a2,#offvmargdata]      /* yes -> get HIGH word of argument */
-       strne ip, [sp, itmp3]
-       addne itmp3, itmp3, #4
-       ldr   ip, [a2,#offvmargdata + 4]  /* get LOW word of argument         */
-       str   ip, [sp, itmp3]
-       add   itmp3, itmp3, #4
-asm_calljava_copydone:
-#endif
-       add   a2, a2, #sizevmarg          /* next argument block              */
-       subs  a1, a1, #1
+       ldr   ip, [itmp1], #4             /* load argument                    */
+       str   ip, [sp, itmp2]             /* store argument on stack          */
+       add   itmp2, itmp2, #4            /* next stackslot                   */
+       ldr   ip, [itmp1], #4             /* load argument                    */
+       str   ip, [sp, itmp2]             /* store argument on stack          */
+       add   itmp2, itmp2, #4            /* next stackslot                   */
+       subs  itmp3, itmp3, #1            /* next argument                    */
        bgt   asm_calljava_copyloop
 
-       /* REMEMBER: first four args are passed in regs, take them out again  */
-       ldmfd sp, {a0, a1, a2, a3}        /* load first four args to register */
-       cmp   v1, #16                     /* do we have four arguments?       */
-       addlt sp, sp, v1
-       movlt v1, #0
-       addge sp, sp, #16
-       subge v1, v1, #16
-
 asm_calljava_copyfinish:
+       mov   mptr, v1                    /* set method pointer               */
+
        /* REMEMBER: do the method call just like in java! */
        ldr   ip, [mptr]                  /* fake virtual function call       */
-       mov   lr, pc 
-       mov   pc, ip 
-fake2:
-       sub   ip, pc, #(fake2 - asm_vm_call_method)+8
+       mov   lr, pc
+       mov   pc, ip
+fake:
+       sub   ip, pc, #(fake - asm_vm_call_method)+8
 
-       add   sp, sp, v1                  /* free stack arguments!            */
+       mov   sp, v1                      /* restore SP                       */
        add   sp, sp, #4                  /* free fake address                */
        ldmfd sp!, {v1}
        RESTORE_SCRATCH_REGS_AND_RETURN   /* return to caller, restore regs   */
@@ -194,7 +159,7 @@ asm_vm_call_method_exception_handler:
        bl    builtin_throw_exception     /* throw the exception              */
        mov   res1, #0                    /* return NULL                      */
        mov   res2, #0                    /* return NULL                      */
-       add   sp, sp, v1                  /* free stack arguments!            */
+       mov   sp, v1                      /* restore SP                       */
        add   sp, sp, #4                  /* free fake address                */
        ldmfd sp!, {v1}
        RESTORE_SCRATCH_REGS_AND_RETURN   /* return to caller, restore regs   */
index 9de8ea042e5c7ed0683e1bd196cd61816774e375..7b9c15d1f560ca1e1c7e681805b48a27a67e2296 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: codegen.c 8127 2007-06-21 11:55:56Z michi $
 
 */
 
@@ -120,7 +120,8 @@ bool codegen_emit(jitdata *jd)
 
        savedregs_num = (jd->isleafmethod) ? 0 : 1;       /* space to save the LR */
        savedregs_num += (INT_SAV_CNT - rd->savintreguse);
-       savedregs_num += (FLT_SAV_CNT - rd->savfltreguse);
+       /*savedregs_num += (FLT_SAV_CNT - rd->savfltreguse);*/
+       assert((FLT_SAV_CNT - rd->savfltreguse) == 0);
 
        spilledregs_num = rd->memuse;
 
@@ -129,7 +130,7 @@ bool codegen_emit(jitdata *jd)
                spilledregs_num++;
 #endif
 
-       cd->stackframesize = (spilledregs_num + savedregs_num) * 4;
+       cd->stackframesize = spilledregs_num * 8 + savedregs_num * 4;
 
        /* XXX QUICK FIX: We shouldn't align the stack in Java code, but
           only in native stubs. */
@@ -151,7 +152,7 @@ bool codegen_emit(jitdata *jd)
        */
 
        if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 4);/* IsSync         */
+               (void) dseg_add_unique_s4(cd, rd->memuse * 8 + 4);/* IsSync         */
        else
 #endif
                (void) dseg_add_unique_s4(cd, 0);                  /* IsSync          */
@@ -278,12 +279,12 @@ bool codegen_emit(jitdata *jd)
        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                /* stack offset for monitor argument */
 
-               s1 = rd->memuse;
+               s1 = rd->memuse * 8;
 
 # if !defined(NDEBUG)
                if (JITDATA_HAS_FLAG_VERBOSECALL(jd)) {
                        M_STMFD(BITMASK_ARGS, REG_SP);
-                       s1 += 4;
+                       s1 += 4 * 4;
                }
 # endif
 
@@ -297,7 +298,7 @@ bool codegen_emit(jitdata *jd)
                        emit_nullpointer_check_force(cd, iptr, REG_A0);
                }
 
-               M_STR(REG_A0, REG_SP, s1 * 4);
+               M_STR(REG_A0, REG_SP, s1);
                disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
                M_DSEG_BRANCH(disp);
                s1 = (s4) (cd->mcodeptr - cd->mcodebase);
@@ -2121,7 +2122,7 @@ bool codegen_emit(jitdata *jd)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                                /* stack offset for monitor argument */
 
-                               s1 = rd->memuse;
+                               s1 = rd->memuse * 8;
 
                                /* we need to save the proper return value */
 
@@ -2132,11 +2133,11 @@ bool codegen_emit(jitdata *jd)
                                case ICMD_FRETURN: /* XXX TWISTI: is that correct? */
                                case ICMD_DRETURN:
                                        M_STMFD(BITMASK_RESULT, REG_SP);
-                                       s1 += 2;
+                                       s1 += 2 * 4;
                                        break;
                                }
 
-                               M_LDR(REG_A0, REG_SP, s1 * 4);
+                               M_LDR(REG_A0, REG_SP, s1);
                                disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
                                M_DSEG_BRANCH(disp);
 
@@ -2925,12 +2926,11 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* calculate stackframe size */
 
-       cd->stackframesize = ( 
-               1 +                                                /* return address  */
-               sizeof(stackframeinfo) / SIZEOF_VOID_P +           /* stackframeinfo  */
-               sizeof(localref_table) / SIZEOF_VOID_P +           /* localref_table  */
-               nmd->memuse                                        /* stack arguments */
-               ) * 4;
+       cd->stackframesize =
+               4 +                                                /* return address  */
+               sizeof(stackframeinfo) +                           /* stackframeinfo  */
+               sizeof(localref_table) +                           /* localref_table  */
+               nmd->memuse * 4;                                   /* stack arguments */
 
        /* align stack to 8-byte */
 
index 3f59b7b0b15f2b759fd2f105dbb17c30c0295ab6..0abca2ad64b8f80f23ec256dfe1b3fd576cbe80b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-abi.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: md-abi.c 8127 2007-06-21 11:55:56Z michi $
 
 */
 
@@ -150,12 +150,14 @@ void md_param_alloc(methoddesc *md)
                case TYPE_FLT:
                        if (reguse < INT_ARG_CNT) {
                                pd->inmemory = false;
+                               pd->index    = reguse;
                                pd->regoff   = abi_registers_integer_argument[reguse];
                                reguse++;
                        }
                        else {
                                pd->inmemory = true;
-                               pd->regoff   = stacksize * 4;
+                               pd->index    = stacksize;
+                               pd->regoff   = stacksize * 8;
                                stacksize++;
                        }
                        break;
@@ -169,10 +171,12 @@ void md_param_alloc(methoddesc *md)
                        if (reguse < INT_ARG_CNT) {
                                pd->inmemory = false;
 #if defined(__ARMEL__)
+                               pd->index    = PACK_REGS(reguse, reguse + 1);
                                pd->regoff   =
                                        PACK_REGS(abi_registers_integer_argument[reguse],
                                                          abi_registers_integer_argument[reguse + 1]);
 #else
+                               pd->index    = PACK_REGS(reguse + 1, reguse);
                                pd->regoff   =
                                        PACK_REGS(abi_registers_integer_argument[reguse + 1],
                                                          abi_registers_integer_argument[reguse]);
@@ -181,11 +185,13 @@ void md_param_alloc(methoddesc *md)
                        }
                        else {
 
-                               ALIGN_2(stacksize);
+                               /*ALIGN_2(stacksize);*/
 
                                pd->inmemory  = true;
-                               pd->regoff    = stacksize * 4;
-                               stacksize    += 2;
+                               pd->index     = stacksize;
+                               pd->regoff    = stacksize * 8;
+                               /*stacksize    += 2;*/
+                               stacksize++;
                        }
                        break;
                }
@@ -242,11 +248,13 @@ void md_param_alloc_native(methoddesc *md)
                case TYPE_FLT:
                        if (reguse < INT_ARG_CNT) {
                                pd->inmemory = false;
+                               pd->index    = -1;
                                pd->regoff   = abi_registers_integer_argument[reguse];
                                reguse++;
                        }
                        else {
                                pd->inmemory = true;
+                               pd->index    = -1;
                                pd->regoff   = stacksize * 4;
                                stacksize++;
                        }
@@ -260,10 +268,12 @@ void md_param_alloc_native(methoddesc *md)
 #endif
                                pd->inmemory = false;
 #if defined(__ARMEL__)
+                               pd->index    = -1;
                                pd->regoff   =
                                        PACK_REGS(abi_registers_integer_argument[reguse],
                                                          abi_registers_integer_argument[reguse + 1]);
 #else
+                               pd->index    = -1;
                                pd->regoff   =
                                        PACK_REGS(abi_registers_integer_argument[reguse + 1],
                                                          abi_registers_integer_argument[reguse]);
@@ -274,10 +284,12 @@ void md_param_alloc_native(methoddesc *md)
                        else if (reguse < INT_ARG_CNT) {
                                pd->inmemory = false;
 # if defined(__ARMEL__)
+                               pd->index    = -1;
                                pd->regoff   =
                                        PACK_REGS(abi_registers_integer_argument[reguse],
                                                          abi_registers_integer_argument[INT_ARG_CNT]);
 # else
+                               pd->index    = -1;
                                pd->regoff   =
                                        PACK_REGS(abi_registers_integer_argument[INT_ARG_CNT],
                                                          abi_registers_integer_argument[reguse]);
@@ -291,6 +303,7 @@ void md_param_alloc_native(methoddesc *md)
                                ALIGN_2(stacksize);
 #endif
                                pd->inmemory  = true;
+                               pd->index     = -1;
                                pd->regoff    = stacksize * 4;
                                reguse        = INT_ARG_CNT;
                                stacksize    += 2;
index 013006f717117eeea906cc83f8c0e9b05c9169e4..5628823bf8eba1b734c71f81b1e23c635bc8b25c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.h 8123 2007-06-20 23:50:55Z michi $
+   $Id: asmpart.h 8128 2007-06-21 16:29:53Z tbfg $
 
 */
 
@@ -89,7 +89,7 @@ s4   asm_md_init(void);
 void asm_call_jit_compiler(void);
 
 #if defined(ENABLE_JIT)
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__)
 java_objectheader *asm_vm_call_method(methodinfo *m, s4 vmargscount,
                                                                          vm_arg *vmargs);
 s4     asm_vm_call_method_int(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
index ac83bb6a9bc606254e7e799fa3dd693dec777483..46bb58dcb5ee92d94af1370cc8c0b0b9f44a638d 100644 (file)
@@ -94,8 +94,6 @@
 
 #define HAS_ADDRESS_REGISTER_FILE        1
 
-#define HAS_4BYTE_STACKSLOT            1
-
 /* coldfire has tst instruction */
 #define SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER       1
 #define SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS     1
index c963ae599b70e43444d44a41edf4e6a5c83ff471..3fcecee8247c4ecfc9e26c6434da2abcac3c2b11 100644 (file)
@@ -9,10 +9,6 @@
 #include "md-abi.h"
 #include "vm/jit/methodheader.h"
 
-.data
-call_jit_dummy:
-       .long 0xdeadbeef
-
 .text
 
 .globl asm_vm_call_method
@@ -59,6 +55,16 @@ call_jit_dummy:
        .long   0                           /* IsSync                             */
        .long   0                           /* frame size                         */
        .long   0                           /* codeinfo pointer                   */
+
+
+/*
+       This method gets called with 3 arguments:
+       1st arg: addres of method to call (fake invokevirtual here)
+       2nd arg: uint64_t array of argument registers followed by stack 
+       3rd arg: number of 8 byte stack slots to be copied.
+
+       coldifire does not use any argument registers, so just the stack has to be copied
+*/
 asm_vm_call_method:
 asm_vm_call_method_int:
 asm_vm_call_method_long:
@@ -66,66 +72,59 @@ asm_vm_call_method_float:
 asm_vm_call_method_double:
 
 #if defined(ENABLE_SOFTFLOAT)
-       addal   #(-11*4),%sp                                            /* create stackframe to save registers */
+       addal   #(-12*4),%sp                                            /* create stackframe to save registers, and 1 slot for method invocation */
        moveml  %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp,%sp@        /* save registers */
 
        /* fetch arguments from vmargs data structure */
-       movel   %sp@(11*4+1*4),%a2                              /* methodinfo argument in atmp1 */
-       movel   %sp@(11*4+3*4),%a3                              /* args block */
-       movel   %sp@(11*4+2*4),%d2                              /* arg count */
+       movel   %sp@(12*4+1*4),%a3                              /* method */
+       movel   %sp@(12*4+2*4),%a2                              /* arg array */
+       movel   %sp@(12*4+3*4),%d2                              /* arg count */
+
+       movel   %a3, %sp@(12*4)                                 /* copy method address to stackslot */
+       leal    %sp@(12*4), %a3                                 /* and store that address in %a3 */
 #else
-       addal #(-11*4-6*8), %sp
+       addal #(-12*4-6*8), %sp
        moveml  %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp,%sp@        /* save registers */
        fmovemd %fp2/%fp3/%fp4/%fp5/%fp6/%fp7,%sp@(11*4)                        /* save registers */
 
        /* fetch arguments from vmargs data structure */
-       movel   %sp@(11*4+6*8+1*4),%a2                          /* methodinfo argument in atmp1 */
-       movel   %sp@(11*4+6*8+3*4),%a3                          /* args block */
-       movel   %sp@(11*4+6*8+2*4),%d2                          /* arg count */
-#endif
+       movel   %sp@(12*4+6*8+1*4),%a3                          /* method */
+       movel   %sp@(12*4+6*8+2*4),%a2                          /* arg array */
+       movel   %sp@(12*4+6*8+3*4),%d2                          /* arg count */
 
+       movel   %a3, %sp@(11*4+6*8)                                     /* copy method address to stackslot */
+       leal    %sp@(11*4+6*8), %a3                                     /* and store that address in %a3 */
+#endif
 
        moveal  %sp, %a5                                        /* memorize stack */
+
        tstl    %d2                                                     /* do we have arguments ? */
        beq     L_asm_vm_call_method_copy_done
-       subql   #1,%d2                                          /* simplifies offset calulation */
-
-       movel   #(sizevmarg), %d0
-       mulsl   %d2, %d0                                        
-       moveal  %a3, %a0
-       addal   %d0, %a0                                        /* %a0 points to last vmarg block */
-
-       addql   #1, %d2
-L_asm_vm_call_copy_arg:
-       subql   #1, %d2                                         /* decrement argument counter */
-       movel   %a0@(offvmargtype+4), %d1       /* %d1 contains type of arg, vmargtype is u8 */ 
-
-       cmpil   #2, %d1                                         /* float type ? */
-       bne             L_asm_vm_call_copy_int
-
-       movel   %a0@(offvmargdata), %d0         /* float has different endianess as int */
-       movel   %d0, %sp@-
-       bra             L_asm_vm_call_copy_1_word_type
-
-L_asm_vm_call_copy_int:
-       movel   %a0@(offvmargdata+4), %d0
-       movel   %d0,%sp@-                                       /* push argument onto stack */
-
-       btstl   #0, %d1                                         /* test if 2 word type */
-       beq     L_asm_vm_call_copy_1_word_type
-       movel   %a0@(offvmargdata), %d0         /* push second word onto stack */
-       movel   %d0,%sp@-
-L_asm_vm_call_copy_1_word_type:
+       movel   %d2, %d3                                                /* create stackframe */
+       asll    #3,  %d3                                                /* number args * 8 */
+       subal   %d3, %sp                        
+       moveal  %sp, %a4                                                /* %a4 is temp stack pointer */
+
+L_asm_vm_call_method_copy_loop:
+       movel   %a2@(0), %d3
+       movel   %d3, %a4@(0)                                    /* copy 4 bytes */
+       movel   %a2@(4), %d3
+       movel   %d3, %a4@(4)                                    /* a whole stack slot has been copied */
+
+       addal   #8, %a2
+       addal   #8, %a4
+       addl    #-1, %d2
+       tstl    %d2                                                             /* do we have more arguments ? */
+       beq     L_asm_vm_call_method_copy_done
+       br      L_asm_vm_call_method_copy_loop
 
-       subl    #(sizevmarg),%a0
-       tstl    %d2                                                     /* arguments left ? */
-       bne     L_asm_vm_call_copy_arg
 
 L_asm_vm_call_method_copy_done:
+       /* now we fake method invocation as it would happen from invokevirtual */
+       /* this is needed as we patch the caller site, so we need a writeable slot */
+       /* %a3 points to the address containing the method, %a3 == REG_METHODPTR */
 
-       leal    asm_call_jit_compiler,%a4                       /* we need to fake a invocation as it would happen from jit code */
-       movel   %a4, call_jit_dummy                                     /* we need a writeable memory location */
-       moveal  call_jit_dummy, %a4                                     /* XXX do we have a race condition here ? */
+       moveal  %a3@(0), %a4
        jsr     %a4@
 
 L_asm_vm_call_method_return:
@@ -133,11 +132,11 @@ L_asm_vm_call_method_return:
 
 #if defined(ENABLE_SOFTFLOAT)
        moveml  %sp@, %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp       /* restore registers */
-       addal   #(11*4),%sp                                             /* restore stack */
+       addal   #(12*4),%sp                                             /* restore stack */
 #else
-       fmovemd %sp@(11*4), %fp2/%fp3/%fp4/%fp5/%fp6/%fp7                       /* restore registers */
+       fmovemd %sp@(12*4), %fp2/%fp3/%fp4/%fp5/%fp6/%fp7                       /* restore registers */
        moveml  %sp@, %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp       /* restore registers */
-       addal   #(11*4+6*8),%sp                                         /* restore stack */
+       addal   #(12*4+6*8),%sp                                         /* restore stack */
 #endif
        moveal  %d0, %a0                                                /* XXX return value in %a0, too, gcc sometimes expects addresses in %a0, wired */
 asm_vm_call_method_end:                                                /* symbol needed to insert method into avl tree */
@@ -417,6 +416,11 @@ L_asm_handle_ex_int_done:
        lsrl    #8, %d0
        lsrl    #8, %d0
 
+#if 0
+       cmpb    #0, %d0
+       beq     L_asm_handle_ex_adr_done
+       moveal  -(%a0), %a5
+#else
        cmpb    #0, %d0
        beq     L_asm_handle_ex_adr_done
        moveal  -(%a0), %fp
@@ -424,6 +428,7 @@ L_asm_handle_ex_int_done:
        cmpb    #1,%d0
        beq     L_asm_handle_ex_adr_done
        moveal  -(%a0), %a5
+#endif
 
 L_asm_handle_ex_adr_done:
 
index 08c3b84da775a08096a90d14c39eb67f551a6fab..ce93ddc2fb4eab431bc39fc6ae37e954a2baf3ea 100644 (file)
@@ -110,17 +110,19 @@ bool codegen_emit(jitdata *jd)
 
                savedregs_num += (INT_SAV_CNT - rd->savintreguse);
                savedregs_num += (ADR_SAV_CNT - rd->savadrreguse);
-               savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2;
+               savedregs_num += (FLT_SAV_CNT - rd->savfltreguse);
 
                cd->stackframesize = rd->memuse + savedregs_num;
        
-               /* we always add 3 words, 
-                * 1 word the lock word, which may be unused and resides @ rd->memuse * 4
-                * + 2 words to either save the return value for LOCK_monitor_exit @ rd->memuse * 4 + 4
+               /* we always add 2 stack slots.
+                * 1 word the lock word, which may be unused and resides @ rd->memuse * 8
+                * + 2 words to either save the return value for LOCK_monitor_exit @ rd->memuse * 8 + 8
                 * on the other hand we could use 2 words when a builtin returns a doulbe which are
                 * returned in %d0, %d1 and need to be stored onto the stack and read in used a fmovemd
-                * so we always _need_ at least 2 words, and this keeps the code simple */
-               cd->stackframesize += 3;        
+                * so we always _need_ at least 2 slots, and this keeps the code simple */
+               cd->stackframesize += 2;        
+
+               cd->stackframesize *= 8;        /* we use 8 byte stack slots */
 
 #if 0
 #if defined(ENABLE_THREADS)
@@ -137,10 +139,10 @@ bool codegen_emit(jitdata *jd)
        
                /* create method header */
                (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
-               (void) dseg_add_unique_s4(cd, cd->stackframesize * 4); /* FrameSize       */
+               (void) dseg_add_unique_s4(cd, cd->stackframesize);         /* FrameSize       */
 #if defined(ENABLE_THREADS)
                if (checksync && (m->flags & ACC_SYNCHRONIZED))
-                       (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 4);/* IsSync         */
+                       (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 8);/* IsSync         */
                else
 #endif
                (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
@@ -170,19 +172,19 @@ bool codegen_emit(jitdata *jd)
                emit_verbosecall_enter(jd);
 #endif
                /* create stack frame */
-               M_AADD_IMM(-(cd->stackframesize*4), REG_SP);
+               M_AADD_IMM(-(cd->stackframesize), REG_SP);
 
                /* save used callee saved registers */
                p = cd->stackframesize;
                for (i=INT_SAV_CNT-1; i>=rd->savintreguse; --i) {
-                       p--; M_IST(rd->savintregs[i], REG_SP, p*4);
+                       p-=8; M_IST(rd->savintregs[i], REG_SP, p);
                }
                for (i=ADR_SAV_CNT-1; i>=rd->savadrreguse; --i) {
-                       p--; M_AST(rd->savadrregs[i], REG_SP, p*4);
+                       p-=8; M_AST(rd->savadrregs[i], REG_SP, p);
                }
 #if !defined(ENABLE_SOFTFLOAT)
                for (i=FLT_SAV_CNT-1; i>=rd->savfltreguse; --i) {
-                       p-=2; M_FSTORE(rd->savfltregs[i], REG_SP, p*4);
+                       p-=8; M_FSTORE(rd->savfltregs[i], REG_SP, p);
                }       
 #else
                assert(FLT_SAV_CNT == 0);
@@ -215,22 +217,17 @@ bool codegen_emit(jitdata *jd)
                        case TYPE_INT:
                                if (!IS_INMEMORY(var->flags)) {      /* stack arg -> register */
                                        if (IS_2_WORD_TYPE(t))  {
-                                               M_LLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                               M_LLD(var->vv.regoff, REG_SP, cd->stackframesize + s1 + 4);
                                        } else {
-                                               M_ILD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                               M_ILD(var->vv.regoff, REG_SP, cd->stackframesize + s1 + 4);
                                        }
                                } else {                             /* stack arg -> spilled  */
-#if 1
-                                       M_ILD(REG_ITMP1, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                       M_ILD(REG_ITMP1, REG_SP, cd->stackframesize + s1 + 4);
                                        M_IST(REG_ITMP1, REG_SP, var->vv.regoff);
                                        if (IS_2_WORD_TYPE(t)) {
-                                               M_ILD(REG_ITMP1, REG_SP, cd->stackframesize * 4 + s1 + 4 + 4);
+                                               M_ILD(REG_ITMP1, REG_SP, cd->stackframesize  + s1 + 4 + 4);
                                                M_IST(REG_ITMP1, REG_SP, var->vv.regoff + 4);
                                        }
-#else
-                                       /* Reuse Memory Position on Caller Stack */
-                                       var->vv.regoff = cd->stackframesize * 4 + s1;
-#endif
                                } 
                                break;
 #if !defined(ENABLE_SOFTFLOAT)
@@ -238,37 +235,27 @@ bool codegen_emit(jitdata *jd)
                        case TYPE_DBL:
                                if (!IS_INMEMORY(var->flags)) {      /* stack-arg -> register */
                                        if (IS_2_WORD_TYPE(t))  {
-                                               M_DLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                               M_DLD(var->vv.regoff, REG_SP, cd->stackframesize + s1 + 4);
                                        } else {
-                                               M_FLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                               M_FLD(var->vv.regoff, REG_SP, cd->stackframesize + s1 + 4);
                                        }
                                } else {                             /* stack-arg -> spilled  */
-#if 1
                                        if (IS_2_WORD_TYPE(t)) {
-                                               M_DLD(REG_FTMP1, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                               M_DLD(REG_FTMP1, REG_SP, cd->stackframesize + s1 + 4);
                                                M_DST(REG_FTMP1, REG_SP, var->vv.regoff);
                                        } else {
-                                               M_FLD(REG_FTMP1, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                               M_FLD(REG_FTMP1, REG_SP, cd->stackframesize + s1 + 4);
                                                M_FST(REG_FTMP1, REG_SP, var->vv.regoff);
                                        }
-#else
-                                       /* Reuse Memory Position on Caller Stack */
-                                       var->vv.regoff = cd->stackframesize * 4 + s1;
-#endif
                                }
                                break;
 #endif /* SOFTFLOAT */
                        case TYPE_ADR:
                                if (!IS_INMEMORY(var->flags)) {      /* stack-arg -> register */
-                                       M_ALD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                       M_ALD(var->vv.regoff, REG_SP, cd->stackframesize + s1 + 4);
                                } else {                             /* stack-arg -> spilled  */
-#if 1
-                                       M_ALD(REG_ATMP1, REG_SP, cd->stackframesize * 4 + s1 + 4);
+                                       M_ALD(REG_ATMP1, REG_SP, cd->stackframesize + s1 + 4);
                                        M_AST(REG_ATMP1, REG_SP, var->vv.regoff);
-#else
-                               /* Reuse Memory Position on Caller Stack */
-                               var->vv.regoff = cd->stackframesize * 4 + s1;
-#endif
                                }
                                break;
                        default: assert(0);
@@ -282,13 +269,13 @@ bool codegen_emit(jitdata *jd)
                        M_AMOV_IMM((&m->class->object.header), REG_ATMP1);
                } else  {
                        /* for non-static case the first arg is the object */
-                       M_ALD(REG_ATMP1, REG_SP, cd->stackframesize*4 + 4);
+                       M_ALD(REG_ATMP1, REG_SP, cd->stackframesize + 4);
                        M_ATST(REG_ATMP1);
                        M_BNE(2);
                        M_TRAP(M68K_EXCEPTION_HARDWARE_NULLPOINTER);
                }
 
-               M_AST(REG_ATMP1, REG_SP, rd->memuse * 4);
+               M_AST(REG_ATMP1, REG_SP, rd->memuse * 8);
                M_AST(REG_ATMP1, REG_SP, 0 * 4);
                M_JSR_IMM(LOCK_monitor_enter);
        }
@@ -1891,7 +1878,7 @@ nowperformreturn:
 #if defined(ENABLE_THREADS)
                        /* call lock_monitor_exit */
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
-                               M_ILD(REG_ITMP3, REG_SP, rd->memuse * 4);
+                               M_ILD(REG_ITMP3, REG_SP, rd->memuse * 8);
 
                                /* we need to save the proper return value */
                                /* we do not care for the long -> doubel convert space here */
@@ -1900,21 +1887,21 @@ nowperformreturn:
                                case ICMD_DRETURN:
 #endif
                                case ICMD_LRETURN:
-                                       M_LST(REG_RESULT_PACKED, REG_SP, rd->memuse * 4 + 4);
+                                       M_LST(REG_RESULT_PACKED, REG_SP, rd->memuse * 8 + 8);
                                        break;
 #if defined(ENABLE_SOFTFLOAT)
                                case ICMD_FRETURN:
 #endif
                                case ICMD_IRETURN:
                                case ICMD_ARETURN:
-                                       M_IST(REG_RESULT , REG_SP, rd->memuse * 4 + 4);
+                                       M_IST(REG_RESULT , REG_SP, rd->memuse * 8 + 8);
                                        break;
 #if !defined(ENABLE_SOFTFLOAT)
                                case ICMD_FRETURN:
-                                       M_FST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
+                                       M_FST(REG_FRESULT, REG_SP, rd->memuse * 8 + 8);
                                        break;
                                case ICMD_DRETURN:
-                                       M_DST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
+                                       M_DST(REG_FRESULT, REG_SP, rd->memuse * 8 + 8);
                                        break;
 #endif
                                }
@@ -1929,21 +1916,21 @@ nowperformreturn:
                                case ICMD_DRETURN:
 #endif
                                case ICMD_LRETURN:
-                                       M_LLD(REG_RESULT_PACKED, REG_SP, rd->memuse * 4 + 4);
+                                       M_LLD(REG_RESULT_PACKED, REG_SP, rd->memuse * 8 + 8);
                                        break;
 #if defined(ENABLE_SOFTFLOAT)
                                case ICMD_FRETURN:
 #endif
                                case ICMD_IRETURN:
                                case ICMD_ARETURN:
-                                       M_ILD(REG_RESULT , REG_SP, rd->memuse * 4 + 4);
+                                       M_ILD(REG_RESULT , REG_SP, rd->memuse * 8 + 8);
                                        break;
 #if !defined(ENABLE_SOFTFLOAT)
                                case ICMD_FRETURN:
-                                       M_FLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
+                                       M_FLD(REG_FRESULT, REG_SP, rd->memuse * 8 + 8);
                                        break;
                                case ICMD_DRETURN:
-                                       M_DLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
+                                       M_DLD(REG_FRESULT, REG_SP, rd->memuse * 8 + 8);
                                        break;
 #endif
                                }
@@ -1964,18 +1951,18 @@ nowperformreturn:
                        /* restore saved registers                                        */
 
                        for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) {
-                               p--; M_ILD(rd->savintregs[i], REG_SP, p * 4);
+                               p-=8; M_ILD(rd->savintregs[i], REG_SP, p);
                        }
                        for (i=ADR_SAV_CNT-1; i>=rd->savadrreguse; --i) {
-                               p--; M_ALD(rd->savadrregs[i], REG_SP, p*4);
+                               p-=8; M_ALD(rd->savadrregs[i], REG_SP, p);
                        }
 #if !defined(ENABLE_SOFTFLOAT)
                        for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) {
-                               p -= 2; M_FLOAD(rd->savfltregs[i], REG_SP, p * 4);
+                               p-=8; M_FLOAD(rd->savfltregs[i], REG_SP, p);
                        }
 #endif
                        /* deallocate stack                                               */
-                       M_AADD_IMM(cd->stackframesize*4, REG_SP);
+                       M_AADD_IMM(cd->stackframesize, REG_SP);
                        M_RET;
                        }
                        break;
index 7da510fb5206c5606455f00dc1d70d18b2f46d42..dff441f7f67b06197d95447163667ae8463b1725 100644 (file)
@@ -597,10 +597,7 @@ void emit_verbosecall_enter(jitdata* jd)
 
        /* travel up stack to the first argument of the function which needs to be copied */
        for (i=0; (i < md->paramcount) && (i < TRACE_ARGS_NUM); i++)    {
-               disp += 4;
-               if (IS_2_WORD_TYPE(md->paramtypes[i].type)) {   
-                       disp += 4;
-               }
+               disp += 8;
        }
 
        /* disp now points to the first arg which gets copied to the trace stack, relative to REG_SP! */
@@ -609,19 +606,11 @@ void emit_verbosecall_enter(jitdata* jd)
                        /* traced function has such an argument */
                        t = md->paramtypes[i].type;
                        
-                       if (IS_2_WORD_TYPE(t))  {
-                               /* copy from original argument stack */
-                               M_ILD(REG_ITMP1, REG_SP, disp);
-                               M_IPUSH(REG_ITMP1);
-                               M_ILD(REG_ITMP1, REG_SP, disp);
-                               M_IPUSH(REG_ITMP1);
-                       } else  {
-                               /* displacment is increased as 4 byte on original stack but 8 byte on trace stack */
-                               M_ILD(REG_ITMP1, REG_SP, disp);
-                               M_IPUSH(REG_ITMP1);
-                               M_IPUSH_IMM(0);
-                               disp += 4;
-                       }
+                       /* copy from original argument stack */
+                       M_ILD(REG_ITMP1, REG_SP, disp);
+                       M_ILD(REG_ITMP2, REG_SP, disp-4);
+                       M_IPUSH(REG_ITMP2);
+                       M_IPUSH(REG_ITMP1);
                } else  {
                        /* function has no arg here, push nothing and adapt displacement */
                        M_IPUSH_IMM(0);
@@ -670,7 +659,7 @@ void emit_verbosecall_exit(jitdata* jd)
 
 #if !defined(ENABLE_SOFTFLOAT)
        M_AADD_IMM(-8, REG_SP);
-       M_FSTORE(REG_F1, REG_SP, 0);
+       M_FSTORE(REG_D1, REG_SP, 0);
 #endif
 
        M_IPUSH_IMM(m);                                 /* push methodinfo */
@@ -702,7 +691,7 @@ void emit_verbosecall_exit(jitdata* jd)
        M_AADD_IMM(3*4 + 4, REG_SP);
 
 #if !defined(ENABLE_SOFTFLOAT)
-       M_FLOAD(REG_F1, REG_SP, 0)
+       M_FLOAD(REG_D1, REG_SP, 0)
        M_AADD_IMM(8, REG_SP);
 #endif
 
index 3a46003a8c0340fbc5e1d3acfcbcbda5c7060fb2..8ad83aa098a8fa22249c4aacbbf49c93e73b6e85 100644 (file)
@@ -51,12 +51,20 @@ const s4 abi_registers_integer_temporary[]  = {0,1};
 /* Address register description */
 /* A6 is used as framepointer by native code, so be sure it is REG_RES */
 /*                        A0,      A1,   ATMP1,   ATMP2,   ATMP3,      A5,  REG_FP, REG_SP */
+#if 0
+s4 nregdescadr[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_RES, REG_RES, REG_END };
+#else
 s4 nregdescadr[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_RES, REG_END };
+#endif
 
 const char *abi_registers_address_name [] = { "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7" };
 
 const s4 abi_registers_address_argument[]      ;
+#if 0
+const s4 abi_registers_address_saved[]                 = {5};
+#else
 const s4 abi_registers_address_saved[]                 = {5,6};
+#endif
 const s4 abi_registers_address_temporary[]     = {0,1};
 
 
index f6a72e2ac43ff8673fa3326ed3ffcf4895a485a0..fc7d09caf8c10ed41a95c1d9990e519d23a3fb2c 100644 (file)
        #define FLT_RES_CNT      8   /* number of float reserved registers            */
 #endif
 
+#if 0
+#define ADR_REG_CNT      8
+#define ADR_SAV_CNT      1
+#define ADR_ARG_CNT      0
+#define ADR_TMP_CNT      2
+#define ADR_RES_CNT      5
+#else
 #define ADR_REG_CNT      8
 #define ADR_SAV_CNT      2
 #define ADR_ARG_CNT      0
 #define ADR_TMP_CNT      2
 #define ADR_RES_CNT      4
-
+#endif
 
 /* packed register defines ***************************************************/
 
index 4a3bfa4715f1c87b57f63b2fa138498f71b78563..eea3da4227201c76f4422a5417aa39126dfaffed 100644 (file)
@@ -944,7 +944,6 @@ void replace_deactivate_replacement_points(codeinfo *code)
    
    IN:
           es...............execution state
-          sp...............stack pointer of the execution state (XXX eliminate?)
           ra...............allocation
           javaval..........where to put the value
 
@@ -954,7 +953,6 @@ void replace_deactivate_replacement_points(codeinfo *code)
 *******************************************************************************/
 
 static void replace_read_value(executionstate_t *es,
-                                                          stackslot_t *sp,
                                                           rplalloc *ra,
                                                           replace_val_t *javaval)
 {
@@ -962,11 +960,11 @@ static void replace_read_value(executionstate_t *es,
                /* 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*)(sp + ra->regoff);
+                       javaval->l = *(u8*)(es->sp + ra->regoff);
                }
                else {
 #endif
-                       javaval->p = sp[ra->regoff];
+                       javaval->p = *(ptrint*)(es->sp + ra->regoff);
 #ifdef HAS_4BYTE_STACKSLOT
                }
 #endif
@@ -1004,14 +1002,12 @@ static void replace_read_value(executionstate_t *es,
    
    IN:
           es...............execution state
-          sp...............stack pointer of the execution state (XXX eliminate?)
           ra...............allocation
           *javaval.........the value
 
 *******************************************************************************/
 
 static void replace_write_value(executionstate_t *es,
-                                                           stackslot_t *sp,
                                                            rplalloc *ra,
                                                            replace_val_t *javaval)
 {
@@ -1019,11 +1015,11 @@ static void replace_write_value(executionstate_t *es,
                /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */
 #ifdef HAS_4BYTE_STACKSLOT
                if (IS_2_WORD_TYPE(ra->type)) {
-                       *(u8*)(sp + ra->regoff) = javaval->l;
+                       *(u8*)(es->sp + ra->regoff) = javaval->l;
                }
                else {
 #endif
-                       sp[ra->regoff] = javaval->p;
+                       *(ptrint*)(es->sp + ra->regoff) = javaval->p;
 #ifdef HAS_4BYTE_STACKSLOT
                }
 #endif
@@ -1186,7 +1182,7 @@ static void replace_read_executionstate(rplpoint *rp,
                if (ra->type == TYPE_RET)
                        frame->javalocals[i].i = ra->regoff;
                else
-                       replace_read_value(es, sp, ra, frame->javalocals + i);
+                       replace_read_value(es, ra, frame->javalocals + i);
                ra++;
                count--;
        }
@@ -1211,12 +1207,12 @@ static void replace_read_executionstate(rplpoint *rp,
                instra.regoff = md->params[0].regoff;
                if (md->params[0].inmemory) {
                        instra.flags = INMEMORY;
-                       instra.regoff += (1 + code->stackframesize);
+                       instra.regoff += (1 + code->stackframesize) * SIZE_OF_STACKSLOT;
                }
                else {
                        instra.flags = 0;
                }
-               replace_read_value(es, sp, &instra, &(frame->instance));
+               replace_read_value(es, &instra, &(frame->instance));
 #endif
        }
 #endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */
@@ -1288,7 +1284,7 @@ static void replace_read_executionstate(rplpoint *rp,
 
                                calleeframe->syncslotcount = 1;
                                calleeframe->syncslots = DMNEW(replace_val_t, 1);
-                               replace_read_value(es,sp,ra,calleeframe->syncslots);
+                               replace_read_value(es,ra,calleeframe->syncslots);
                        }
 
                        frame->javastackdepth--;
@@ -1306,7 +1302,7 @@ static void replace_read_executionstate(rplpoint *rp,
                        if (ra->type == TYPE_RET)
                                frame->javastack[i].i = ra->regoff;
                        else
-                               replace_read_value(es,sp,ra,frame->javastack + i);
+                               replace_read_value(es,ra,frame->javastack + i);
                        frame->javastacktype[i] = ra->type;
                        i++;
                }
@@ -1379,7 +1375,7 @@ static void replace_write_executionstate(rplpoint *rp,
                        /* XXX assert that it matches this rplpoint */
                }
                else
-                       replace_write_value(es, sp, ra, frame->javalocals + i);
+                       replace_write_value(es, ra, frame->javalocals + i);
                count--;
                ra++;
        }
@@ -1436,7 +1432,7 @@ static void replace_write_executionstate(rplpoint *rp,
                                assert(frame->down->syncslotcount == 1); /* XXX need to understand more cases */
                                assert(frame->down->syncslots != NULL);
 
-                               replace_write_value(es,sp,ra,frame->down->syncslots);
+                               replace_write_value(es,ra,frame->down->syncslots);
                        }
                        continue;
                }
@@ -1455,7 +1451,7 @@ static void replace_write_executionstate(rplpoint *rp,
                                /* XXX assert that it matches this rplpoint */
                        }
                        else {
-                               replace_write_value(es,sp,ra,frame->javastack + i);
+                               replace_write_value(es,ra,frame->javastack + i);
                        }
                        i++;
                }
index 32b064f66fccd765b31943e2a50fb3c601f26b43..19dc3f71c1f23b924656313e463944f27cb47d18 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: properties.c 7783 2007-04-20 13:28:27Z twisti $
+   $Id: properties.c 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
@@ -82,17 +82,20 @@ static list_t *list_properties = NULL;
 bool properties_init(void)
 {
 #if defined(ENABLE_JAVASE)
-       char           *cwd;
        char           *env_java_home;
+       char           *java_home;
+       s4              len;
+
+# if defined(WITH_CLASSPATH_GNU)
+       char           *cwd;
        char           *env_user;
        char           *env_home;
        char           *env_lang;
-       char           *java_home;
        char           *extdirs;
        char           *lang;
        char           *country;
        struct utsname *utsnamebuf;
-       s4              len;
+# endif
 #endif
 
        /* create the properties list */
@@ -100,17 +103,10 @@ bool properties_init(void)
        list_properties = list_create(OFFSET(list_properties_entry, linkage));
 
 #if defined(ENABLE_JAVASE)
+
        /* get properties from system */
 
-       cwd           = _Jv_getcwd();
        env_java_home = getenv("JAVA_HOME");
-       env_user      = getenv("USER");
-       env_home      = getenv("HOME");
-       env_lang      = getenv("LANG");
-
-       utsnamebuf = NEW(struct utsname);
-
-       uname(utsnamebuf);
 
        /* set JAVA_HOME to default prefix if not defined */
 
@@ -119,10 +115,6 @@ bool properties_init(void)
 
        /* fill in system properties */
 
-       properties_add("java.version", JAVA_VERSION);
-       properties_add("java.vendor", "GNU Classpath");
-       properties_add("java.vendor.url", "http://www.gnu.org/software/classpath/");
-
        /* add /jre to java.home property */
 
        len = strlen(env_java_home) + strlen("/jre") + strlen("0");
@@ -140,14 +132,34 @@ bool properties_init(void)
        properties_add("java.vm.version", VERSION);
        properties_add("java.vm.vendor", "CACAO Team");
        properties_add("java.vm.name", "CACAO");
+
+# if defined(WITH_CLASSPATH_GNU)
+
+       /* 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.class.version", CLASS_VERSION);
-       properties_add("java.class.path", _Jv_classpath);
 
-       properties_add("java.runtime.version", VERSION);
-       properties_add("java.runtime.name", "CACAO");
+       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.path", _Jv_classpath);
+       properties_add("java.class.version", CLASS_VERSION);
 
        /* Set bootclasspath properties. One for GNU classpath and the
           other for compatibility with Sun (required by most
@@ -156,20 +168,20 @@ bool properties_init(void)
        properties_add("java.boot.class.path", _Jv_bootclasspath);
        properties_add("sun.boot.class.path", _Jv_bootclasspath);
 
-#if defined(WITH_STATIC_CLASSPATH)
+#  if defined(WITH_STATIC_CLASSPATH)
        properties_add("gnu.classpath.boot.library.path", ".");
        properties_add("java.library.path" , ".");
-#else
+#  else
        /* fill gnu.classpath.boot.library.path with GNU Classpath library
        path */
 
        properties_add("gnu.classpath.boot.library.path", classpath_libdir);
        properties_add("java.library.path", _Jv_java_library_path);
-#endif
+#  endif
 
        properties_add("java.io.tmpdir", "/tmp");
 
-#if defined(ENABLE_INTRP)
+#  if defined(ENABLE_INTRP)
        if (opt_intrp) {
                /* XXX We don't support java.lang.Compiler */
 /*             properties_add("java.compiler", "cacao.intrp"); */
@@ -177,7 +189,7 @@ bool properties_init(void)
                properties_add("gnu.java.compiler.name", "cacao.intrp");
        }
        else
-#endif
+#  endif
        {
                /* XXX We don't support java.lang.Compiler */
 /*             properties_add("java.compiler", "cacao.jit"); */
@@ -198,7 +210,7 @@ bool properties_init(void)
 
        properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
 
-#if defined(DISABLE_GC)
+#  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
@@ -208,46 +220,47 @@ bool properties_init(void)
        properties_add("os.arch", "unknown");
        properties_add("os.name", "unknown");
        properties_add("os.version", "unknown");
-#else
+#  else
        /* We need to set the os.arch hardcoded to be compatible with SUN. */
 
-# if defined(__I386__)
+#   if defined(__I386__)
        /* map all x86 architectures (i386, i486, i686) to i386 */
 
        properties_add("os.arch", "i386");
-# elif defined(__POWERPC__)
+#   elif defined(__POWERPC__)
        properties_add("os.arch", "ppc");
-# elif defined(__X86_64__)
+#   elif defined(__X86_64__)
        properties_add("os.arch", "amd64");
-# else
+#   else
        /* default to what uname returns */
 
        properties_add("os.arch", utsnamebuf->machine);
-# endif
+#   endif
 
        properties_add("os.name", utsnamebuf->sysname);
        properties_add("os.version", utsnamebuf->release);
-#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");
+#  endif
 
-#if defined(WITH_STATIC_CLASSPATH)
+#  if defined(WITH_STATIC_CLASSPATH)
        /* This is just for debugging purposes and can cause troubles in
        GNU Classpath. */
 
        properties_add("gnu.cpu.endian", "unknown");
-#else
-# if WORDS_BIGENDIAN == 1
+#  else
+#   if WORDS_BIGENDIAN == 1
        properties_add("gnu.cpu.endian", "big");
-# else
+#   else
        properties_add("gnu.cpu.endian", "little");
-# endif
-#endif
+#   endif
+#  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 */
 
@@ -278,13 +291,28 @@ bool properties_init(void)
                properties_add("user.language", "en");
                properties_add("user.country", "US");
        }
+
+# elif defined(WITH_CLASSPATH_SUN)
+
+       properties_add("sun.boot.library.path", classpath_libdir);
+
+# 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
+
+# error unknown Java configuration
+
 #endif
 
        /* everything's ok */
index 9d8a4e599832c61994120edc06c7cc7d4524e65b..e68f36fb04d6ee1a2e758d88b89b80f57dac6bcc 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: vm.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: vm.c 8137 2007-06-22 16:41:36Z michi $
 
 */
 
 
 #include "native/jni.h"
 #include "native/native.h"
-#include "native/include/java_lang_String.h" /* required by java_lang_Class.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_CLASSPATH_SUN)
+# 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/include/java_lang_Byte.h"
@@ -63,6 +71,8 @@
 #include "native/include/java_lang_Float.h"
 #include "native/include/java_lang_Double.h"
 
+#include "native/vm/nativevm.h"
+
 #include "threads/threads-common.h"
 
 #include "toolbox/logging.h"
@@ -866,7 +876,12 @@ bool vm_create(JavaVMInitArgs *vm_args)
 #else
        cacao_prefix     = CACAO_PREFIX;
        cacao_libjvm     = CACAO_LIBDIR"/libjvm";
+
+# if defined(WITH_CLASSPATH_GNU)
        classpath_libdir = CLASSPATH_LIBDIR"/classpath";
+# else
+       classpath_libdir = CLASSPATH_LIBDIR;
+# endif
 #endif
 
        /* set the bootclasspath */
@@ -1633,16 +1648,23 @@ bool vm_create(JavaVMInitArgs *vm_args)
        if (!primitive_init())
                vm_abort("vm_create: primitive_init failed");
 
+       if (!exceptions_init())
+               vm_abort("vm_create: exceptions_init failed");
+
+       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");
 
-       if (!exceptions_init())
-               vm_abort("vm_create: exceptions_init failed");
+       /* Register the native methods implemented in the VM. */
+       /* BEFORE: threads_init */
 
-       if (!builtin_init())
-               vm_abort("vm_create: builtin_init failed");
+       if (!nativevm_preinit())
+               vm_abort("vm_create: nativevm_preinit failed");
 
 #if defined(ENABLE_JNI)
        /* Initialize the JNI subsystem (must be done _before_
@@ -1658,6 +1680,12 @@ bool vm_create(JavaVMInitArgs *vm_args)
                vm_abort("vm_create: threads_init failed");
 #endif
 
+       /* Initialize the native VM subsystem. */
+       /* AFTER: threads_init (at least for SUN's classes) */
+
+       if (!nativevm_init())
+               vm_abort("vm_create: nativevm_init failed");
+
 #if defined(ENABLE_PROFILING)
        /* initialize profiling */
 
@@ -2396,7 +2424,11 @@ static void vm_array_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(__POWERPC64__)
                array[index] = value >> 32;
 #else
@@ -2425,12 +2457,22 @@ static void vm_array_store_dbl(uint64_t *array, paramdesc *pd, uint64_t value)
 {
        int32_t index;
 
-       if (!pd->inmemory)
-               index = INT_ARG_CNT + pd->index;
-       else
-               index = ARG_CNT + pd->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;
 
-       array[index] = value;
+               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;
+       }
 }
 
 
@@ -2477,7 +2519,7 @@ static void vm_array_store_adr(uint64_t *array, paramdesc *pd, void *value)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
                                                                  vm_arg *vmargs, va_list ap)
 {
@@ -2613,9 +2655,9 @@ uint64_t *vm_array_from_valist(methodinfo *m, java_objectheader *o, va_list ap)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
-                                                                 vm_arg *vmargs, jvalue *args)
+                                                                 vm_arg *vmargs, const jvalue *args)
 {
        typedesc *paramtypes;
        s4        i;
@@ -2673,7 +2715,7 @@ static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
 }
 #else
 static uint64_t *vm_array_from_jvalue(methodinfo *m, java_objectheader *o,
-                                                                         jvalue *args)
+                                                                         const jvalue *args)
 {
        methoddesc *md;
        paramdesc  *pd;
@@ -2743,7 +2785,7 @@ static uint64_t *vm_array_from_jvalue(methodinfo *m, java_objectheader *o,
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o,
                                                                vm_arg *vmargs, java_objectarray *params)
 {
@@ -3146,7 +3188,7 @@ java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
                                                                                 va_list ap)
 {
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__ARM__) & !defined(__M68K__)
        s4                 vmargscount;
        vm_arg            *vmargs;
        java_objectheader *ro;
@@ -3211,9 +3253,9 @@ java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
 *******************************************************************************/
 
 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
-                                                                                jvalue *args)
+                                                                                const jvalue *args)
 {
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
        s4                 vmargscount;
        vm_arg            *vmargs;
        java_objectheader *ro;
@@ -3277,7 +3319,7 @@ java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
                                                                                vm_arg *vmargs)
 {
@@ -3345,7 +3387,7 @@ java_objectheader *vm_call_array(methodinfo *m, uint64_t *array)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
 {
        s4 i;
@@ -3432,7 +3474,7 @@ s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
 {
        s4      vmargscount;
@@ -3501,8 +3543,9 @@ int32_t vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list a
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
-s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o,
+                                                        const jvalue *args)
 {
        s4      vmargscount;
        vm_arg *vmargs;
@@ -3536,7 +3579,8 @@ s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
        return i;
 }
 #else
-int32_t vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
+int32_t vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o,
+                                                                 const jvalue *args)
 {
        int32_t   dumpsize;
        uint64_t *array;
@@ -3570,7 +3614,7 @@ int32_t vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *a
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
 {
        s8 l;
@@ -3657,7 +3701,7 @@ s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
 {
        s4      vmargscount;
@@ -3726,8 +3770,9 @@ int64_t vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
-s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
+s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o,
+                                                         const jvalue *args)
 {
        s4      vmargscount;
        vm_arg *vmargs;
@@ -3761,7 +3806,8 @@ s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
        return l;
 }
 #else
-int64_t vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
+int64_t vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o,
+                                                                  const jvalue *args)
 {
        int32_t   dumpsize;
        uint64_t *array;
@@ -3795,7 +3841,7 @@ int64_t vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
 {
        float f;
@@ -3883,7 +3929,7 @@ float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
                                                                  va_list ap)
 {
@@ -3952,9 +3998,9 @@ float vm_call_method_float_valist(methodinfo *m, java_objectheader *o, va_list a
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
-                                                                 jvalue *args)
+                                                                 const jvalue *args)
 {
        s4      vmargscount;
        vm_arg *vmargs;
@@ -3988,7 +4034,7 @@ float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
        return f;
 }
 #else
-float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
+float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o, const jvalue *args)
 {
        int32_t   dumpsize;
        uint64_t *array;
@@ -4022,7 +4068,7 @@ float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o, jvalue *a
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
                                                                   vm_arg *vmargs)
 {
@@ -4112,7 +4158,7 @@ double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
                                                                        va_list ap)
 {
@@ -4182,9 +4228,9 @@ double vm_call_method_double_valist(methodinfo *m, java_objectheader *o, va_list
 
 *******************************************************************************/
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
-                                                                       jvalue *args)
+                                                                       const jvalue *args)
 {
        s4      vmargscount;
        vm_arg *vmargs;
@@ -4218,7 +4264,7 @@ double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
        return d;
 }
 #else
-double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
+double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o, const jvalue *args)
 {
        int32_t   dumpsize;
        uint64_t *array;
index ef976a2dbfe591da469bca21fd362912dc5e9254..93d0d89f812fdbf9f718bc113c1ab76e0c695a8e 100644 (file)
@@ -104,7 +104,7 @@ void vm_exit_handler(void);
 void vm_abort(const char *text, ...);
 
 /* Java method calling functions */
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o,
                                                                vm_arg *vmargs, java_objectarray *params);
 #else
@@ -116,9 +116,9 @@ java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...);
 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
                                                                                 va_list ap);
 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
-                                                                                jvalue *args);
+                                                                                const jvalue *args);
 
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
                                                                                vm_arg *vmargs);
 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
@@ -135,23 +135,25 @@ double             vm_call_double_array(methodinfo *m, uint64_t *array);
 
 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...);
 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap);
-s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args);
+s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o,
+                                                        const jvalue *args);
 
 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...);
 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap);
-s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args);
+s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o,
+                                                         const jvalue *args);
 
 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...);
 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
                                                                  va_list ap);
 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
-                                                                 jvalue *args);
+                                                                 const jvalue *args);
 
 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...);
 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
                                                                        va_list ap);
 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
-                                                                       jvalue *args);
+                                                                       const jvalue *args);
 
 #endif /* _VM_H */
 
index 7dfaf675c69f875b7a0449952b05f28010f8134b..e962ac584d06f335bd4f66bc3cc45990f5d82820 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: class.h 8123 2007-06-20 23:50:55Z michi $
+   $Id: class.h 8137 2007-06-22 16:41:36Z michi $
 
 */
 
@@ -39,6 +39,9 @@ typedef struct castinfo       castinfo;
 
 
 #include "config.h"
+
+#include <stdint.h>
+
 #include "vm/types.h"
 
 #include "toolbox/list.h"
@@ -82,7 +85,15 @@ typedef struct castinfo       castinfo;
 
 typedef struct {
        java_objectheader header;
-       ptrint            padding[4];
+#if defined(WITH_CLASSPATH_GNU)
+       intptr_t           padding[4];
+#elif defined(WITH_CLASSPATH_SUN)
+       intptr_t           padding[19];
+#elif defined(WITH_CLASSPATH_CLDC1_1)
+       intptr_t           padding[3];
+#else
+# error unknown classpath configuration
+#endif
 } dummy_java_lang_Class;
 
 struct classinfo {                /* class structure                          */
index 01b5f72b841ccac6ad1c0a55d5b694628483c5b1..4f8dcff7a907a1086812bad79f4117abd0b74be3 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: field.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: field.c 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
 
 #include "config.h"
 
+#include <assert.h>
 #include <stdio.h>
 
 #include "vm/types.h"
 
+#include "vmcore/class.h"
 #include "vmcore/field.h"
+#include "vmcore/primitive.h"
 #include "vmcore/references.h"
 #include "vmcore/utf8.h"
 
 
+/* 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->class->classloader);
+       }
+       else {
+               c = primitive_class_get_by_type(td->decltype);
+       }
+
+       return c;
+}
+
+
 /* field_free ******************************************************************
 
    Frees a fields' resources.
index dcbd1eec8e37b009a50230faf3011962a3464104..00616399d4c8aac0d891afdd21d6a4bc3c28c284 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: field.h 7246 2007-01-29 18:49:05Z twisti $
+   $Id: field.h 8132 2007-06-22 11:15:47Z twisti $
 */
 
 
@@ -72,7 +72,8 @@ struct fieldinfo {          /* field of a class                                 */
 
 /* function prototypes ********************************************************/
 
-void field_free(fieldinfo *f);
+classinfo *field_get_type(fieldinfo *f);
+void       field_free(fieldinfo *f);
 
 #if !defined(NDEBUG)
 void field_printflags(fieldinfo *f);
index c143a0c61bc2409111fc71416040c21d9d5e0034..09bc6723474b96c11fa16099d567662bcf104f14 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: options.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: options.c 8134 2007-06-22 14:49:10Z twisti $
 
 */
 
@@ -179,9 +179,12 @@ const char *opt_filter_show_method = 0;
 
 /* NOTE: For better readability keep these alpha-sorted. */
 
+int32_t  opt_MaxPermSize               = 0;
+int32_t  opt_PermSize                  = 0;
 int32_t  opt_ProfileGCMemoryUsage      = 0;
 int32_t  opt_ProfileMemoryUsage        = 0;
 FILE    *opt_ProfileMemoryUsageGNUPlot = NULL;
+int32_t  opt_ThreadStackSize           = 0;
 int32_t  opt_TraceExceptions           = 0;
 #if defined(ENABLE_REPLACEMENT)
 int32_t  opt_TraceReplacement          = 0;
@@ -189,18 +192,24 @@ int32_t  opt_TraceReplacement          = 0;
 
 
 enum {
+       OPT_MaxPermSize,
+       OPT_PermSize,
        OPT_ProfileGCMemoryUsage,
        OPT_ProfileMemoryUsage,
        OPT_ProfileMemoryUsageGNUPlot,
+       OPT_ThreadStackSize,
        OPT_TraceExceptions,
        OPT_TraceReplacement
 };
 
 
 option_t options_XX[] = {
+       { "MaxPermSize",               OPT_MaxPermSize,               "" },
+       { "PermSize",                  OPT_PermSize,                  "" },
        { "ProfileGCMemoryUsage",      OPT_ProfileGCMemoryUsage,      "" },
        { "ProfileMemoryUsage",        OPT_ProfileMemoryUsage,        "" },
        { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, "" },
+       { "ThreadStackSize",           OPT_ThreadStackSize,           "" },
        { "TraceExceptions",           OPT_TraceExceptions,           "" },
 #if defined(ENABLE_REPLACEMENT)
        { "TraceReplacement",          OPT_TraceReplacement,          "" },
@@ -298,27 +307,42 @@ s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
 
 void options_xx(const char *name)
 {
+       char    *start;
        char    *end;
        int32_t  length;
+       int32_t  enable;
        char    *value;
        int32_t  option;
        char    *filename;
        FILE    *file;
        int32_t  i;
 
-       log_println("name: %s", name);
+       /* Check if the option is a boolean option. */
 
-       /* Search for a ':' in the option name and get the option name
+       if (name[0] == '+') {
+               start  = name + 1;
+               enable = 1;
+       }
+       else if (name[0] == '-') {
+               start  = name + 1;
+               enable = 0;
+       }
+       else {
+               start  = name;
+               enable = -1;
+       }
+
+       /* Search for a '=' in the option name and get the option name
           length and the value of the option. */
 
-       end = strchr(name, ':');
+       end = strchr(start, '=');
 
        if (end == NULL) {
-               length = strlen(name);
+               length = strlen(start);
                value  = NULL;
        }
        else {
-               length = end - name;
+               length = end - start;
                value  = end + 1;
        }
 
@@ -327,7 +351,7 @@ void options_xx(const char *name)
        option = OPT_ERROR;
 
        for (i = 0; options_XX[i].name != NULL; i++) {
-               if (strncmp(options_XX[i].name, name, length) == 0) {
+               if (strncmp(options_XX[i].name, start, length) == 0) {
                        option = options_XX[i].option;
                        break;
                }
@@ -336,6 +360,14 @@ void options_xx(const char *name)
        /* process the option */
 
        switch (option) {
+       case OPT_MaxPermSize:
+               /* currently ignored */
+               break;
+
+       case OPT_PermSize:
+               /* currently ignored */
+               break;
+
        case OPT_ProfileGCMemoryUsage:
                if (value == NULL)
                        opt_ProfileGCMemoryUsage = 5;
@@ -370,8 +402,12 @@ void options_xx(const char *name)
                opt_ProfileMemoryUsageGNUPlot = file;
                break;
 
+       case OPT_ThreadStackSize:
+               /* currently ignored */
+               break;
+
        case OPT_TraceExceptions:
-               opt_TraceExceptions = true;
+               opt_TraceExceptions = enable;
                break;
 
 #if defined(ENABLE_REPLACEMENT)
index c1ee4d381318b4ed171bba08707847d6fa144b1e..049a47079f9b33079696d2c6e2fb4c5e519dc4c4 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: options.h 8123 2007-06-20 23:50:55Z michi $
+   $Id: options.h 8134 2007-06-22 14:49:10Z twisti $
 
 */
 
@@ -193,9 +193,12 @@ extern const char *opt_filter_show_method;
 
 /* NOTE: For better readability keep these alpha-sorted. */
 
+extern int32_t  opt_MaxPermSize;
+extern int32_t  opt_PermSize;
 extern int32_t  opt_ProfileGCMemoryUsage;
 extern int32_t  opt_ProfileMemoryUsage;
 extern FILE    *opt_ProfileMemoryUsageGNUPlot;
+extern int32_t  opt_ThreadStackSize;
 extern int32_t  opt_TraceExceptions;
 #if defined(ENABLE_REPLACEMENT)
 extern int32_t  opt_TraceReplacement;
index 4575dc2dcb62454acb7c1a1cab2fe24590921f67..d9893ef004391c33cac2f2156235644129ffda5d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: utf8.c 8123 2007-06-20 23:50:55Z michi $
+   $Id: utf8.c 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
@@ -171,6 +171,7 @@ utf *utf_get;
 utf *utf_value;
 
 utf *utf_fillInStackTrace;
+utf *utf_findNative;
 utf *utf_getSystemClassLoader;
 utf *utf_initCause;
 utf *utf_loadClass;
@@ -200,6 +201,7 @@ 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              */
@@ -410,6 +412,7 @@ bool utf8_init(void)
        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");
@@ -441,6 +444,9 @@ bool utf8_init(void)
        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 =
index da788d77450c9ef0194af2bc11a36f71a0c7de4a..b6a6992abc78721000b3aae8527f87d52c905ddd 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: utf8.h 8123 2007-06-20 23:50:55Z michi $
+   $Id: utf8.h 8132 2007-06-22 11:15:47Z twisti $
 
 */
 
@@ -167,6 +167,7 @@ extern utf *utf_get;
 extern utf *utf_value;
 
 extern utf *utf_fillInStackTrace;
+extern utf *utf_findNative;
 extern utf *utf_getSystemClassLoader;
 extern utf *utf_initCause;
 extern utf *utf_loadClass;
@@ -196,6 +197,7 @@ 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;