From 58bac0a56dab7d6983a3cfbee7a9b7ffec5a4284 Mon Sep 17 00:00:00 2001 From: michi Date: Mon, 13 Aug 2007 08:41:18 +0000 Subject: [PATCH] Merged revisions 8245-8298 via svnmerge from svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk ........ r8246 | michi | 2007-07-31 13:36:03 +0200 (Tue, 31 Jul 2007) | 2 lines * src/vm/jit/sparc64/md.c: Fixed file header. ........ r8247 | michi | 2007-07-31 14:06:44 +0200 (Tue, 31 Jul 2007) | 10 lines * src/vm/jit/arm/arch.h, src/vm/jit/powerpc/arch.h, src/vm/jit/sparc64/arch.h, src/vm/jit/alpha/arch.h, src/vm/jit/s390/arch.h, src/vm/jit/mips/arch.h, src/vm/jit/powerpc64/arch.h, src/vm/jit/i386/arch.h, src/vm/jit/x86_64/arch.h (REPLACEMENT_STUB_SIZE): Removed obsolete define. * src/vm/jit/powerpc/md.c, src/vm/jit/sparc64/md.c, src/vm/jit/alpha/md.c, src/vm/jit/mips/md.c, src/vm/jit/powerpc64/md.c, src/vm/jit/i386/md.c, src/vm/jit/x86_64/md.c (md_patch_replacement_point): We have to use trap instructions here. ........ r8248 | twisti | 2007-07-31 14:47:11 +0200 (Tue, 31 Jul 2007) | 6 lines * configure.ac: Only check AC_PROG_JAVAC and AC_PROG_JAR for CLDC-1.1 and GNU. * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed default value for different configurations.. ........ r8249 | panzi | 2007-07-31 14:59:03 +0200 (Tue, 31 Jul 2007) | 257 lines * src/lib/gnu/java/lang/reflect/Method.java (annotations): Added. (parameterAnnotations): Added. (annotationDefault): Added. * src/lib/gnu/java/lang/reflect/Field.java (annotations): Added. * src/lib/gnu/sun/reflect: New directory. * src/lib/gnu/sun/reflect/generics: New directory. * src/lib/gnu/sun/reflect/generics/parser: New directory. * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java: New file. * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: New file. This class parses type signatures and returns the acording type as a java.lang.Class instance. * src/lib/gnu/sun/reflect/ConstantPool.java [WITH_CLASSPATH_GNU]: New file. * src/lib/gnu/sun/reflect/annotation: New directory. * src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK. * src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK. * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so it can be used with GNU Classpath. [WITH_CLASSPATH_GNU] (parseAnnotationsIntoArray): Added for convenience. [WITH_CLASSPATH_GNU] (parseAnnotationDefault): Added for convenience. * src/lib/gnu/sun/reflect/annotation/AnnotationType.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so it can be used with GNU Classpath. [WITH_CLASSPATH_GNU] (annotationTypes): Added to emulate sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType(). * src/lib/Makefile.am [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]: Added classes needed by annotations support. * src/native/vm/nativevm.h [ENABLE_ANNOTATIONS] (_Jv_sun_reflect_ConstantPool_init): Added. * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (vmcore/annotation.h): Include added. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): Include added. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): Implemented. * src/native/vm/gnu/java_lang_VMClass.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (Java_java_lang_VMClass_getDeclaredAnnotations): Implemented. * src/native/vm/gnu/sun_reflect_ConstantPool.c [ENABLE_ANNOTATIONS]: Added implementation of sun.reflect.ConstantPool class. This is an copy of the according functions from src/native/vm/sun/jvm.c for I don't know how to unify it better (needs to be discussed). * src/native/vm/gnu/java_lang_reflect_Method.c [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): Added include. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Method_getDefaultValue): Implemented. * src/native/vm/gnu/Makefile.am [ENABLE_ANNOTATIONS] (SUN_REFLECT_SOURCES): Added sun_reflect_ConstantPool.c * src/native/vm/java_lang_Class.h [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): Added. * src/native/vm/sun/jvm.c (assert.h): Added include. (native/include/java_lang_Integer.h): Added include. (native/include/java_lang_Long.h): Added include. (native/include/java_lang_Short.h): Added include. (native/include/java_lang_Byte.h): Added include. (native/include/java_lang_Character.h): Added include. (native/include/java_lang_Boolean.h): Added include. (native/include/java_lang_Float.h): Added include. (native/include/java_lang_Double.h): Added include. [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): Added include. (JVM_GetDeclaringClass): Implemented. (JVM_GetClassAnnotations) [ENABLE_ANNOTATIONS]: Implemented. (JVM_GetFieldAnnotations): Implemented. (JVM_GetMethodAnnotations): Implemented. (JVM_GetMethodDefaultAnnotationValue): Implemented. (JVM_GetMethodParameterAnnotations): Implemented. [ENABLE_ANNOTATIONS] (JVM_GetClassConstantPool): Implemented. (JVM_ConstantPoolGetSize): Implemented. (JVM_ConstantPoolGetClassAt): Implemented. (JVM_ConstantPoolGetClassAtIfLoaded): Implemented. (JVM_ConstantPoolGetMethodAt): Implemented. (JVM_ConstantPoolGetMethodAtIfLoaded): Implemented. (JVM_ConstantPoolGetFieldAt): Implemented. (JVM_ConstantPoolGetFieldAtIfLoaded): Implemented. (JVM_ConstantPoolGetIntAt): Implemented. (JVM_ConstantPoolGetLongAt): Implemented. (JVM_ConstantPoolGetFloatAt): Implemented. (JVM_ConstantPoolGetDoubleAt): Implemented. (JVM_ConstantPoolGetStringAt): Implemented. (JVM_ConstantPoolGetUTF8At): Implemented. (JVM_GetArrayElement): Quickly implemented (will be rewritten by twisti). I needed this function in a testcase and not directly for annotations support. * src/native/vm/reflect.c [ENABLE_ANNOTATIONS] (mm/memmory.h): Added include. (reflect_constructor_new) [ENABLE_ANNOTATIONS]: Load annotations and parameter annotations. (reflect_field_new) [ENABLE_ANNOTATIONS]: Load annotations. (reflect_method_new) [ENABLE_ANNOTATIONS]: Load annotations, parameter annotations and annotation default value. * src/native/vm/nativevm.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (_Jv_sun_reflect_ConstantPool_init): Added call. * src/native/include/Makefile.am [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (JAVASE_HEADER_FILES): Added sun_reflect_ConstantPool.h * src/vmcore/class.c [ENABLE_ANNOTATIONS] (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] (class_sun_reflect_annotation_AnnotationParser): Added. (class_load_attributes) [ENABLE_ANNOTATIONS]: Load annotations. (class_free) [ENABLE_ANNOTATIONS]: Free annotations. * src/vmcore/loader.c (loader_init) [ENABLE_ANNOTATIONS]: Load class_sun_reflect_ConstantPool. (loader_init) [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU]: Load class_sun_reflect_annotation_AnnotationParser. * src/vmcore/annotation.c [!ENABLE_ANNOTATIONS]: Error: annotation support has to be enabled when compling this file. (assert.h): Added include. (toolbox/logging.h): Added include. (annotation_bytearray_new): Added. (annotation_bytearray_free): Added. (annotation_bytearrays_new): Added. (annotation_bytearrays_resize): Added. (annotation_bytearrays_insert): Added. (annotation_bytearrays_free): Added. (annotation_load_attribute_body): Added. Maybe this function should be called loader_load_attribute_body and located in vmcore/loader.c? (annotation_load_method_attribute_annotationdefault): Added. (annotation_load_method_attribute_runtimevisibleparameterannotations): Added. (annotation_load_method_attribute_runtimeinvisibleparameterannotations): Added. (annotation_load_class_attribute_runtimevisibleannotations): Added. (annotation_load_class_attribute_runtimeinvisibleannotations): Added. (annotation_load_method_attribute_runtimevisibleannotations): Added. (annotation_load_method_attribute_runtimeinvisibleannotations): Added. (annotation_load_field_attribute_runtimevisibleannotations): Added. (annotation_load_field_attribute_runtimeinvisibleannotations): Added. * src/vmcore/class.h [ENABLE_ANNOTATIONS] (runtimevisibleannotationscount): Removed. [ENABLE_ANNOTATIONS] (runtimevisibleannotations): Removed. [ENABLE_ANNOTATIONS] (annotations): Added. Bytearray of the unparsed annotations or NULL if none. [ENABLE_ANNOTATIONS] (method_annotations): Added. Array of bytearrays of method annotations. This Array is only as big as needed or NULL if there are no method annotations at all. [ENABLE_ANNOTATIONS] (method_parameterannotations): Added. Array of bytearrays of method parameter annotations. This Array is only as big as needed or NULL if there are no method parameter annotations at all. [ENABLE_ANNOTATIONS] (method_annotationdefaults): Added. Array of bytearrays of method annotation default values. This Array is only as big as needed or NULL if there are no method annotation default values at all. [ENABLE_ANNOTATIONS] (field_annotations): Added. Array of bytearrays of field annotations. This Array is only as big as needed or NULL if there are no field annotations at all. [ENABLE_ANNOTATIONS] (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] (class_sun_reflect_annotation_AnnotationParser): Added. * src/vmcore/annotation.h (annotation_bytearray_t): Added. Used to store unparsed (parameter-) annotations or unparsed annotation default values in. (annotation_bytearrays_t): Added. Array of bytearrays. (annotation_bytearray_new): Added. (annotation_bytearray_free): Added. (annotation_bytearrays_new): Added. (annotation_bytearrays_resize): Added. (annotation_bytearrays_insert): Added. (annotation_bytearrays_free): Added. (annotation_load_class_attribute_runtimeinvisibleannotations): Added. (annotation_load_method_attribute_runtimevisibleannotations): Added. (annotation_load_method_attribute_runtimeinvisibleannotations): Added. (annotation_load_field_attribute_runtimevisibleannotations): Added. (annotation_load_field_attribute_runtimeinvisibleannotations): Added. (annotation_load_method_attribute_annotationdefault): Added. (annotation_load_method_attribute_runtimevisibleparameterannotations): Added. (annotation_load_method_attribute_runtimeinvisibleparameterannotations): Added. * src/vmcore/method.c (method_load) [ENABLE_ANNOTATIONS]: Load annotations, parameter annotations and annotation default values. [ENABLE_ANNOTATIONS] (method_get_annotations): Added. [ENABLE_ANNOTATIONS] (method_get_parameterannotations): Added. [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added. * src/vmcore/method.h [ENABLE_ANNOTATIONS] (method_get_annotations): Added. [ENABLE_ANNOTATIONS] (method_get_parameterannotations): Added. [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added. * src/vmcore/field.c (mm/memory.h): Added include. (vmcore/annotations.h): Added include. (field_load) [ENABLE_ANNOTATIONS]: Laod annotations. [ENABLE_ANNOTATIONS] (field_get_annotations): Added. * src/vmcore/utf8.c [ENABLE_ANNOTATIONS] (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS] (utf_RuntimeVisibleParameterAnnotations): Added. [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations): Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added. [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] (utf_sun_reflect_annotation_AnnotationParser): Added. * src/vmcore/field.h [ENABLE_ANNOTATIONS] (field_get_annotations): Added. * src/vmcore/Makefile.am [ENABLE_ANNOTATIONS] (ANNOTATION_SOURCES): Only compile annotations sources when annotations are enabled. * src/vmcore/utf8.h [ENABLE_ANNOTATIONS] (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS] (utf_RuntimeVisibleParameterAnnotations): Added. [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations): Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added. [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] (utf_sun_reflect_annotation_AnnotationParser): Added. * configure.ac (ENABLE_ANNOTATIONS): Added configure option --enable-annotations. ........ r8250 | twisti | 2007-07-31 15:16:43 +0200 (Tue, 31 Jul 2007) | 3 lines * m4/annotations.m4: New file. * configure.ac: Use AC_CHECK_ENABLE_ANNOTATIONS. ........ r8251 | pm | 2007-08-01 17:26:59 +0200 (Wed, 01 Aug 2007) | 9 lines * jit/patcher.h: Added #error if included on s390. * jit/patcher-common.h: Made declarations visible on s390. * jit/s390/asmpart.S (asm_patcher_wrapper): removed. * jit/s390/emit.c (emit_patcher_stubs): removed, (emit_patcher_traps): added. * jit/s390/codegen.h (PATCHER_LONGBRANCHES_NOPS_SKIP, PATCHER_LONGBRANCHES_NOPS): removed, (PATCHER_CALL_SIZE, PATCHER_NOPS, PATCHER_NOPS_SKIP) adapted to patching via signals. * jit/s390/codegen.c (codegen_emit, codegen_emit_stub_native): Adapted to paching via signals. * jit/s390/md.c (md_signal_handler_sigill, md_signal_handler_sigsegv): added support for exceptions_new_hardware_exception returning NULL. * jit/s390/patcher.c: Adapted to paching via signals. ........ r8252 | twisti | 2007-08-02 00:47:17 +0200 (Thu, 02 Aug 2007) | 5 lines * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed -1.5 from ecj. * src/lib/Makefile.am (vm.zip): Added -source 1.5 -target 1.5. Thanks to Mark Wielaard. ........ r8253 | twisti | 2007-08-02 16:46:00 +0200 (Thu, 02 Aug 2007) | 2 lines * src/native/vm/sun/jvm.c (JVM_RaiseSignal): New function. ........ r8254 | pm | 2007-08-03 20:43:30 +0200 (Fri, 03 Aug 2007) | 3 lines * src/vm/jit/patcher-common.c (patcher_handler): Call LOCK_MONITOR_EXIT instead of LOCK_MONITOR_ENTER in double-patching handler code. ........ r8255 | michi | 2007-08-03 21:06:37 +0200 (Fri, 03 Aug 2007) | 7 lines * src/vm/jit/patcher-common.c (patcher_list_reset): Added. (patcher_add_patch_ref) [!NDEBUG]: Added sanity check. * src/vm/jit/patcher-common.h (patcher_list_reset): Added. * src/vm/jit/codegen-common.c (codegen_reset): Resets the patcher list. ........ r8256 | twisti | 2007-08-05 12:58:21 +0200 (Sun, 05 Aug 2007) | 3 lines * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Use HotSpot-compatible code. ........ r8257 | twisti | 2007-08-05 13:04:21 +0200 (Sun, 05 Aug 2007) | 4 lines * src/vm/jit/patcher-common.c (stdint.h): Added. (patcher_list_free): Removed unused variable pr. (patcher_add_patch_ref): Fixed warning. ........ r8258 | edwin | 2007-08-05 22:15:27 +0200 (Sun, 05 Aug 2007) | 2 lines * src/vm/jit/replace.c (replace_new_sourceframe): Fixed documentation. ........ r8259 | edwin | 2007-08-05 22:41:25 +0200 (Sun, 05 Aug 2007) | 3 lines * src/vm/jit/replace.c (replace_read_executionstate): Improved comments. (replace_write_executionstate): Likewise. ........ r8260 | michi | 2007-08-06 14:19:01 +0200 (Mon, 06 Aug 2007) | 13 lines * src/vm/jit/emit-common.c (emit_patcher_traps): Added. * src/vm/jit/emit-common.h (emit_trap): Added prototype. * src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to emit-common). (emit_trap): Implemented. * src/vm/jit/arm/emit.c: Likewise. * src/vm/jit/powerpc/emit.c: Likewise. * src/vm/jit/s390/emit.c: Likewise. ........ r8261 | michi | 2007-08-06 14:42:31 +0200 (Mon, 06 Aug 2007) | 3 lines * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed obsolete code about PATCHER_LONGBRANCHES_NOPS. ........ r8262 | panzi | 2007-08-06 14:44:01 +0200 (Mon, 06 Aug 2007) | 97 lines * src/lib/gnu/java/lang/reflect/Method.java (java.lang.annotation.Annotation): Added import. (java.util.Map): Added import. (sun.refelct.annotation.AnnotationParser): Added import. (declaredAnnotations): Added field (inspired by OpenJDK). (getAnnotation): Added method. (getDeclaredAnnotations): Added method. (declaredAnnotations): Added method (inspired by OpenJDK). (getParameterAnnotations): Added method. * src/lib/gnu/java/lang/reflect/Field.java (java.lang.annotation.Annotation): Added import. (java.util.Map): Added import. (sun.refelct.annotation.AnnotationParser): Added import. (declaredAnnotations): Added field (inspired by OpenJDK). (getAnnotation): Added method. (getDeclaredAnnotations): Added method. (declaredAnnotations): Added method (inspired by OpenJDK). * src/lib/gnu/java/lang/reflect/Constructor.java: Copied file from GNU Classpath. (java.lang.annotation.Annotation): Added import. (java.util.Map): Added import. (sun.refelct.annotation.AnnotationParser): Added import. (declaredAnnotations): Added field (inspired by OpenJDK). (getAnnotation): Added method. (getDeclaredAnnotations): Added method. (declaredAnnotations): Added method (inspired by OpenJDK). (getParameterAnnotations): Added method. * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java: Removed. * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: Removed. I figured out which class of GNU Classpath to use to replace this self written class. * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Added a few comments. (sun.reflect.generics.parser.SignatureParser): Removed import. (sun.reflect.generics.parser.SignatureFormatError): Removed import. (gnu.java.lang.reflect.FieldSignatureParser): Added import. (parseParameterAnnotations): Added method. (parseSig): Changed method so it uses GNU Classpaths FieldSignatureParser. * src/lib/Makefile.am (VM_JAVA_FILES): Added $(top_srcdir)/src/lib/gnu/java/lang/reflect/Constructor.java (VM_CLASS_FILES): Added classes/java/lang/reflect/Constructor.class * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): Cache methodinfo for sun.reflect.annotation.AnnotationParser.parseAnnotationsIntoArray. * src/native/vm/gnu/java_lang_reflect_Method.c [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Method_getDefaultValue): Cache methodinfo for sun.reflect.annotation.AnnotationParser.parseDefaultValue. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Method_declaredAnnotations): Added. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Method_getParameterAnnotations): Added. * src/native/vm/gnu/java_lang_reflect_Field.c [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): Added include. [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Field_declaredAnnotations): Added. * src/native/vm/gnu/java_lang_reflect_Constructor.c [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): Added include. [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Constructor_declaredAnnotations): Added. [ENABLE_ANNOTATIONS] (Java_java_lang_reflect_Constructor_getParameterAnnotations): Added. * src/native/vm/reflect.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): Added include. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added. * src/native/vm/reflect.h [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added. * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Implemented (needed by a testcase of mine). * src/vmcore/method.c (method_get_parametercount): Added. This function gets the parameter count of a method (not counting the this pointer of non-static methods). Returns -1 in case of an error. * src/vmcore/method.h (method_get_parametercount): Added. ........ r8263 | twisti | 2007-08-06 16:41:05 +0200 (Mon, 06 Aug 2007) | 3 lines * src/vm/jit/mips/arch.h (SUPPORT_PASS_FLOATARGS_IN_INTREGS): Removed duplicate define. ........ r8264 | twisti | 2007-08-06 18:02:28 +0200 (Mon, 06 Aug 2007) | 33 lines * src/vm/jit/patcher-common.h: Added __MIPS__ for new patcher functions. * src/vm/jit/patcher.h: Added __MIPS__ to include-check. * src/vm/jit/mips/emit.c (vm/jit/patcher-common.h): Added. (emit_patcher_stubs): Removed. (emit_trap): Added. * src/vm/jit/mips/codegen.c (vm/jit/patcher.h): Removed. (vm/jit/patcher-common.h): Added. (codegen_emit): Replaced codegen_add_patch_ref with patcher_add_patch_ref, and emit_patcher_stubs with emit_patcher_traps. (codegen_emit_stub_native): Likewise. * src/vm/jit/mips/codegen.h (PATCHER_CALL_INSTRUCTIONS): Changed to 1. (PATCHER_CALL_SIZE): Changed to 1*4. (PATCHER_NOPS): Emit only one NOP. * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Check for exception, set PC in trap-case. * src/vm/jit/mips/irix/md-os.c (md_signal_handler_sigsegv): Check for exception. * src/vm/jit/mips/patcher.c: Renamed function to new patcher functions, and use patcher references. (vm/jit/patcher.h): Removed. (vm/jit/patcher-common.h): Added (patcher_wrapper): Removed. * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Removed. ........ r8265 | twisti | 2007-08-06 18:10:42 +0200 (Mon, 06 Aug 2007) | 3 lines * src/vm/jit/emit-common.c: Set Id keyword. * src/vm/jit/emit-common.h: Likewise. ........ r8266 | twisti | 2007-08-07 10:26:38 +0200 (Tue, 07 Aug 2007) | 3 lines * src/threads/threads-common.c (threads_preinit): Fixed compiler warning. ........ r8267 | twisti | 2007-08-07 13:07:48 +0200 (Tue, 07 Aug 2007) | 4 lines * src/vm/jit/i386/emit.c (emit_trap): New function. * src/vm/jit/powerpc64/emit.c: Likewise. * src/vm/jit/x86_64/emit.c: Likewise. ........ r8268 | twisti | 2007-08-07 15:24:43 +0200 (Tue, 07 Aug 2007) | 34 lines * src/vmcore/field.c (mm/memory.h): Added. (vm/global.h): Likewise. (field_load): Allocate value memory only for static and final fields. * src/vmcore/field.h (fieldinfo): Made value a pointer. * src/vmcore/loader.c (load_class_from_classbuffer): Allocate fieldinfo's on the C heap. * src/native/jni.c: fieldinfo->value is now a pointer. * src/native/vm/sun_misc_Unsafe.c: Likewise. * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c, src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c: Likewise. ........ r8269 | twisti | 2007-08-07 21:21:33 +0200 (Tue, 07 Aug 2007) | 3 lines * tests/rtMissedIn0: Removed. * tests/rtIn: Likewise. ........ r8270 | twisti | 2007-08-08 15:57:12 +0200 (Wed, 08 Aug 2007) | 49 lines * src/vm/vm.c (vm_array_store_flt): Handle __POWERPC__ correctly. (vm_vmargs_from_valist): Removed. (vm_vmargs_from_jvalue): Likewise. (vm_vmargs_from_objectarray): Likewise. (vm_call_method_vmarg): Likewise. (vm_call_method_int_vmarg): Likewise. (vm_call_method_int_valist): Likewise. (vm_call_method_int_jvalue): Likewise. (vm_call_method_long_vmarg): Likewise. (vm_call_method_long_valist): Likewise. (vm_call_method_long_jvalue): Likewise. (vm_call_method_float_vmarg): Likewise. (vm_call_method_float_valist): Likewise. (vm_call_method_float_jvalue): Likewise. (vm_call_method_double_vmarg): Likewise. (vm_call_method_double_valist): Likewise. (vm_call_method_double_jvalue): Likewise. (vm_call_method_valist): Removed old implementation. (vm_call_method_jvalue): Likewise. * src/vm/vm.h: Removed old prototypes. * src/vm/jit/asmpart.h: Likewise. * src/vm/exceptions.c (exceptions_handle_exception) [__POWERPC__]: Get monitor object correctly (talk to Michi because of ARM). * src/native/jni.c (_Jv_jni_invokeNative): Removed old implementation. * src/vm/jit/powerpc/linux/md-abi.c (md_param_alloc): Use 8-byte stackslots. (md_param_alloc_native): Implemented native ABI. * src/vm/jit/powerpc/emit.c (emit_load): Merged TYPE_FLT and TYPE_DBL. (emit_store): Likewise * src/vm/jit/powerpc/darwin/md-abi.c: Likewise. * src/vm/jit/powerpc/arch.h (HAS_4BYTE_STACKSLOT): Removed. (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY): Likewise. * src/vm/jit/powerpc/codegen.c: Implemented 8-byte stackslots, always load and store float-values as double (PowerPC's internal register representation is the same). * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Use new argument array. (asm_handle_exception): Restore callee-saved registers from the correct location. ........ r8271 | twisti | 2007-08-08 16:07:56 +0200 (Wed, 08 Aug 2007) | 7 lines * src/vm/vm.h (vm_arg): Removed. * src/vm/jit/tools/genoffsets.c (main): Removed sizevmarg, offvmargtype and offvmargdata. * src/vm/jit/m68k/md.c (md_init): Removed some obsolete checks. ........ r8272 | twisti | 2007-08-08 16:55:00 +0200 (Wed, 08 Aug 2007) | 7 lines * src/threads/threads-common.c (stdint.h): Added. (threads_thread_free): Also save and restore the thread state (this is required for CLDC1.1, but is generally a good idea). * src/native/vm/java_lang_Thread.c (isAlive) [WITH_CLASSPATH_CLDC1_1]: Check for NULL. ........ r8273 | twisti | 2007-08-08 17:33:15 +0200 (Wed, 08 Aug 2007) | 8 lines * src/vmcore/class.c (class_isanysubclass): Don't use ASM_GETCLASSVALUES_ATOMIC anymore, we will change that to use the class-renumbering lock. * src/vm/builtin.c (builtin_canstore): Likewise. (builtin_canstore_onedim): Likewise. (builtin_canstore_onedim_class): Likewise. ........ r8274 | twisti | 2007-08-08 17:58:17 +0200 (Wed, 08 Aug 2007) | 45 lines * src/vm/jit/tools: Removed. * configure.ac (AC_CONFIG_FILES): Removed src/vm/jit/tools/Makefile. * src/vm/jit/Makefile.am (DIST_SUBDIRS): Removed tools. (SUBDIRS): Likewise. * src/threads/critical.c (stdint.h): Added. (vm/jit/asmpart.h): Removed. (critical_init): Don't call critical_register_asm_critical_sections. (critical_register_asm_critical_sections): Removed. * src/vm/jit/asmpart.h (ASM_GETCLASSVALUES_ATOMIC): Removed. (asm_criticalsections): Likewise. (asm_getclassvalues_atomic): Likewise. (intrp_asm_getclassvalues_atomic): Likewise. * src/vm/jit/alpha/Makefile.am, src/vm/jit/arm/Makefile.am, src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am, src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am, src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am (BUILT_SOURCES): Removed (CLEANFILES): Likewise. (offsets.h): Likewise. * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S, src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S (offsets.h): Removed. (asm_getclassvalues_atomic): Likewise. (asm_criticalsections): Likewise. * src/vm/jit/powerpc/darwin/md-asm.h (asm_criticalsections): Removed. (asm_getclassvalues_atomic): Likewise. ........ r8275 | twisti | 2007-08-08 18:05:40 +0200 (Wed, 08 Aug 2007) | 12 lines * src/vm/jit/alpha, src/vm/jit/arm, src/vm/jit/i386, src/vm/jit/m68k, src/vm/jit/mips, src/vm/jit/parisc, src/vm/jit/powerpc, src/vm/jit/powerpc64, src/vm/jit/s390, src/vm/jit/sparc64, src/vm/jit/x86_64 (svn:ignore): Removed offsets.h. ........ r8276 | twisti | 2007-08-08 18:09:14 +0200 (Wed, 08 Aug 2007) | 2 lines * src/vm/jit/arm/asmpart.S (offsets.h): Removed. ........ r8277 | michi | 2007-08-08 18:42:11 +0200 (Wed, 08 Aug 2007) | 9 lines * src/vmcore/linker.c (linker_compute_subclasses): Added attention notice about the locking mechanism. * src/vmcore/class.c (class_isanysubclass): Uses linker_classrenumber_lock now. * src/vm/builtin.c (builtin_canstore): Likewise. (builtin_canstore_onedim): Likewise. (builtin_canstore_onedim_class): Likewise. ........ r8278 | michi | 2007-08-08 19:10:18 +0200 (Wed, 08 Aug 2007) | 5 lines * src/vm/jit/s390/emit.c (emit_replacement_stubs): Removed obsolete function. * src/vm/jit/s390/codegen.c (codegen_emit): Do not create replacement stubs. * src/vm/jit/replace.c (replace_me): No longer call asm_replacement_in. * src/vm/jit/asmpart.h [ENABLE_REPLACEMENT]: Removed obsolete prototypes. ........ r8279 | michi | 2007-08-09 11:36:57 +0200 (Thu, 09 Aug 2007) | 7 lines * src/vm/jit/alpha/linux/md-os.c [ENABLE_REPLACEMENT] (md_replace_executionstate_read): Implemented. [ENABLE_REPLACEMENT] (md_replace_executionstate_write): Likewise. * src/vm/jit/alpha/asmpart.S (asm_replacement_out): Removed. (asm_replacement_in): Likewise. ........ r8280 | twisti | 2007-08-09 13:28:51 +0200 (Thu, 09 Aug 2007) | 2 lines * NEWS: Added 0.99 release and some news. ........ r8281 | twisti | 2007-08-09 14:09:17 +0200 (Thu, 09 Aug 2007) | 2 lines * NEWS: Added news. ........ r8282 | twisti | 2007-08-09 14:18:47 +0200 (Thu, 09 Aug 2007) | 7 lines * src/vm/signal.c (vm/types.h): Removed. (signal_init): Use signal_register_signal. (signal_register_signal): New function. * src/vm/signallocal.h (vm/types.h): Removed. (signal_register_signal): New function. ........ r8283 | twisti | 2007-08-09 17:10:05 +0200 (Thu, 09 Aug 2007) | 30 lines * src/vm/exceptions.c (toolbox/logging.h): Removed. (vm/jit/disass.h): Likewise. (exceptions_new_hardware_exception): Likewise. * src/vm/exceptions.h (exceptions_new_hardware_exception): Likewise. * src/vm/signal.c (stdint.h): Added. (toolbox/logging.h): Likewise. (vm/jit/codegen-common.h): Likewise. (vm/jit/disass.h): Likewise. (vm/jit/patcher-common.h): Likewise. (signal_handle): New function. * src/vm/signallocal.h (signal_handle): Likewise. * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md-os.c: Use new signal_handle function. ........ r8284 | michi | 2007-08-10 10:58:39 +0200 (Fri, 10 Aug 2007) | 26 lines * src/native/llni.h: Added LLNI (low level native interface). Use LLNI macros throughout the whole codebase: * src/vm/jit/stacktrace.c * src/vm/string.c * src/vm/builtin.c * src/vm/exceptions.c * src/vm/vm.c * src/native/jni.c * src/native/vm/java_lang_ClassLoader.c * src/native/vm/java_lang_Class.c * src/native/vm/java_lang_String.c * src/native/vm/java_lang_Object.c * src/native/vm/gnu/java_lang_VMThread.c * src/native/vm/gnu/java_lang_reflect_Method.c * src/native/vm/gnu/java_lang_reflect_Field.c * src/native/vm/gnu/java_lang_reflect_Constructor.c * src/native/vm/gnu/java_lang_VMThrowable.c * src/native/vm/java_lang_Thread.c * src/native/vm/sun_misc_Unsafe.c * src/native/vm/reflect.c * src/native/vm/java_lang_reflect_Method.c * src/native/vm/java_lang_reflect_Constructor.c * src/threads/threads-common.c * src/threads/native/threads.c ........ r8285 | michi | 2007-08-10 11:20:04 +0200 (Fri, 10 Aug 2007) | 5 lines * src/native/vm/gnu/java_lang_reflect_Method.c: Fixed merge problem in previous revision 8284. * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. ........ r8286 | michi | 2007-08-10 12:46:17 +0200 (Fri, 10 Aug 2007) | 9 lines * src/vm/jit/powerpc/patcher.c (patcher_get_putfield): Fixed severe bug for unalligned long field offsets. * src/vmcore/linker.c [__POWERPC__ && __DARWIN__]: Long fields are 4-byte alligned in structs. * src/vm/jit/patcher-common.c [TRACE_PATCHER]: Left patcher trace code hanging around, might come handy again. ........ r8287 | twisti | 2007-08-10 17:10:29 +0200 (Fri, 10 Aug 2007) | 2 lines * src/native/jni.c (_Jv_JNI_FromReflectedField): Added missing ;. ........ r8288 | twisti | 2007-08-10 17:12:00 +0200 (Fri, 10 Aug 2007) | 34 lines * src/vmcore/primitive.c: Removed. * src/vmcore/primitive.h: Likewise. * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Removed primitive.[ch]. * src/vmcore/primitivecore.c: New file. * src/vm/primitive.c: Likwise. * src/vm/primitive.h: Likewise. * src/vm/Makefile.am (libvm_la_SOURCES): Added primitive.[ch]. * src/cacaoh/dummy.c (vm/primitive.h): Added. (primitive_class_get_by_type): New function. (primitive_class_get_by_char): Likewise. * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c, src/native/vm/gnu/java_lang_reflect_Field.c, src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, src/vm/builtin.c, src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, src/vm/resolve.c, src/vm/string.c, src/vm/vm.c, src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/linker.c, src/vmcore/loader.c: Changed primitive.h include. ........ r8289 | twisti | 2007-08-10 17:18:05 +0200 (Fri, 10 Aug 2007) | 3 lines * src/native/vm/reflect.c (reflect_field_new): Fixed compilation. (reflect_method_new): Likewise. ........ r8290 | twisti | 2007-08-11 12:25:40 +0200 (Sat, 11 Aug 2007) | 6 lines * src/native/vm/sun/jvm.c (JVM_GC): Call GC-call directly, use TRACEJVMCALLS. (JVM_TotalMemory): Likewise. (JVM_FreeMemory): Likewise. (JVM_NewArray): Use TRACEJVMCALLS. ........ r8291 | twisti | 2007-08-11 12:43:45 +0200 (Sat, 11 Aug 2007) | 41 lines * src/vm/primitive.c (native/jni.h): Added. (native/llni.h): Likewise. (native/include/java_lang_Boolean.h, native/include/java_lang_Byte.h, native/include/java_lang_Short.h, native/include/java_lang_Character.h, native/include/java_lang_Integer.h, native/include/java_lang_Long.h, native/include/java_lang_Float.h, native/include/java_lang_Double.h): Likewise. (vm/builtin.h): Likewise. (vm/vm.h): Likewise. (primitive_box): New function. (primitive_unbox): Likewise. (PRIMITIVE_BOX_TYPE): New macro for primitive_box_xxx functions. (PRIMITIVE_UNBOX_TYPE): New macro for primitive_unbox_xxx functions. * src/vm/primitive.h (primitive_box): Added. (primitive_unbox): Likewise. (primitive_box_boolean, primitive_box_byte, primitive_box_char, primitive_box_short, primitive_box_int, primitive_box_long, primitive_box_float, primitive_box_double): Likewise. (primitive_unbox_boolean, primitive_unbox_byte, primitive_unbox_char, primitive_unbox_short, primitive_unbox_int, primitive_unbox_long, primitive_unbox_float, primitive_unbox_double): Likewise. * src/native/jni.c (_Jv_jni_invokeNative): Use primitive-box functions. * src/native/vm/gnu/java_lang_reflect_Field.c (get): Likewise. ........ r8292 | twisti | 2007-08-11 14:39:28 +0200 (Sat, 11 Aug 2007) | 13 lines * src/vm/vm.c (VM_CALL_METHOD): New macro. (VM_CALL_METHOD_VALIST): Likewise. (VM_CALL_METHOD_JVALUE): Likewise. (VM_CALL_ARRAY): Likewise. * src/vm/vm.h (vm_call_method_int): Changed return type to stdint-type. (vm_call_method_int_valist): Likewise. (vm_call_method_int_jvalue): Likewise. (vm_call_method_long): Likewise. (vm_call_method_long_valist): Likewise. (vm_call_method_long_jvalue): Likewise. ........ r8293 | twisti | 2007-08-11 14:40:22 +0200 (Sat, 11 Aug 2007) | 2 lines * src/vm/vm.h: Set Id keyword. ........ r8294 | ajordan | 2007-08-11 15:42:25 +0200 (Sat, 11 Aug 2007) | 6 lines * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): Fixed pending issue from regoff change. * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Likewise. * src/vm/jit/sparc64/emit.c (emit_trap): Added. ........ r8295 | michi | 2007-08-11 19:57:24 +0200 (Sat, 11 Aug 2007) | 106 lines * src/vm/global.h (java_handle_t): Added typedef. (java_object_t): New name for what was formerly known as java_objectheader. Adapted to above changes and decided where to use handles: * src/vm/initialize.c * src/vm/properties.h * src/vm/jit/arm/codegen.c * src/vm/jit/powerpc/codegen.c * src/vm/jit/codegen-common.h * src/vm/jit/sparc64/codegen.c * src/vm/jit/sparc64/patcher.c * src/vm/jit/alpha/codegen.c * src/vm/jit/optimizing/recompile.c * src/vm/jit/patcher-common.c * src/vm/jit/s390/codegen.c * src/vm/jit/show.c * src/vm/jit/patcher-common.h * src/vm/jit/mips/codegen.c * src/vm/jit/patcher.h * src/vm/jit/m68k/codegen.c * src/vm/jit/powerpc64/codegen.c * src/vm/jit/i386/codegen.c * src/vm/jit/i386/patcher.c * src/vm/jit/replace.c * src/vm/jit/asmpart.h * src/vm/jit/x86_64/codegen.c * src/vm/jit/x86_64/patcher.c * src/vm/jit/replace.h * src/vm/jit/stacktrace.c * src/vm/jit/stacktrace.h * src/vm/jit/codegen-common.c * src/vm/jit/jit.h * src/vm/builtin.c * src/vm/string.c * src/vm/primitive.c * src/vm/builtin.h * src/vm/signal.c * src/vm/primitive.h * src/vm/exceptions.c * src/vm/vm.c * src/vm/finalizer.c * src/vm/exceptions.h * src/vm/stringlocal.h * src/vm/vm.h * src/vm/properties.c * src/native/jni.c * src/native/vm/java_lang_ClassLoader.c * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c * src/native/vm/cldc1.1/java_lang_Class.c * src/native/vm/cldc1.1/java_lang_String.c * src/native/vm/cldc1.1/java_lang_Object.c * src/native/vm/cldc1.1/java_lang_System.c * src/native/vm/cldc1.1/java_lang_Throwable.c * src/native/vm/java_lang_Class.c * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c * src/native/vm/gnu/java_lang_VMClassLoader.c * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c * src/native/vm/gnu/java_lang_reflect_Method.c * src/native/vm/gnu/java_lang_VMRuntime.c * src/native/vm/gnu/gnu_classpath_VMStackWalker.c * src/native/vm/gnu/java_lang_reflect_Field.c * src/native/vm/gnu/java_lang_reflect_Constructor.c * src/native/vm/gnu/java_lang_VMThrowable.c * src/native/vm/java_lang_Object.c * src/native/vm/java_lang_String.c * src/native/vm/java_lang_Thread.c * src/native/vm/sun_misc_Unsafe.c * src/native/vm/sun/jvm.c * src/native/vm/reflect.c * src/native/vm/java_lang_Runtime.c * src/native/vm/java_lang_reflect_Method.c * src/native/vm/reflect.h * src/native/vm/java_lang_Runtime.h * src/native/vm/java_lang_reflect_Constructor.c * src/native/jni.h * src/native/native.c * src/native/native.h * src/toolbox/hashtable.h * src/toolbox/util.c * src/toolbox/list.h * src/toolbox/avl.c * src/toolbox/avl.h * src/toolbox/hashtable.c * src/mm/memory.c * src/threads/none/threads.h * src/threads/threads-common.c * src/threads/lock-common.h * src/threads/native/threads.h * src/threads/native/lock.c * src/threads/native/threads.c * src/threads/native/lock.h * src/vmcore/class.c * src/vmcore/loader.c * src/vmcore/suck.h * src/vmcore/class.h * src/vmcore/loader.h * src/vmcore/method.c * src/vmcore/method.h * src/vmcore/classcache.c * src/vmcore/classcache.h * src/vmcore/linker.c * src/vmcore/linker.h * src/cacaoh/headers.h * src/cacaoh/dummy.c * src/cacaoh/headers.c ........ r8296 | pm | 2007-08-12 00:38:38 +0200 (Sun, 12 Aug 2007) | 11 lines * src/vm/exceptions.c (exceptions_handle_exception) [__S390__]: Synchronization object is at SP - IsSync - 8. * src/vm/vm.c (vm_array_store_flt) [__S390__]: Float value is in bytes 4-7 of uint64_t. * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-asm.h: Changed a lot for 8 byte stackslots. ........ r8297 | michi | 2007-08-12 02:02:48 +0200 (Sun, 12 Aug 2007) | 35 lines * src/native/localref.c: Added new file. * src/native/localref.h: Likewise. * src/native/Makefile.am: Added above two files. * src/vm/jit/codegen-common.c (codegen_start_native_call) (codegen_finish_native_call): Use separate function to deal with localrefs. * src/native/jni.h: Moved localref stuff to own file. * src/native/jni.c: Likewise. (JNI_CALL_VIRTUAL_METHOD): Added new macro. (JNI_CALL_NONVIRTUAL_METHOD): Likewise. (JNI_GET_FIELD): Likewise. (JNI_SET_FIELD): Likewise. (JNI_CALL_STATIC_METHOD): Likewise. (JNI_GET_STATIC_FIELD): Likewise. (JNI_SET_STATIC_FIELD): Likewise. (JNI_NEW_ARRAY): Likewise. (JNI_GET_ARRAY_ELEMENTS): Likewise. (JNI_RELEASE_ARRAY_ELEMENTS): Likewise. (JNI_GET_ARRAY_REGION): Likewise. (JNI_SET_ARRAY_REGION): Likewise. * src/threads/native/threads.h, * src/vm/jit/arm/codegen.c, * src/vm/jit/powerpc/codegen.c, * src/vm/jit/sparc64/codegen.c, * src/vm/jit/alpha/codegen.c, * src/vm/jit/s390/codegen.c, * src/vm/jit/mips/codegen.c, * src/vm/jit/m68k/codegen.c, * src/vm/jit/powerpc64/codegen.c, * src/vm/jit/i386/codegen.c, * src/vm/jit/x86_64/codegen.c: Added missing include. ........ r8298 | pm | 2007-08-12 20:49:16 +0200 (Sun, 12 Aug 2007) | 7 lines * src/vm/jit/dseg.c (dseg_get_linenumber_from_pc) [__S390__]: Clear most significant bit of passed pc parameter. * src/vm/jit/s390/asmpart.S (asm_handle_exception): Rewritten to be wrapper for md_handle_exception. * src/vm/jit/s390/md.c (md_handle_exception): New function. * src/vm/jit/s390/md-abi.h (FLT_SAV_CNT): 2, (FLT_RES_CNT): 0. * src/vm/jit/s390/md-abi.c (abi_registers_float_saved): Added f4 and f6, (nregdescfloat): Made f4 and f6 saved registers. ........ --HG-- branch : exact-gc --- NEWS | 9 + configure.ac | 23 +- m4/ac_prog_javac.m4 | 4 +- m4/classpath.m4 | 18 +- src/cacaoh/dummy.c | 34 +- src/cacaoh/headers.c | 8 +- src/cacaoh/headers.h | 7 +- src/lib/Makefile.am | 25 +- src/mm/memory.c | 12 +- src/native/Makefile.am | 6 +- src/native/include/Makefile.am | 7 +- src/native/jni.c | 4378 ++++------------- src/native/jni.h | 40 +- src/native/localref.c | 285 ++ src/native/native.c | 23 +- src/native/native.h | 11 +- .../vm/cldc1.1/com_sun_cldchi_jvm_JVM.c | 2 +- src/native/vm/cldc1.1/java_lang_Class.c | 4 +- src/native/vm/cldc1.1/java_lang_Object.c | 6 +- src/native/vm/cldc1.1/java_lang_String.c | 2 +- src/native/vm/cldc1.1/java_lang_System.c | 10 +- src/native/vm/cldc1.1/java_lang_Throwable.c | 4 +- src/native/vm/gnu/Makefile.am | 10 +- .../vm/gnu/gnu_classpath_VMStackWalker.c | 16 +- .../vm/gnu/gnu_classpath_VMSystemProperties.c | 10 +- ..._java_lang_management_VMMemoryMXBeanImpl.c | 2 +- src/native/vm/gnu/java_lang_VMClass.c | 7 +- src/native/vm/gnu/java_lang_VMClassLoader.c | 14 +- src/native/vm/gnu/java_lang_VMRuntime.c | 18 +- src/native/vm/gnu/java_lang_VMThread.c | 57 +- src/native/vm/gnu/java_lang_VMThrowable.c | 22 +- .../vm/gnu/java_lang_reflect_Constructor.c | 67 +- src/native/vm/gnu/java_lang_reflect_Field.c | 364 +- src/native/vm/gnu/java_lang_reflect_Method.c | 167 +- src/native/vm/java_lang_Class.c | 126 +- src/native/vm/java_lang_Class.h | 2 +- src/native/vm/java_lang_ClassLoader.c | 7 +- src/native/vm/java_lang_Object.c | 22 +- src/native/vm/java_lang_Runtime.c | 6 +- src/native/vm/java_lang_Runtime.h | 4 +- src/native/vm/java_lang_Thread.c | 38 +- src/native/vm/java_lang_reflect_Method.c | 14 +- src/native/vm/nativevm.c | 4 + src/native/vm/nativevm.h | 4 + src/native/vm/sun_misc_Unsafe.c | 33 +- src/threads/critical.c | 28 +- src/threads/native/lock.c | 34 +- src/threads/native/lock.h | 10 +- src/threads/native/threads.c | 69 +- src/threads/native/threads.h | 5 +- src/threads/none/threads.h | 2 +- src/threads/threads-common.c | 52 +- src/toolbox/avl.c | 4 +- src/toolbox/avl.h | 4 +- src/toolbox/hashtable.c | 8 +- src/toolbox/hashtable.h | 4 +- src/toolbox/list.h | 4 +- src/toolbox/util.c | 4 +- src/vm/Makefile.am | 4 +- src/vm/builtin.c | 141 +- src/vm/builtin.h | 20 +- src/vm/exceptions.c | 269 +- src/vm/exceptions.h | 44 +- src/vm/finalizer.c | 10 +- src/vm/global.h | 23 +- src/vm/initialize.c | 6 +- src/vm/jit/Makefile.am | 4 +- src/vm/jit/alpha/Makefile.am | 19 +- src/vm/jit/alpha/arch.h | 3 +- src/vm/jit/alpha/asmpart.S | 284 +- src/vm/jit/alpha/codegen.c | 21 +- src/vm/jit/alpha/emit.c | 44 +- src/vm/jit/alpha/linux/md-os.c | 114 +- src/vm/jit/alpha/md.c | 10 +- src/vm/jit/alpha/patcher.c | 4 +- src/vm/jit/arm/Makefile.am | 19 +- src/vm/jit/arm/arch.h | 3 +- src/vm/jit/arm/asmpart.S | 32 +- src/vm/jit/arm/codegen.c | 71 +- src/vm/jit/arm/emit.c | 41 +- src/vm/jit/arm/linux/md-os.c | 69 +- src/vm/jit/arm/patcher.c | 5 +- src/vm/jit/asmpart.h | 74 +- src/vm/jit/codegen-common.c | 68 +- src/vm/jit/codegen-common.h | 4 +- src/vm/jit/dseg.c | 6 +- src/vm/jit/emit-common.c | 51 +- src/vm/jit/emit-common.h | 4 +- src/vm/jit/i386/Makefile.am | 19 +- src/vm/jit/i386/arch.h | 3 +- src/vm/jit/i386/asmpart.S | 39 +- src/vm/jit/i386/codegen.c | 67 +- src/vm/jit/i386/darwin/md-os.c | 52 +- src/vm/jit/i386/emit.c | 23 +- src/vm/jit/i386/linux/md-os.c | 73 +- src/vm/jit/i386/md.c | 10 +- src/vm/jit/i386/patcher.c | 15 +- src/vm/jit/jit.h | 4 +- src/vm/jit/m68k/Makefile.am | 52 +- src/vm/jit/m68k/asmpart.S | 71 +- src/vm/jit/m68k/codegen.c | 45 +- src/vm/jit/m68k/linux/md-os.c | 24 +- src/vm/jit/m68k/md.c | 3 - src/vm/jit/m68k/patcher.c | 3 +- src/vm/jit/mips/Makefile.am | 13 +- src/vm/jit/mips/arch.h | 4 +- src/vm/jit/mips/asmpart.S | 143 +- src/vm/jit/mips/codegen.c | 99 +- src/vm/jit/mips/codegen.h | 10 +- src/vm/jit/mips/emit.c | 157 +- src/vm/jit/mips/irix/md-os.c | 50 +- src/vm/jit/mips/linux/md-os.c | 63 +- src/vm/jit/mips/md.c | 19 +- src/vm/jit/mips/patcher.c | 647 +-- src/vm/jit/optimizing/recompile.c | 6 +- src/vm/jit/patcher.h | 6 +- src/vm/jit/powerpc/Makefile.am | 22 +- src/vm/jit/powerpc/arch.h | 7 +- src/vm/jit/powerpc/asmpart.S | 578 +-- src/vm/jit/powerpc/codegen.c | 166 +- src/vm/jit/powerpc/darwin/md-abi.c | 144 +- src/vm/jit/powerpc/darwin/md-asm.h | 5 +- src/vm/jit/powerpc/darwin/md-os.c | 47 +- src/vm/jit/powerpc/emit.c | 47 +- src/vm/jit/powerpc/linux/md-abi.c | 145 +- src/vm/jit/powerpc/linux/md-os.c | 83 +- src/vm/jit/powerpc/md.c | 10 +- src/vm/jit/powerpc/patcher.c | 7 +- src/vm/jit/powerpc64/Makefile.am | 19 +- src/vm/jit/powerpc64/arch.h | 3 +- src/vm/jit/powerpc64/asmpart.S | 40 +- src/vm/jit/powerpc64/codegen.c | 20 +- src/vm/jit/powerpc64/emit.c | 45 +- src/vm/jit/powerpc64/linux/md-os.c | 50 +- src/vm/jit/powerpc64/md.c | 10 +- src/vm/jit/powerpc64/patcher.c | 5 +- src/vm/jit/replace.c | 52 +- src/vm/jit/replace.h | 14 +- src/vm/jit/s390/Makefile.am | 24 +- src/vm/jit/s390/arch.h | 5 +- src/vm/jit/s390/asmpart.S | 674 +-- src/vm/jit/s390/codegen.c | 296 +- src/vm/jit/s390/codegen.h | 28 +- src/vm/jit/s390/emit.c | 273 +- src/vm/jit/s390/md-abi.c | 54 +- src/vm/jit/s390/md-abi.h | 8 +- src/vm/jit/s390/md-asm.h | 3 +- src/vm/jit/s390/md.c | 244 +- src/vm/jit/s390/patcher.c | 386 +- src/vm/jit/show.c | 6 +- src/vm/jit/sparc64/Makefile.am | 18 +- src/vm/jit/sparc64/arch.h | 1 - src/vm/jit/sparc64/asmpart.S | 36 +- src/vm/jit/sparc64/codegen.c | 52 +- src/vm/jit/sparc64/emit.c | 23 +- src/vm/jit/sparc64/linux/md-os.c | 33 +- src/vm/jit/sparc64/md-abi.c | 16 +- src/vm/jit/sparc64/md.c | 13 +- src/vm/jit/sparc64/patcher.c | 11 +- src/vm/jit/sparc64/solaris/md-os.c | 57 +- src/vm/jit/stacktrace.c | 19 +- src/vm/jit/stacktrace.h | 4 +- src/vm/jit/tools/Makefile.am | 46 - src/vm/jit/tools/genoffsets.c | 100 - src/vm/jit/verify/typecheck-stackbased.c | 3 +- src/vm/jit/verify/typecheck-typeinferer.c | 2 +- src/vm/jit/verify/typecheck.c | 4 +- src/vm/jit/verify/typeinfo.c | 4 +- src/vm/jit/x86_64/Makefile.am | 13 +- src/vm/jit/x86_64/arch.h | 3 +- src/vm/jit/x86_64/asmpart.S | 29 +- src/vm/jit/x86_64/codegen.c | 21 +- src/vm/jit/x86_64/emit.c | 23 +- src/vm/jit/x86_64/linux/md-os.c | 69 +- src/vm/jit/x86_64/md.c | 14 +- src/vm/jit/x86_64/patcher.c | 35 +- src/vm/properties.c | 18 +- src/vm/properties.h | 6 +- src/vm/resolve.c | 4 +- src/vm/signal.c | 156 +- src/vm/signallocal.h | 10 +- src/vm/string.c | 105 +- src/vm/stringlocal.h | 24 +- src/vm/vm.c | 1561 +----- src/vm/vm.h | 83 +- src/vmcore/Makefile.am | 5 +- src/vmcore/annotation.c | 543 +- src/vmcore/annotation.h | 67 +- src/vmcore/class.c | 51 +- src/vmcore/class.h | 21 +- src/vmcore/classcache.c | 6 +- src/vmcore/descriptor.c | 4 +- src/vmcore/field.c | 160 +- src/vmcore/field.h | 11 +- src/vmcore/linker.c | 20 +- src/vmcore/linker.h | 4 +- src/vmcore/loader.c | 46 +- src/vmcore/method.c | 137 +- src/vmcore/method.h | 11 +- src/vmcore/primitive.c | 282 -- src/vmcore/primitive.h | 129 - src/vmcore/suck.h | 4 +- src/vmcore/utf8.c | 30 +- src/vmcore/utf8.h | 21 +- tests/rtIn/at/dms/kjc/Main | 8 - tests/rtMissedIn0 | 10 - 206 files changed, 6216 insertions(+), 10837 deletions(-) create mode 100644 src/native/localref.c delete mode 100644 src/vm/jit/tools/Makefile.am delete mode 100644 src/vm/jit/tools/genoffsets.c delete mode 100644 src/vmcore/primitive.c delete mode 100644 src/vmcore/primitive.h delete mode 100644 tests/rtIn/at/dms/kjc/Main delete mode 100644 tests/rtMissedIn0 diff --git a/NEWS b/NEWS index 78c54a060..737fbc2ea 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ +New in release 0.99 (August x, 2007) + + * Initial support to use OpenJDK as Java core library. + * Fixed memory leak in Boehm-GC. + * Use 8-byte stack-slots on all architectures. + * Faster C-to-Java calls. + * Removed genoffsets, cross-compilation is now much easier. + + New in release 0.98 (June 6, 2007) * ARM and MIPS32 code generators are now open-source. diff --git a/configure.ac b/configure.ac index 076094b27..169eb6074 100644 --- a/configure.ac +++ b/configure.ac @@ -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 8163 2007-06-29 18:53:55Z twisti $ +dnl $Id: configure.ac 8274 2007-08-08 15:58:17Z twisti $ dnl Process this file with autoconf to produce a configure script. @@ -850,6 +850,9 @@ AM_CONDITIONAL([ENABLE_STATICVM], test x"${ENABLE_STATICVM}" = "xyes") AC_SUBST(ENABLE_STATICVM) +AC_CHECK_ENABLE_ANNOTATIONS + + dnl where is CACAO's vm.zip AC_MSG_CHECKING(where CACAO's vm.zip is installed) AC_ARG_WITH([vm-zip], @@ -906,8 +909,19 @@ AC_SUBST(WITH_STATIC_CLASSPATH) dnl check for some programs we need -AC_PROG_JAVAC -AC_PROG_JAR + +case "${WITH_CLASSPATH}" in + cldc1.1 | gnu) + AC_PROG_JAVAC + AC_PROG_JAR + ;; + sun) + ;; + *) + AC_MSG_ERROR(unknown classpath configuration ${WITH_CLASSPATH}) + ;; +esac + AC_CHECK_HEADERS( [regex.h], @@ -996,7 +1010,6 @@ AC_CONFIG_FILES([Makefile] [src/vm/jit/sparc64/Makefile] [src/vm/jit/sparc64/linux/Makefile] [src/vm/jit/sparc64/solaris/Makefile] - [src/vm/jit/tools/Makefile] [src/vm/jit/verify/Makefile] [src/vm/jit/x86_64/Makefile] [src/vm/jit/x86_64/freebsd/Makefile] @@ -1011,7 +1024,7 @@ AC_CONFIG_FILES([Makefile] [tests/regression/resolving/classes1/Makefile] [tests/regression/resolving/classes2/Makefile] [tests/regression/resolving/classes3/Makefile] - ) +) dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS diff --git a/m4/ac_prog_javac.m4 b/m4/ac_prog_javac.m4 index 74d2e4571..caa71e53a 100644 --- a/m4/ac_prog_javac.m4 +++ b/m4/ac_prog_javac.m4 @@ -37,9 +37,9 @@ dnl @license GPLWithACException AC_DEFUN([AC_PROG_JAVAC],[ AC_REQUIRE([AC_EXEEXT])dnl if test "x$JAVAPREFIX" = x; then - test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES} -1.5" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}") + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}") else - test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES} -1.5" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}", $JAVAPREFIX) + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}", $JAVAPREFIX) fi test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) AC_PROG_JAVAC_WORKS diff --git a/m4/classpath.m4 b/m4/classpath.m4 index 700c9685c..2b11adc8d 100644 --- a/m4/classpath.m4 +++ b/m4/classpath.m4 @@ -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: classpath.m4 8133 2007-06-22 13:29:38Z twisti $ +dnl $Id: classpath.m4 8248 2007-07-31 12:47:11Z twisti $ dnl which Java core library should we use @@ -80,9 +80,19 @@ dnl where are Java core library classes installed AC_DEFUN([AC_CHECK_WITH_CLASSPATH_CLASSES],[ AC_MSG_CHECKING(where Java core library classes are installed) AC_ARG_WITH([classpath-classes], - [AS_HELP_STRING(--with-classpath-classes=,path to Java core library classes (includes the name of the file and may be flat) [[default=/usr/local/classpath/share/classpath/glibj.zip]])], + [AS_HELP_STRING(--with-classpath-classes=,path to Java core library classes (includes the name of the file and may be flat) [[default=CLASSPATH_PREFIX/{share/classpath/glibj.zip,classes}]])], [CLASSPATH_CLASSES=${withval}], - [CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip]) + [case "${WITH_CLASSPATH}" in + gnu) + CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip + ;; + sun) + CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/classes + ;; + *) + CLASSPATH_CLASSES=${CLASSPATH_PREFIX} + ;; + esac]) AC_MSG_RESULT(${CLASSPATH_CLASSES}) AC_DEFINE_UNQUOTED([CLASSPATH_CLASSES], "${CLASSPATH_CLASSES}", [Java core library classes]) AC_SUBST(CLASSPATH_CLASSES) @@ -94,7 +104,7 @@ dnl where are Java core library native libraries installed AC_DEFUN([AC_CHECK_WITH_CLASSPATH_LIBDIR],[ AC_MSG_CHECKING(where Java core library native libraries are installed) AC_ARG_WITH([classpath-libdir], - [AS_HELP_STRING(--with-classpath-libdir=,installation directory of Java core library native libraries [[default=/usr/local/classpath/lib]])], + [AS_HELP_STRING(--with-classpath-libdir=,installation directory of Java core library native libraries [[default=CLASSPATH_PREFIX/lib]])], [CLASSPATH_LIBDIR=${withval}], [CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib]) AC_MSG_RESULT(${CLASSPATH_LIBDIR}) diff --git a/src/cacaoh/dummy.c b/src/cacaoh/dummy.c index 0473dfab7..285e11d6b 100644 --- a/src/cacaoh/dummy.c +++ b/src/cacaoh/dummy.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: dummy.c 8245 2007-07-31 09:55:04Z michi $ + $Id: dummy.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -38,6 +38,7 @@ #include "toolbox/logging.h" #include "vm/global.h" +#include "vm/primitive.h" #include "vm/vm.h" #include "vmcore/class.h" @@ -52,7 +53,7 @@ char *_Jv_bootclasspath; -java_objectheader *javastring_new_slash_to_dot(utf *u) +java_handle_t *javastring_new_slash_to_dot(utf *u) { vm_abort("javastring_new_slash_to_dot"); @@ -101,7 +102,7 @@ void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out /* builtin ********************************************************************/ -java_objectheader *builtin_clone(void *env, java_objectheader *o) +java_handle_t *builtin_clone(void *env, java_handle_t *o) { abort(); @@ -115,7 +116,7 @@ int32_t builtin_isanysubclass(classinfo *sub, classinfo *super) return 0; } -java_objectheader *builtin_new(classinfo *c) +java_handle_t *builtin_new(classinfo *c) { abort(); @@ -405,16 +406,16 @@ void jit_invalidate_code(methodinfo *m) /* lock ***********************************************************************/ -void lock_init_object_lock(java_objectheader *o) +void lock_init_object_lock(java_object_t *o) { } -bool lock_monitor_enter(java_objectheader *o) +bool lock_monitor_enter(java_object_t *o) { return true; } -bool lock_monitor_exit(java_objectheader *o) +bool lock_monitor_exit(java_object_t *o) { return true; } @@ -465,6 +466,21 @@ int32_t dump_size(void) } +/* primitive ******************************************************************/ + +classinfo *primitive_class_get_by_type(int type) +{ + abort(); + return NULL; +} + +classinfo *primitive_class_get_by_char(char ch) +{ + abort(); + return NULL; +} + + /* properties *****************************************************************/ void properties_add(char *key, char *value) @@ -621,7 +637,7 @@ void vm_abort(const char *text, ...) abort(); } -java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...) +java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...) { return NULL; } @@ -634,7 +650,7 @@ void stringtable_update(void) log_println("stringtable_update: REMOVE ME!"); } -java_objectheader *literalstring_new(utf *u) +java_object_t *literalstring_new(utf *u) { log_println("literalstring_new: REMOVE ME!"); diff --git a/src/cacaoh/headers.c b/src/cacaoh/headers.c index 1016e30fd..2e597df29 100644 --- a/src/cacaoh/headers.c +++ b/src/cacaoh/headers.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: headers.c 8123 2007-06-20 23:50:55Z michi $ + $Id: headers.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -201,7 +201,7 @@ static char *printtype(char *utf_ptr) break; case 'L': - addoutputsize ( sizeof(java_objectheader*)); + addoutputsize ( sizeof(java_object_t*)); fprintf (file, "struct "); while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c); fprintf (file, "*"); @@ -241,8 +241,8 @@ static void printfields(classinfo *c) int ident_count; if (!c) { - addoutputsize(sizeof(java_objectheader)); - fprintf(file, " java_objectheader header;\n"); + addoutputsize(sizeof(java_object_t)); + fprintf(file, " java_object_t header;\n"); return; } diff --git a/src/cacaoh/headers.h b/src/cacaoh/headers.h index e12c74de1..a404eff6b 100644 --- a/src/cacaoh/headers.h +++ b/src/cacaoh/headers.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: headers.h 7246 2007-01-29 18:49:05Z twisti $ + $Id: headers.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -42,7 +42,8 @@ /* export variables ***********************************************************/ -extern java_objectheader *_exceptionptr; +#warning object or handle??? +extern java_object_t *_exceptionptr; extern chain *nativemethod_chain; extern chain *nativeclass_chain; extern chain *ident_chain; @@ -53,7 +54,7 @@ extern FILE *file; void printID(utf *u); void printOverloadPart(utf *desc); -void literalstring_free(java_objectheader *o); +void literalstring_free(java_object_t *o); void printmethod(methodinfo *m); void gen_header_filename(char *buffer, utf *u); void headerfile_generate(classinfo *c, char *opt_directory); diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index efa9fb2dd..af5834f98 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 8132 2007-06-22 11:15:47Z twisti $ +## $Id: Makefile.am 8262 2007-08-06 12:44:01Z panzi $ ## Process this file with automake to produce Makefile.in @@ -40,6 +40,7 @@ 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/lang/reflect/Constructor.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 \ @@ -54,11 +55,31 @@ VM_CLASS_FILES = \ classes/java/lang/VMString.class \ classes/java/lang/VMThread.class \ classes/java/lang/VMThrowable.class \ + classes/java/lang/reflect/Constructor.class \ classes/java/lang/reflect/Field.class \ classes/java/lang/reflect/Method.class \ classes/java/security/VMAccessController.class \ classes/sun/misc/Unsafe.class +if WITH_CLASSPATH_GNU +if ENABLE_ANNOTATIONS +VM_JAVA_FILES += \ + $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java \ + $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java \ + $(top_srcdir)/src/lib/gnu/sun/reflect/ConstantPool.java \ + $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/AnnotationType.java \ + $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/AnnotationParser.java + +VM_CLASS_FILES += \ + classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.class \ + classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.class \ + classes/sun/reflect/ConstantPool.class \ + classes/sun/reflect/annotation/AnnotationType.class \ + classes/sun/reflect/annotation/AnnotationParser.class +endif +endif + + if ENABLE_ZLIB pkgdata_DATA = vm.zip @@ -66,7 +87,7 @@ VM_ZIP = ../vm.zip vm.zip: $(VM_JAVA_FILES) $(mkdir_p) classes - $(JAVAC) -d classes $(VM_JAVA_FILES) + $(JAVAC) -source 1.5 -target 1.5 -d classes $(VM_JAVA_FILES) @if test "$(JAR)" = "zip" -o "$(JAR)" = "zip.exe"; then \ cd classes && $(JAR) -r -D $(VM_ZIP) .; \ else \ diff --git a/src/mm/memory.c b/src/mm/memory.c index 26c2aea73..d4ad804a2 100644 --- a/src/mm/memory.c +++ b/src/mm/memory.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: memory.c 8123 2007-06-20 23:50:55Z michi $ + $Id: memory.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -91,11 +91,11 @@ static dumpinfo_t _no_threads_dumpinfo; #define DEFAULT_CODE_MEMORY_SIZE 128 * 1024 /* defaulting to 128kB */ #if defined(ENABLE_THREADS) -static java_objectheader *lock_code_memory = NULL; +static java_object_t *lock_code_memory = NULL; #endif -static void *code_memory = NULL; -static int code_memory_size = 0; -static int pagesize = 0; +static void *code_memory = NULL; +static int code_memory_size = 0; +static int pagesize = 0; /* memory_init ***************************************************************** @@ -109,7 +109,7 @@ bool memory_init(void) #if defined(ENABLE_THREADS) /* create lock for code memory */ - lock_code_memory = NEW(java_objectheader); + lock_code_memory = NEW(java_object_t); lock_init_object_lock(lock_code_memory); #endif diff --git a/src/native/Makefile.am b/src/native/Makefile.am index b824949fb..d149d03dd 100644 --- a/src/native/Makefile.am +++ b/src/native/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 7384 2007-02-21 22:17:16Z twisti $ +## $Id: Makefile.am 8297 2007-08-12 00:02:48Z michi $ ## Process this file with automake to produce Makefile.in @@ -61,7 +61,9 @@ noinst_LTLIBRARIES = libnative.la if ENABLE_JNI JNI_SOURCES = \ jni.c \ - jni.h + jni.h \ + localref.c \ + localref.h endif libnative_la_SOURCES = \ diff --git a/src/native/include/Makefile.am b/src/native/include/Makefile.am index ff610f1cb..ab712873c 100644 --- a/src/native/include/Makefile.am +++ b/src/native/include/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 8202 2007-07-15 12:08:18Z twisti $ +## $Id: Makefile.am 8249 2007-07-31 12:59:03Z panzi $ ## Process this file with automake to produce Makefile.in @@ -73,6 +73,11 @@ JAVASE_HEADER_FILES += \ gnu_classpath_Pointer64.h \ java_lang_VMObject.h \ java_nio_DirectByteBufferImpl.h + +if ENABLE_ANNOTATIONS +JAVASE_HEADER_FILES += \ + sun_reflect_ConstantPool.h +endif endif if WITH_CLASSPATH_SUN diff --git a/src/native/jni.c b/src/native/jni.c index 96bf7c5c7..162aebcb0 100644 --- a/src/native/jni.c +++ b/src/native/jni.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: jni.c 8245 2007-07-31 09:55:04Z michi $ + $Id: jni.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -38,6 +38,7 @@ #include "mm/gc-common.h" #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #if defined(ENABLE_JAVASE) @@ -102,6 +103,7 @@ #include "vm/exceptions.h" #include "vm/global.h" #include "vm/initialize.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/stringlocal.h" #include "vm/vm.h" @@ -112,7 +114,6 @@ #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/statistics.h" @@ -160,20 +161,13 @@ static methodinfo *dbbirw_init; #endif -/* local reference table ******************************************************/ - -#if !defined(ENABLE_THREADS) -localref_table *_no_threads_localref_table; -#endif - - /* accessing instance fields macros *******************************************/ #define SET_FIELD(o,type,f,value) \ - *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset)) = (type) (value) + *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) = (type) (value) #define GET_FIELD(o,type,f) \ - *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset)) + *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) /* some forward declarations **************************************************/ @@ -240,42 +234,6 @@ bool jni_init(void) } -/* jni_init_localref_table ***************************************************** - - Initializes the local references table of the current thread. - -*******************************************************************************/ - -bool jni_init_localref_table(void) -{ - localref_table *lrt; - -#if defined(ENABLE_GC_CACAO) - /* XXX this one will never get freed for the main thread; - call jni_free_localref_table() if you want to do it! */ - lrt = NEW(localref_table); -#else - lrt = GCNEW(localref_table); -#endif - - if (lrt == NULL) - return false; - - lrt->capacity = LOCALREFTABLE_CAPACITY; - lrt->used = 0; - lrt->localframes = 1; - lrt->prev = LOCALREFTABLE; - - /* clear the references array (memset is faster then a for-loop) */ - - MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY); - - LOCALREFTABLE = lrt; - - return true; -} - - /* jni_init_localref_table ***************************************************** Frees the local references table of the current thread. @@ -307,12 +265,12 @@ bool jni_free_localref_table(void) *******************************************************************************/ -static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o, - vftbl_t *vftbl, - methodinfo *m, va_list ap) +static java_handle_t *_Jv_jni_CallObjectMethod(java_handle_t *o, + vftbl_t *vftbl, + methodinfo *m, va_list ap) { - methodinfo *resm; - java_objectheader *ro; + methodinfo *resm; + java_handle_t *ro; STATISTICS(jniinvokation()); @@ -354,13 +312,13 @@ static java_objectheader *_Jv_jni_CallObjectMethod(java_objectheader *o, *******************************************************************************/ -static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o, - vftbl_t *vftbl, - methodinfo *m, - const jvalue *args) +static java_handle_t *_Jv_jni_CallObjectMethodA(java_handle_t *o, + vftbl_t *vftbl, + methodinfo *m, + const jvalue *args) { - methodinfo *resm; - java_objectheader *ro; + methodinfo *resm; + java_handle_t *ro; STATISTICS(jniinvokation()); @@ -403,7 +361,7 @@ static java_objectheader *_Jv_jni_CallObjectMethodA(java_objectheader *o, *******************************************************************************/ -static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl, +static jint _Jv_jni_CallIntMethod(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, va_list ap) { methodinfo *resm; @@ -450,7 +408,7 @@ static jint _Jv_jni_CallIntMethod(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl, +static jint _Jv_jni_CallIntMethodA(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, const jvalue *args) { methodinfo *resm; @@ -496,7 +454,7 @@ static jint _Jv_jni_CallIntMethodA(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl, +static jlong _Jv_jni_CallLongMethod(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, va_list ap) { methodinfo *resm; @@ -542,7 +500,7 @@ static jlong _Jv_jni_CallLongMethod(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl, +static jlong _Jv_jni_CallLongMethodA(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, const jvalue *args) { methodinfo *resm; @@ -588,7 +546,7 @@ static jlong _Jv_jni_CallLongMethodA(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl, +static jfloat _Jv_jni_CallFloatMethod(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, va_list ap) { methodinfo *resm; @@ -627,7 +585,7 @@ static jfloat _Jv_jni_CallFloatMethod(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl, +static jfloat _Jv_jni_CallFloatMethodA(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, const jvalue *args) { methodinfo *resm; @@ -666,7 +624,7 @@ static jfloat _Jv_jni_CallFloatMethodA(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl, +static jdouble _Jv_jni_CallDoubleMethod(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, va_list ap) { methodinfo *resm; @@ -703,7 +661,7 @@ static jdouble _Jv_jni_CallDoubleMethod(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl, +static jdouble _Jv_jni_CallDoubleMethodA(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, const jvalue *args) { methodinfo *resm; @@ -740,7 +698,7 @@ static jdouble _Jv_jni_CallDoubleMethodA(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl, +static void _Jv_jni_CallVoidMethod(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, va_list ap) { methodinfo *resm; @@ -781,7 +739,7 @@ static void _Jv_jni_CallVoidMethod(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl, +static void _Jv_jni_CallVoidMethodA(java_handle_t *o, vftbl_t *vftbl, methodinfo *m, const jvalue *args) { methodinfo *resm; @@ -827,241 +785,17 @@ static void _Jv_jni_CallVoidMethodA(java_objectheader *o, vftbl_t *vftbl, *******************************************************************************/ -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o, - java_objectarray *params) -{ - methodinfo *resm; - vm_arg *vmargs; - java_objectheader *ro; - s4 argcount; - s4 paramcount; - java_objectheader *xptr; - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - argcount = m->parseddesc->paramcount; - paramcount = argcount; - - /* if method is non-static, remove the `this' pointer */ - - if (!(m->flags & ACC_STATIC)) - paramcount--; - - /* For instance methods the object has to be an instance of the - class the method belongs to. For static methods the obj - parameter is ignored. */ - - if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->class))) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* check if we got the right number of arguments */ - - if (((params == NULL) && (paramcount != 0)) || - (params && (params->header.size != paramcount))) - { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* for instance methods we need an object */ - - if (!(m->flags & ACC_STATIC) && (o == NULL)) { - /* XXX not sure if that is the correct exception */ - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* for static methods, zero object to make subsequent code simpler */ - if (m->flags & ACC_STATIC) - o = NULL; - - if (o != NULL) { - /* for instance methods we must do a vftbl lookup */ - resm = method_vftbl_lookup(o->vftbl, m); - } - else { - /* for static methods, just for convenience */ - resm = m; - } - - vmargs = MNEW(vm_arg, argcount); - - if (!vm_vmargs_from_objectarray(resm, o, vmargs, params)) { - MFREE(vmargs, vm_arg, argcount); - return NULL; - } - - switch (resm->parseddesc->returntype.decltype) { - case TYPE_VOID: - (void) vm_call_method_vmarg(resm, argcount, vmargs); - - ro = NULL; - break; - - case PRIMITIVETYPE_BOOLEAN: { - s4 i; - java_lang_Boolean *bo; - - i = vm_call_method_int_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Boolean); - - /* setting the value of the object direct */ - - bo = (java_lang_Boolean *) ro; - bo->value = i; - } - break; - - case PRIMITIVETYPE_BYTE: { - s4 i; - java_lang_Byte *bo; - - i = vm_call_method_int_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Byte); - - /* setting the value of the object direct */ - - bo = (java_lang_Byte *) ro; - bo->value = i; - } - break; - - case PRIMITIVETYPE_CHAR: { - s4 i; - java_lang_Character *co; - - i = vm_call_method_int_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Character); - - /* setting the value of the object direct */ - - co = (java_lang_Character *) ro; - co->value = i; - } - break; - - case PRIMITIVETYPE_SHORT: { - s4 i; - java_lang_Short *so; - - i = vm_call_method_int_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Short); - - /* setting the value of the object direct */ - - so = (java_lang_Short *) ro; - so->value = i; - } - break; - - case PRIMITIVETYPE_INT: { - s4 i; - java_lang_Integer *io; - - i = vm_call_method_int_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Integer); - - /* setting the value of the object direct */ - - io = (java_lang_Integer *) ro; - io->value = i; - } - break; - - case PRIMITIVETYPE_LONG: { - s8 l; - java_lang_Long *lo; - - l = vm_call_method_long_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Long); - - /* setting the value of the object direct */ - - lo = (java_lang_Long *) ro; - lo->value = l; - } - break; - - case PRIMITIVETYPE_FLOAT: { - float f; - java_lang_Float *fo; - - f = vm_call_method_float_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Float); - - /* setting the value of the object direct */ - - fo = (java_lang_Float *) ro; - fo->value = f; - } - break; - - case PRIMITIVETYPE_DOUBLE: { - double d; - java_lang_Double *_do; - - d = vm_call_method_double_vmarg(resm, argcount, vmargs); - - ro = builtin_new(class_java_lang_Double); - - /* setting the value of the object direct */ - - _do = (java_lang_Double *) ro; - _do->value = d; - } - break; - - case TYPE_ADR: - ro = vm_call_method_vmarg(resm, argcount, vmargs); - break; - - default: - /* if this happens the exception has already been set by - fill_callblock_from_objectarray */ - - MFREE(vmargs, vm_arg, argcount); - - return NULL; - } - - MFREE(vmargs, vm_arg, argcount); - - xptr = exceptions_get_exception(); - - if (xptr != NULL) { - /* clear exception pointer, we are calling JIT code again */ - - exceptions_clear_exception(); - - exceptions_throw_invocationtargetexception(xptr); - } - - return ro; -} -#else -java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o, - java_objectarray *params) +java_handle_t *_Jv_jni_invokeNative(methodinfo *m, java_handle_t *o, + java_objectarray *params) { - methodinfo *resm; - java_objectheader *ro; - s4 argcount; - s4 paramcount; - java_objectheader *xptr; - int32_t dumpsize; - uint64_t *array; + methodinfo *resm; + java_handle_t *ro; + s4 argcount; + s4 paramcount; + java_handle_t *xptr; + int32_t dumpsize; + uint64_t *array; + imm_union value; if (m == NULL) { exceptions_throw_nullpointerexception(); @@ -1139,143 +873,39 @@ java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o, switch (resm->parseddesc->returntype.decltype) { case TYPE_VOID: (void) vm_call_array(resm, array); - ro = NULL; break; - case PRIMITIVETYPE_BOOLEAN: { - s4 i; - java_lang_Boolean *bo; - - i = vm_call_int_array(resm, array); - - ro = builtin_new(class_java_lang_Boolean); - - /* setting the value of the object direct */ - - bo = (java_lang_Boolean *) ro; - bo->value = i; - } - break; - - case PRIMITIVETYPE_BYTE: { - s4 i; - java_lang_Byte *bo; - - i = vm_call_int_array(resm, array); - - ro = builtin_new(class_java_lang_Byte); - - /* setting the value of the object direct */ - - bo = (java_lang_Byte *) ro; - bo->value = i; - } - break; - - case PRIMITIVETYPE_CHAR: { - s4 i; - java_lang_Character *co; - - i = vm_call_int_array(resm, array); - - ro = builtin_new(class_java_lang_Character); - - /* setting the value of the object direct */ - - co = (java_lang_Character *) ro; - co->value = i; - } - break; - - case PRIMITIVETYPE_SHORT: { - s4 i; - java_lang_Short *so; - - i = vm_call_int_array(resm, array); - - ro = builtin_new(class_java_lang_Short); - - /* setting the value of the object direct */ - - so = (java_lang_Short *) ro; - so->value = i; - } - break; - - case PRIMITIVETYPE_INT: { - s4 i; - java_lang_Integer *io; - - i = vm_call_int_array(resm, array); - - ro = builtin_new(class_java_lang_Integer); - - /* setting the value of the object direct */ - - io = (java_lang_Integer *) ro; - io->value = i; - } - break; - - case PRIMITIVETYPE_LONG: { - s8 l; - java_lang_Long *lo; - - l = vm_call_long_array(resm, array); - - ro = builtin_new(class_java_lang_Long); - - /* setting the value of the object direct */ - - lo = (java_lang_Long *) ro; - lo->value = l; - } - break; - - case PRIMITIVETYPE_FLOAT: { - float f; - java_lang_Float *fo; - - f = vm_call_float_array(resm, array); - - ro = builtin_new(class_java_lang_Float); - - /* setting the value of the object direct */ - - fo = (java_lang_Float *) ro; - fo->value = f; - } - break; - - case PRIMITIVETYPE_DOUBLE: { - double d; - java_lang_Double *_do; - - d = vm_call_double_array(resm, array); + case PRIMITIVETYPE_BOOLEAN: + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + value.i = vm_call_int_array(resm, array); + ro = primitive_box(resm->parseddesc->returntype.decltype, value); + break; - ro = builtin_new(class_java_lang_Double); + case PRIMITIVETYPE_LONG: + value.l = vm_call_long_array(resm, array); + ro = primitive_box(resm->parseddesc->returntype.decltype, value); + break; - /* setting the value of the object direct */ + case PRIMITIVETYPE_FLOAT: + value.f = vm_call_float_array(resm, array); + ro = primitive_box(resm->parseddesc->returntype.decltype, value); + break; - _do = (java_lang_Double *) ro; - _do->value = d; - } - break; + case PRIMITIVETYPE_DOUBLE: + value.d = vm_call_double_array(resm, array); + ro = primitive_box(resm->parseddesc->returntype.decltype, value); + break; case TYPE_ADR: ro = vm_call_array(resm, array); break; default: - /* if this happens the exception has already been set by - fill_callblock_from_objectarray */ - - /* release dump area */ - - dump_release(dumpsize); - - return NULL; + vm_abort("_Jv_jni_invokeNative: invalid return type %d", resm->parseddesc->returntype.decltype); } xptr = exceptions_get_exception(); @@ -1294,7 +924,6 @@ java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o, return ro; } -#endif /* GetVersion ****************************************************************** @@ -1328,14 +957,14 @@ jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize bufLen) { #if defined(ENABLE_JAVASE) - utf *u; - java_objectheader *cl; - classinfo *c; + utf *u; + classloader *cl; + classinfo *c; TRACEJNICALLS("_Jv_JNI_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d", env, name, loader, buf, bufLen); u = utf_new_char(name); - cl = (java_objectheader *) loader; + cl = (classloader *) loader; c = class_define(u, cl, bufLen, (const uint8_t *) buf); @@ -1461,11 +1090,11 @@ jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup) jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj) { - java_objectheader *o; + java_handle_t *o; STATISTICS(jniinvokation()); - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; exceptions_set_exception(o); @@ -1483,9 +1112,9 @@ jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj) jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg) { - classinfo *c; - java_objectheader *o; - java_objectheader *s; + classinfo *c; + java_handle_t *o; + java_handle_t *s; STATISTICS(jniinvokation()); @@ -1517,7 +1146,7 @@ jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg) jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env) { - java_objectheader *o; + java_handle_t *o; STATISTICS(jniinvokation()); @@ -1537,8 +1166,8 @@ jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env) void _Jv_JNI_ExceptionDescribe(JNIEnv *env) { - java_objectheader *o; - methodinfo *m; + java_handle_t *o; + methodinfo *m; STATISTICS(jniinvokation()); @@ -1609,48 +1238,16 @@ void _Jv_JNI_FatalError(JNIEnv *env, const char *msg) jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity) { - s4 additionalrefs; - localref_table *lrt; - localref_table *nlrt; - STATISTICS(jniinvokation()); if (capacity <= 0) return -1; - /* Allocate new local reference table on Java heap. Calculate the - additional memory we have to allocate. */ - - if (capacity > LOCALREFTABLE_CAPACITY) - additionalrefs = capacity - LOCALREFTABLE_CAPACITY; - else - additionalrefs = 0; - -#if defined(ENABLE_GC_CACAO) - nlrt = MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P); -#else - nlrt = GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P); -#endif + /* add new local reference frame to current table */ - if (nlrt == NULL) + if (!localref_frame_push(capacity)) return -1; - /* get current local reference table from thread */ - - lrt = LOCALREFTABLE; - - /* Set up the new local reference table and add it to the local - frames chain. */ - - nlrt->capacity = capacity; - nlrt->used = 0; - nlrt->localframes = lrt->localframes + 1; - nlrt->prev = lrt; - - /* store new local reference table in thread */ - - LOCALREFTABLE = nlrt; - return 0; } @@ -1665,59 +1262,11 @@ jint _Jv_JNI_PushLocalFrame(JNIEnv* env, jint capacity) jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result) { - localref_table *lrt; - localref_table *plrt; - s4 localframes; - s4 additionalrefs; - STATISTICS(jniinvokation()); - /* get current local reference table from thread */ - - lrt = LOCALREFTABLE; - - localframes = lrt->localframes; - - /* Don't delete the top local frame, as this one is allocated in - the native stub on the stack and is freed automagically on - return. */ - - if (localframes == 1) - return _Jv_JNI_NewLocalRef(env, result); - /* release all current local frames */ - for (; localframes >= 1; localframes--) { - /* get previous frame */ - - plrt = lrt->prev; - - /* clear all reference entries */ - - MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity); - - lrt->prev = NULL; - -#if defined(ENABLE_GC_CACAO) - /* for the exact GC local reference tables are not on the heap, - so we need to free them explicitly here. */ - - if (lrt->capacity > LOCALREFTABLE_CAPACITY) - additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY; - else - additionalrefs = 0; - - MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P); -#endif - - /* set new local references table */ - - lrt = plrt; - } - - /* store new local reference table in thread */ - - LOCALREFTABLE = lrt; + localref_frame_pop_all(); /* add local reference and return the value */ @@ -1733,13 +1282,13 @@ jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result) void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef) { - java_objectheader *o; - localref_table *lrt; - s4 i; + java_handle_t *o; + localref_table *lrt; + s4 i; STATISTICS(jniinvokation()); - o = (java_objectheader *) localRef; + o = (java_handle_t *) localRef; /* get local reference table (thread specific) */ @@ -1823,7 +1372,7 @@ jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref) for (i = 0; i < lrt->capacity; i++) { if (lrt->refs[i] == NULL) { - lrt->refs[i] = (java_objectheader *) ref; + lrt->refs[i] = (java_handle_t *) ref; lrt->used++; return ref; @@ -1875,8 +1424,8 @@ jint _Jv_JNI_EnsureLocalCapacity(JNIEnv* env, jint capacity) jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz) { - classinfo *c; - java_objectheader *o; + classinfo *c; + java_handle_t *o; STATISTICS(jniinvokation()); @@ -1904,10 +1453,10 @@ 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; + java_handle_t *o; + classinfo *c; + methodinfo *m; + va_list ap; STATISTICS(jniinvokation()); @@ -1944,9 +1493,9 @@ jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...) jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { - java_objectheader *o; - classinfo *c; - methodinfo *m; + java_handle_t *o; + classinfo *c; + methodinfo *m; STATISTICS(jniinvokation()); @@ -1981,9 +1530,9 @@ jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue *args) { - java_objectheader *o; - classinfo *c; - methodinfo *m; + java_handle_t *o; + classinfo *c; + methodinfo *m; STATISTICS(jniinvokation()); @@ -2013,12 +1562,12 @@ jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj) { - java_objectheader *o; - classinfo *c; + java_handle_t *o; + classinfo *c; STATISTICS(jniinvokation()); - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; if ((o == NULL) || (o->vftbl == NULL)) return NULL; @@ -2061,14 +1610,14 @@ jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz) jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method) { #if defined(ENABLE_JAVASE) - java_objectheader *o; - classinfo *c; - methodinfo *m; - s4 slot; + java_handle_t *o; + classinfo *c; + methodinfo *m; + s4 slot; STATISTICS(jniinvokation()); - o = (java_objectheader *) method; + o = (java_handle_t *) method; if (o == NULL) return NULL; @@ -2077,15 +1626,15 @@ jmethodID _Jv_JNI_FromReflectedMethod(JNIEnv *env, jobject method) java_lang_reflect_Method *rm; rm = (java_lang_reflect_Method *) method; - c = (classinfo *) (rm->clazz); - slot = rm->slot; + LLNI_field_get_cls(rm, clazz, c); + LLNI_field_get_val(rm, slot , slot); } 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); - slot = rc->slot; + LLNI_field_get_cls(rc, clazz, c); + LLNI_field_get_val(rc, slot , slot); } else return NULL; @@ -2115,6 +1664,7 @@ jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field) java_lang_reflect_Field *rf; classinfo *c; fieldinfo *f; + int32_t slot; STATISTICS(jniinvokation()); @@ -2123,8 +1673,9 @@ jfieldID _Jv_JNI_FromReflectedField(JNIEnv* env, jobject field) if (rf == NULL) return NULL; - c = (classinfo *) rf->clazz; - f = &(c->fields[rf->slot]); + LLNI_field_get_cls(rf, clazz, c); + LLNI_field_get_val(rf, slot , slot); + f = &(c->fields[slot]); return (jfieldID) f; #else @@ -2250,15 +1801,97 @@ jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name, /* JNI-functions for calling instance methods *********************************/ +#define JNI_CALL_VIRTUAL_METHOD(name, type, intern) \ +type _Jv_JNI_Call##name##Method(JNIEnv *env, jobject obj, \ + jmethodID methodID, ...) \ +{ \ + java_handle_t *o; \ + methodinfo *m; \ + va_list ap; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + m = (methodinfo *) methodID; \ + \ + va_start(ap, methodID); \ + ret = _Jv_jni_Call##intern##Method(o, o->vftbl, m, ap); \ + va_end(ap); \ + \ + return ret; \ +} + +JNI_CALL_VIRTUAL_METHOD(Boolean, jboolean, Int) +JNI_CALL_VIRTUAL_METHOD(Byte, jbyte, Int) +JNI_CALL_VIRTUAL_METHOD(Char, jchar, Int) +JNI_CALL_VIRTUAL_METHOD(Short, jshort, Int) +JNI_CALL_VIRTUAL_METHOD(Int, jint, Int) +JNI_CALL_VIRTUAL_METHOD(Long, jlong, Long) +JNI_CALL_VIRTUAL_METHOD(Float, jfloat, Float) +JNI_CALL_VIRTUAL_METHOD(Double, jdouble, Double) + + +#define JNI_CALL_VIRTUAL_METHOD_V(name, type, intern) \ +type _Jv_JNI_Call##name##MethodV(JNIEnv *env, jobject obj, \ + jmethodID methodID, va_list args) \ +{ \ + java_handle_t *o; \ + methodinfo *m; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + m = (methodinfo *) methodID; \ + \ + ret = _Jv_jni_Call##intern##Method(o, o->vftbl, m, args); \ + \ + return ret; \ +} + +JNI_CALL_VIRTUAL_METHOD_V(Boolean, jboolean, Int) +JNI_CALL_VIRTUAL_METHOD_V(Byte, jbyte, Int) +JNI_CALL_VIRTUAL_METHOD_V(Char, jchar, Int) +JNI_CALL_VIRTUAL_METHOD_V(Short, jshort, Int) +JNI_CALL_VIRTUAL_METHOD_V(Int, jint, Int) +JNI_CALL_VIRTUAL_METHOD_V(Long, jlong, Long) +JNI_CALL_VIRTUAL_METHOD_V(Float, jfloat, Float) +JNI_CALL_VIRTUAL_METHOD_V(Double, jdouble, Double) + + +#define JNI_CALL_VIRTUAL_METHOD_A(name, type, intern) \ +type _Jv_JNI_Call##name##MethodA(JNIEnv *env, jobject obj, \ + jmethodID methodID, \ + const jvalue *args) \ +{ \ + java_handle_t *o; \ + methodinfo *m; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + m = (methodinfo *) methodID; \ + \ + ret = _Jv_jni_Call##intern##MethodA(o, o->vftbl, m, args); \ + \ + return ret; \ +} + +JNI_CALL_VIRTUAL_METHOD_A(Boolean, jboolean, Int) +JNI_CALL_VIRTUAL_METHOD_A(Byte, jbyte, Int) +JNI_CALL_VIRTUAL_METHOD_A(Char, jchar, Int) +JNI_CALL_VIRTUAL_METHOD_A(Short, jshort, Int) +JNI_CALL_VIRTUAL_METHOD_A(Int, jint, Int) +JNI_CALL_VIRTUAL_METHOD_A(Long, jlong, Long) +JNI_CALL_VIRTUAL_METHOD_A(Float, jfloat, Float) +JNI_CALL_VIRTUAL_METHOD_A(Double, jdouble, Double) + + jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) { - java_objectheader *o; - methodinfo *m; - java_objectheader *ret; - va_list ap; + java_handle_t *o; + methodinfo *m; + java_handle_t *ret; + va_list ap; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; m = (methodinfo *) methodID; va_start(ap, methodID); @@ -2272,11 +1905,11 @@ jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID, jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args) { - java_objectheader *o; - methodinfo *m; - java_objectheader *ret; + java_handle_t *o; + methodinfo *m; + java_handle_t *ret; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; m = (methodinfo *) methodID; ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args); @@ -2288,11 +1921,11 @@ jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID, jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args) { - java_objectheader *o; - methodinfo *m; - java_objectheader *ret; + java_handle_t *o; + methodinfo *m; + java_handle_t *ret; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; m = (methodinfo *) methodID; ret = _Jv_jni_CallObjectMethodA(o, o->vftbl, m, args); @@ -2301,3127 +1934,1205 @@ jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID, } -jboolean _Jv_JNI_CallBooleanMethod(JNIEnv *env, jobject obj, jmethodID methodID, - ...) + +void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) { - java_objectheader *o; - methodinfo *m; - va_list ap; - jboolean b; + java_handle_t *o; + methodinfo *m; + va_list ap; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; m = (methodinfo *) methodID; va_start(ap, methodID); - b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap); + _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap); va_end(ap); - - return b; } -jboolean _Jv_JNI_CallBooleanMethodV(JNIEnv *env, jobject obj, - jmethodID methodID, va_list args) +void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, + va_list args) { - java_objectheader *o; - methodinfo *m; - jboolean b; + java_handle_t *o; + methodinfo *m; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; m = (methodinfo *) methodID; - b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args); - - return b; + _Jv_jni_CallVoidMethod(o, o->vftbl, m, args); } -jboolean _Jv_JNI_CallBooleanMethodA(JNIEnv *env, jobject obj, - jmethodID methodID, const jvalue *args) +void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, + const jvalue *args) { - java_objectheader *o; - methodinfo *m; - jboolean b; + java_handle_t *o; + methodinfo *m; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; m = (methodinfo *) methodID; - b = _Jv_jni_CallIntMethodA(o, o->vftbl, m, args); - - return b; + _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args); } -jbyte _Jv_JNI_CallByteMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) + +#define JNI_CALL_NONVIRTUAL_METHOD(name, type, intern) \ +type _Jv_JNI_CallNonvirtual##name##Method(JNIEnv *env, jobject obj, \ + jclass clazz, jmethodID methodID, \ + ...) \ +{ \ + java_handle_t *o; \ + classinfo *c; \ + methodinfo *m; \ + va_list ap; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + c = (classinfo *) clazz; \ + m = (methodinfo *) methodID; \ + \ + va_start(ap, methodID); \ + ret = _Jv_jni_Call##intern##Method(o, c->vftbl, m, ap); \ + va_end(ap); \ + \ + return ret; \ +} + +JNI_CALL_NONVIRTUAL_METHOD(Boolean, jboolean, Int) +JNI_CALL_NONVIRTUAL_METHOD(Byte, jbyte, Int) +JNI_CALL_NONVIRTUAL_METHOD(Char, jchar, Int) +JNI_CALL_NONVIRTUAL_METHOD(Short, jshort, Int) +JNI_CALL_NONVIRTUAL_METHOD(Int, jint, Int) +JNI_CALL_NONVIRTUAL_METHOD(Long, jlong, Long) +JNI_CALL_NONVIRTUAL_METHOD(Float, jfloat, Float) +JNI_CALL_NONVIRTUAL_METHOD(Double, jdouble, Double) + + +#define JNI_CALL_NONVIRTUAL_METHOD_V(name, type, intern) \ +type _Jv_JNI_CallNonvirtual##name##MethodV(JNIEnv *env, jobject obj, \ + jclass clazz, jmethodID methodID, \ + va_list args) \ +{ \ + java_handle_t *o; \ + classinfo *c; \ + methodinfo *m; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + c = (classinfo *) clazz; \ + m = (methodinfo *) methodID; \ + \ + ret = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); \ + \ + return ret; \ +} + +JNI_CALL_NONVIRTUAL_METHOD_V(Boolean, jboolean, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Byte, jbyte, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Char, jchar, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Short, jshort, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Int, jint, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Long, jlong, Long) +JNI_CALL_NONVIRTUAL_METHOD_V(Float, jfloat, Float) +JNI_CALL_NONVIRTUAL_METHOD_V(Double, jdouble, Double) + + +#define JNI_CALL_NONVIRTUAL_METHOD_A(name, type, intern) \ +type _Jv_JNI_CallNonvirtual##name##MethodA(JNIEnv *env, jobject obj, \ + jclass clazz, jmethodID methodID, \ + const jvalue *args) \ +{ \ + log_text("JNI-Call: CallNonvirtual##name##MethodA: IMPLEMENT ME!"); \ + \ + return 0; \ +} + +JNI_CALL_NONVIRTUAL_METHOD_A(Boolean, jboolean, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Byte, jbyte, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Char, jchar, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Short, jshort, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Int, jint, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Long, jlong, Long) +JNI_CALL_NONVIRTUAL_METHOD_A(Float, jfloat, Float) +JNI_CALL_NONVIRTUAL_METHOD_A(Double, jdouble, Double) + +jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj, + jclass clazz, jmethodID methodID, + ...) { - java_objectheader *o; - methodinfo *m; - va_list ap; - jbyte b; + java_handle_t *o; + classinfo *c; + methodinfo *m; + java_handle_t *r; + va_list ap; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; + c = (classinfo *) clazz; m = (methodinfo *) methodID; va_start(ap, methodID); - b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap); + r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap); va_end(ap); - return b; - + return _Jv_JNI_NewLocalRef(env, (jobject) r); } -jbyte _Jv_JNI_CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) +jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj, + jclass clazz, jmethodID methodID, + va_list args) { - java_objectheader *o; - methodinfo *m; - jbyte b; + java_handle_t *o; + classinfo *c; + methodinfo *m; + java_handle_t *r; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; + c = (classinfo *) clazz; m = (methodinfo *) methodID; - b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args); + r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args); - return b; + return _Jv_JNI_NewLocalRef(env, (jobject) r); } -jbyte _Jv_JNI_CallByteMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) +jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj, + jclass clazz, jmethodID methodID, + const jvalue *args) { - log_text("JNI-Call: CallByteMethodA: IMPLEMENT ME!"); + log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!"); - return 0; + return _Jv_JNI_NewLocalRef(env, NULL); } -jchar _Jv_JNI_CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) +void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...) { - java_objectheader *o; - methodinfo *m; - va_list ap; - jchar c; + java_handle_t *o; + classinfo *c; + methodinfo *m; + va_list ap; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; + c = (classinfo *) clazz; m = (methodinfo *) methodID; va_start(ap, methodID); - c = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap); + _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap); va_end(ap); - - return c; } -jchar _Jv_JNI_CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) +void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, va_list args) { - java_objectheader *o; - methodinfo *m; - jchar c; + java_handle_t *o; + classinfo *c; + methodinfo *m; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; + c = (classinfo *) clazz; m = (methodinfo *) methodID; - c = _Jv_jni_CallIntMethod(o, o->vftbl, m, args); - - return c; + _Jv_jni_CallVoidMethod(o, c->vftbl, m, args); } -jchar _Jv_JNI_CallCharMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallCharMethodA: IMPLEMENT ME!"); +void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; - return 0; -} + o = (java_handle_t *) obj; + c = (classinfo *) clazz; + m = (methodinfo *) methodID; + _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args); +} -jshort _Jv_JNI_CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID, - ...) -{ - java_objectheader *o; - methodinfo *m; - va_list ap; - jshort s; - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; +/* Accessing Fields of Objects ************************************************/ - va_start(ap, methodID); - s = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap); - va_end(ap); +/* GetFieldID ****************************************************************** - return s; -} + Returns the field ID for an instance (nonstatic) field of a + class. The field is specified by its name and signature. The + GetField and SetField families of accessor functions + use field IDs to retrieve object fields. +*******************************************************************************/ -jshort _Jv_JNI_CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) +jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name, + const char *sig) { - java_objectheader *o; - methodinfo *m; - jshort s; + classinfo *c; + fieldinfo *f; + utf *uname; + utf *udesc; - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; + STATISTICS(jniinvokation()); - s = _Jv_jni_CallIntMethod(o, o->vftbl, m, args); + c = (classinfo *) clazz; - return s; -} + /* XXX NPE check? */ + uname = utf_new_char((char *) name); + udesc = utf_new_char((char *) sig); -jshort _Jv_JNI_CallShortMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallShortMethodA: IMPLEMENT ME!"); + f = class_findfield(c, uname, udesc); + + if (f == NULL) + exceptions_throw_nosuchfielderror(c, uname); - return 0; + return (jfieldID) f; } +/* GetField Routines ***************************************************** -jint _Jv_JNI_CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) -{ - java_objectheader *o; - methodinfo *m; - va_list ap; - jint i; - - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; + This family of accessor routines returns the value of an instance + (nonstatic) field of an object. The field to access is specified by + a field ID obtained by calling GetFieldID(). - va_start(ap, methodID); - i = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap); - va_end(ap); +*******************************************************************************/ - return i; +#define JNI_GET_FIELD(name, type, intern) \ +type _Jv_JNI_Get##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID) \ +{ \ + intern ret; \ + \ + STATISTICS(jniinvokation()); \ + \ + ret = GET_FIELD(obj, intern, fieldID); \ + \ + return (type) ret; \ } +JNI_GET_FIELD(Boolean, jboolean, s4) +JNI_GET_FIELD(Byte, jbyte, s4) +JNI_GET_FIELD(Char, jchar, s4) +JNI_GET_FIELD(Short, jshort, s4) +JNI_GET_FIELD(Int, jint, s4) +JNI_GET_FIELD(Long, jlong, s8) +JNI_GET_FIELD(Float, jfloat, float) +JNI_GET_FIELD(Double, jdouble, double) + -jint _Jv_JNI_CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) +jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID) { - java_objectheader *o; - methodinfo *m; - jint i; + java_handle_t *o; - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; + STATISTICS(jniinvokation()); - i = _Jv_jni_CallIntMethod(o, o->vftbl, m, args); +#warning this needs to be fixed + o = GET_FIELD(obj, java_handle_t*, fieldID); - return i; + return _Jv_JNI_NewLocalRef(env, (jobject) o); } -jint _Jv_JNI_CallIntMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallIntMethodA: IMPLEMENT ME!"); +/* SetField Routines ***************************************************** - return 0; -} + This family of accessor routines sets the value of an instance + (nonstatic) field of an object. The field to access is specified by + a field ID obtained by calling GetFieldID(). +*******************************************************************************/ +#define JNI_SET_FIELD(name, type, intern) \ +void _Jv_JNI_Set##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID, \ + type value) \ +{ \ + STATISTICS(jniinvokation()); \ + \ + SET_FIELD(obj, intern, fieldID, value); \ +} -jlong _Jv_JNI_CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) -{ - java_objectheader *o; - methodinfo *m; - va_list ap; - jlong l; +JNI_SET_FIELD(Boolean, jboolean, s4) +JNI_SET_FIELD(Byte, jbyte, s4) +JNI_SET_FIELD(Char, jchar, s4) +JNI_SET_FIELD(Short, jshort, s4) +JNI_SET_FIELD(Int, jint, s4) +JNI_SET_FIELD(Long, jlong, s8) +JNI_SET_FIELD(Float, jfloat, float) +JNI_SET_FIELD(Double, jdouble, double) - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; - va_start(ap, methodID); - l = _Jv_jni_CallLongMethod(o, o->vftbl, m, ap); - va_end(ap); +void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, + jobject value) +{ + STATISTICS(jniinvokation()); - return l; +#warning this needs to be fixed + SET_FIELD(obj, java_handle_t*, fieldID, value); } -jlong _Jv_JNI_CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) -{ - java_objectheader *o; - methodinfo *m; - jlong l; +/* Calling Static Methods *****************************************************/ - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; +/* GetStaticMethodID *********************************************************** - l = _Jv_jni_CallLongMethod(o, o->vftbl, m, args); + Returns the method ID for a static method of a class. The method is + specified by its name and signature. - return l; -} + GetStaticMethodID() causes an uninitialized class to be + initialized. +*******************************************************************************/ -jlong _Jv_JNI_CallLongMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) +jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, + const char *sig) { - log_text("JNI-Call: CallLongMethodA: IMPLEMENT ME!"); - - return 0; -} - + classinfo *c; + utf *uname; + utf *udesc; + methodinfo *m; + STATISTICS(jniinvokation()); -jfloat _Jv_JNI_CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID, - ...) -{ - java_objectheader *o; - methodinfo *m; - va_list ap; - jfloat f; + c = (classinfo *) clazz; - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; + if (!c) + return NULL; - va_start(ap, methodID); - f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, ap); - va_end(ap); + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return NULL; - return f; -} + /* try to get the static method of the class */ + uname = utf_new_char((char *) name); + udesc = utf_new_char((char *) sig); -jfloat _Jv_JNI_CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) -{ - java_objectheader *o; - methodinfo *m; - jfloat f; + m = class_resolvemethod(c, uname, udesc); - o = (java_objectheader *) obj; - m = (methodinfo *) methodID; + if ((m == NULL) || !(m->flags & ACC_STATIC)) { + exceptions_throw_nosuchmethoderror(c, uname, udesc); - f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, args); + return NULL; + } - return f; + return (jmethodID) m; } -jfloat _Jv_JNI_CallFloatMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallFloatMethodA: IMPLEMENT ME!"); - - return 0; -} - +#define JNI_CALL_STATIC_METHOD(name, type, intern) \ +type _Jv_JNI_CallStatic##name##Method(JNIEnv *env, jclass clazz, \ + jmethodID methodID, ...) \ +{ \ + methodinfo *m; \ + va_list ap; \ + type res; \ + \ + m = (methodinfo *) methodID; \ + \ + va_start(ap, methodID); \ + res = _Jv_jni_Call##intern##Method(NULL, NULL, m, ap); \ + va_end(ap); \ + \ + return res; \ +} + +JNI_CALL_STATIC_METHOD(Boolean, jboolean, Int) +JNI_CALL_STATIC_METHOD(Byte, jbyte, Int) +JNI_CALL_STATIC_METHOD(Char, jchar, Int) +JNI_CALL_STATIC_METHOD(Short, jshort, Int) +JNI_CALL_STATIC_METHOD(Int, jint, Int) +JNI_CALL_STATIC_METHOD(Long, jlong, Long) +JNI_CALL_STATIC_METHOD(Float, jfloat, Float) +JNI_CALL_STATIC_METHOD(Double, jdouble, Double) + + +#define JNI_CALL_STATIC_METHOD_V(name, type, intern) \ +type _Jv_JNI_CallStatic##name##MethodV(JNIEnv *env, jclass clazz, \ + jmethodID methodID, va_list args) \ +{ \ + methodinfo *m; \ + type res; \ + \ + m = (methodinfo *) methodID; \ + \ + res = _Jv_jni_Call##intern##Method(NULL, NULL, m, args); \ + \ + return res; \ +} + +JNI_CALL_STATIC_METHOD_V(Boolean, jboolean, Int) +JNI_CALL_STATIC_METHOD_V(Byte, jbyte, Int) +JNI_CALL_STATIC_METHOD_V(Char, jchar, Int) +JNI_CALL_STATIC_METHOD_V(Short, jshort, Int) +JNI_CALL_STATIC_METHOD_V(Int, jint, Int) +JNI_CALL_STATIC_METHOD_V(Long, jlong, Long) +JNI_CALL_STATIC_METHOD_V(Float, jfloat, Float) +JNI_CALL_STATIC_METHOD_V(Double, jdouble, Double) + + +#define JNI_CALL_STATIC_METHOD_A(name, type, intern) \ +type _Jv_JNI_CallStatic##name##MethodA(JNIEnv *env, jclass clazz, \ + jmethodID methodID, const jvalue *args) \ +{ \ + methodinfo *m; \ + type res; \ + \ + m = (methodinfo *) methodID; \ + \ + res = _Jv_jni_Call##intern##MethodA(NULL, NULL, m, args); \ + \ + return res; \ +} + +JNI_CALL_STATIC_METHOD_A(Boolean, jboolean, Int) +JNI_CALL_STATIC_METHOD_A(Byte, jbyte, Int) +JNI_CALL_STATIC_METHOD_A(Char, jchar, Int) +JNI_CALL_STATIC_METHOD_A(Short, jshort, Int) +JNI_CALL_STATIC_METHOD_A(Int, jint, Int) +JNI_CALL_STATIC_METHOD_A(Long, jlong, Long) +JNI_CALL_STATIC_METHOD_A(Float, jfloat, Float) +JNI_CALL_STATIC_METHOD_A(Double, jdouble, Double) -jdouble _Jv_JNI_CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID, - ...) +jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz, + jmethodID methodID, ...) { - java_objectheader *o; - methodinfo *m; - va_list ap; - jdouble d; + methodinfo *m; + java_handle_t *o; + va_list ap; - o = (java_objectheader *) obj; m = (methodinfo *) methodID; va_start(ap, methodID); - d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, ap); + o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap); va_end(ap); - return d; + return _Jv_JNI_NewLocalRef(env, (jobject) o); } -jdouble _Jv_JNI_CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) +jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz, + jmethodID methodID, va_list args) { - java_objectheader *o; - methodinfo *m; - jdouble d; + methodinfo *m; + java_handle_t *o; - o = (java_objectheader *) obj; m = (methodinfo *) methodID; - d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, args); + o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args); - return d; + return _Jv_JNI_NewLocalRef(env, (jobject) o); } -jdouble _Jv_JNI_CallDoubleMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) +jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz, + jmethodID methodID, const jvalue *args) { - log_text("JNI-Call: CallDoubleMethodA: IMPLEMENT ME!"); + methodinfo *m; + java_handle_t *o; - return 0; -} + m = (methodinfo *) methodID; + o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args); + return _Jv_JNI_NewLocalRef(env, (jobject) o); +} -void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) + +void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz, + jmethodID methodID, ...) { - java_objectheader *o; - methodinfo *m; - va_list ap; + methodinfo *m; + va_list ap; - o = (java_objectheader *) obj; m = (methodinfo *) methodID; va_start(ap, methodID); - _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap); + _Jv_jni_CallVoidMethod(NULL, NULL, m, ap); va_end(ap); } -void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) +void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz, + jmethodID methodID, va_list args) { - java_objectheader *o; - methodinfo *m; + methodinfo *m; - o = (java_objectheader *) obj; m = (methodinfo *) methodID; - _Jv_jni_CallVoidMethod(o, o->vftbl, m, args); + _Jv_jni_CallVoidMethod(NULL, NULL, m, args); } -void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) +void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz, + jmethodID methodID, const jvalue * args) { - java_objectheader *o; - methodinfo *m; + methodinfo *m; - o = (java_objectheader *) obj; m = (methodinfo *) methodID; - _Jv_jni_CallVoidMethodA(o, o->vftbl, m, args); + _Jv_jni_CallVoidMethodA(NULL, NULL, m, args); } +/* Accessing Static Fields ****************************************************/ -jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - java_objectheader *r; - va_list ap; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap); - va_end(ap); +/* GetStaticFieldID ************************************************************ - return _Jv_JNI_NewLocalRef(env, (jobject) r); -} + Returns the field ID for a static field of a class. The field is + specified by its name and signature. The GetStaticField and + SetStaticField families of accessor functions use field IDs + to retrieve static fields. +*******************************************************************************/ -jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - va_list args) +jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, + const char *sig) { - java_objectheader *o; - classinfo *c; - methodinfo *m; - java_objectheader *r; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args); - - return _Jv_JNI_NewLocalRef(env, (jobject) r); -} - - -jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!"); - - return _Jv_JNI_NewLocalRef(env, NULL); -} - - - -jboolean _Jv_JNI_CallNonvirtualBooleanMethod(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jboolean b; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap); - va_end(ap); - - return b; -} - - -jboolean _Jv_JNI_CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jboolean b; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); - - return b; -} - - -jboolean _Jv_JNI_CallNonvirtualBooleanMethodA(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualBooleanMethodA: IMPLEMENT ME!"); - - return 0; -} - - -jbyte _Jv_JNI_CallNonvirtualByteMethod(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jbyte b; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap); - va_end(ap); - - return b; -} - - -jbyte _Jv_JNI_CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jbyte b; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); - - return b; -} - - -jbyte _Jv_JNI_CallNonvirtualByteMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualByteMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -jchar _Jv_JNI_CallNonvirtualCharMethod(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jchar ch; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap); - va_end(ap); - - return ch; -} - - -jchar _Jv_JNI_CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jchar ch; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); - - return ch; -} - - -jchar _Jv_JNI_CallNonvirtualCharMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualCharMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -jshort _Jv_JNI_CallNonvirtualShortMethod(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jshort s; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - s = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap); - va_end(ap); - - return s; -} - - -jshort _Jv_JNI_CallNonvirtualShortMethodV(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jshort s; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - s = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); - - return s; -} - - -jshort _Jv_JNI_CallNonvirtualShortMethodA(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualShortMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -jint _Jv_JNI_CallNonvirtualIntMethod(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jint i; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - i = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap); - va_end(ap); - - return i; -} - - -jint _Jv_JNI_CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jint i; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - i = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); - - return i; -} - - -jint _Jv_JNI_CallNonvirtualIntMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualIntMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -jlong _Jv_JNI_CallNonvirtualLongMethod(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jlong l; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - l = _Jv_jni_CallLongMethod(o, c->vftbl, m, ap); - va_end(ap); - - return l; -} - - -jlong _Jv_JNI_CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jlong l; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - l = _Jv_jni_CallLongMethod(o, c->vftbl, m, args); - - return l; -} - - -jlong _Jv_JNI_CallNonvirtualLongMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualLongMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -jfloat _Jv_JNI_CallNonvirtualFloatMethod(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jfloat f; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, ap); - va_end(ap); - - return f; -} - - -jfloat _Jv_JNI_CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jfloat f; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, args); - - return f; -} - - -jfloat _Jv_JNI_CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -jdouble _Jv_JNI_CallNonvirtualDoubleMethod(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - jdouble d; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, ap); - va_end(ap); - - return d; -} - - -jdouble _Jv_JNI_CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - jdouble d; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, args); - - return d; -} - - -jdouble _Jv_JNI_CallNonvirtualDoubleMethodA(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualDoubleMethodA: IMPLEMENT ME!"); - - return 0; -} - - - -void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, ...) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - va_list ap; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap); - va_end(ap); -} - - -void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, va_list args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethod(o, c->vftbl, m, args); -} - - -void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) -{ - java_objectheader *o; - classinfo *c; - methodinfo *m; - - o = (java_objectheader *) obj; - c = (classinfo *) clazz; - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args); -} - - -/* Accessing Fields of Objects ************************************************/ - -/* GetFieldID ****************************************************************** - - Returns the field ID for an instance (nonstatic) field of a - class. The field is specified by its name and signature. The - GetField and SetField families of accessor functions - use field IDs to retrieve object fields. - -*******************************************************************************/ - -jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - fieldinfo *f; - utf *uname; - utf *udesc; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - - /* XXX NPE check? */ - - uname = utf_new_char((char *) name); - udesc = utf_new_char((char *) sig); - - f = class_findfield(c, uname, udesc); - - if (f == NULL) - exceptions_throw_nosuchfielderror(c, uname); - - return (jfieldID) f; -} - - -/* GetField Routines ***************************************************** - - This family of accessor routines returns the value of an instance - (nonstatic) field of an object. The field to access is specified by - a field ID obtained by calling GetFieldID(). - -*******************************************************************************/ - -jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - java_objectheader *o; - - STATISTICS(jniinvokation()); - - o = GET_FIELD(obj, java_objectheader*, fieldID); - - return _Jv_JNI_NewLocalRef(env, (jobject) o); -} - - -jboolean _Jv_JNI_GetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - s4 i; - - STATISTICS(jniinvokation()); - - i = GET_FIELD(obj, s4, fieldID); - - return (jboolean) i; -} - - -jbyte _Jv_JNI_GetByteField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - s4 i; - - STATISTICS(jniinvokation()); - - i = GET_FIELD(obj, s4, fieldID); - - return (jbyte) i; -} - - -jchar _Jv_JNI_GetCharField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - s4 i; - - STATISTICS(jniinvokation()); - - i = GET_FIELD(obj, s4, fieldID); - - return (jchar) i; -} - - -jshort _Jv_JNI_GetShortField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - s4 i; - - STATISTICS(jniinvokation()); - - i = GET_FIELD(obj, s4, fieldID); - - return (jshort) i; -} - - -jint _Jv_JNI_GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - java_objectheader *o; - fieldinfo *f; - s4 i; - - STATISTICS(jniinvokation()); - - o = (java_objectheader *) obj; - f = (fieldinfo *) fieldID; - - i = GET_FIELD(o, s4, f); - - return i; -} - - -jlong _Jv_JNI_GetLongField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - s8 l; - - STATISTICS(jniinvokation()); - - l = GET_FIELD(obj, s8, fieldID); - - return l; -} - - -jfloat _Jv_JNI_GetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - float f; - - STATISTICS(jniinvokation()); - - f = GET_FIELD(obj, float, fieldID); - - return f; -} - - -jdouble _Jv_JNI_GetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - double d; - - STATISTICS(jniinvokation()); - - d = GET_FIELD(obj, double, fieldID); - - return d; -} - - -/* SetField Routines ***************************************************** - - This family of accessor routines sets the value of an instance - (nonstatic) field of an object. The field to access is specified by - a field ID obtained by calling GetFieldID(). - -*******************************************************************************/ - -void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, - jobject value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, java_objectheader*, fieldID, value); -} - - -void _Jv_JNI_SetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID, - jboolean value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, s4, fieldID, value); -} - - -void _Jv_JNI_SetByteField(JNIEnv *env, jobject obj, jfieldID fieldID, - jbyte value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, s4, fieldID, value); -} - - -void _Jv_JNI_SetCharField(JNIEnv *env, jobject obj, jfieldID fieldID, - jchar value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, s4, fieldID, value); -} - - -void _Jv_JNI_SetShortField(JNIEnv *env, jobject obj, jfieldID fieldID, - jshort value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, s4, fieldID, value); -} - - -void _Jv_JNI_SetIntField(JNIEnv *env, jobject obj, jfieldID fieldID, jint value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, s4, fieldID, value); -} - - -void _Jv_JNI_SetLongField(JNIEnv *env, jobject obj, jfieldID fieldID, - jlong value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, s8, fieldID, value); -} - - -void _Jv_JNI_SetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID, - jfloat value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, float, fieldID, value); -} - - -void _Jv_JNI_SetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID, - jdouble value) -{ - STATISTICS(jniinvokation()); - - SET_FIELD(obj, double, fieldID, value); -} - - -/* Calling Static Methods *****************************************************/ - -/* GetStaticMethodID *********************************************************** - - Returns the method ID for a static method of a class. The method is - specified by its name and signature. - - GetStaticMethodID() causes an uninitialized class to be - initialized. - -*******************************************************************************/ - -jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - utf *uname; - utf *udesc; - methodinfo *m; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - - if (!c) - return NULL; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return NULL; - - /* try to get the static method of the class */ - - uname = utf_new_char((char *) name); - udesc = utf_new_char((char *) sig); - - m = class_resolvemethod(c, uname, udesc); - - if ((m == NULL) || !(m->flags & ACC_STATIC)) { - exceptions_throw_nosuchmethoderror(c, uname, udesc); - - return NULL; - } - - return (jmethodID) m; -} - - -jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - java_objectheader *o; - va_list ap; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap); - va_end(ap); - - return _Jv_JNI_NewLocalRef(env, (jobject) o); -} - - -jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - java_objectheader *o; - - m = (methodinfo *) methodID; - - o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args); - - return _Jv_JNI_NewLocalRef(env, (jobject) o); -} - - -jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - java_objectheader *o; - - m = (methodinfo *) methodID; - - o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args); - - return _Jv_JNI_NewLocalRef(env, (jobject) o); -} - - -jboolean _Jv_JNI_CallStaticBooleanMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jboolean b; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap); - va_end(ap); - - return b; -} - - -jboolean _Jv_JNI_CallStaticBooleanMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jboolean b; - - m = (methodinfo *) methodID; - - b = _Jv_jni_CallIntMethod(NULL, NULL, m, args); - - return b; -} - - -jboolean _Jv_JNI_CallStaticBooleanMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jboolean b; - - m = (methodinfo *) methodID; - - b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args); - - return b; -} - - -jbyte _Jv_JNI_CallStaticByteMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jbyte b; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap); - va_end(ap); - - return b; -} - - -jbyte _Jv_JNI_CallStaticByteMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jbyte b; - - m = (methodinfo *) methodID; - - b = _Jv_jni_CallIntMethod(NULL, NULL, m, args); - - return b; -} - - -jbyte _Jv_JNI_CallStaticByteMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jbyte b; - - m = (methodinfo *) methodID; - - b = _Jv_jni_CallIntMethodA(NULL, NULL, m, args); - - return b; -} - - -jchar _Jv_JNI_CallStaticCharMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jchar c; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - c = _Jv_jni_CallIntMethod(NULL, NULL, m, ap); - va_end(ap); - - return c; -} - - -jchar _Jv_JNI_CallStaticCharMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jchar c; - - m = (methodinfo *) methodID; - - c = _Jv_jni_CallIntMethod(NULL, NULL, m, args); - - return c; -} - - -jchar _Jv_JNI_CallStaticCharMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jchar c; - - m = (methodinfo *) methodID; - - c = _Jv_jni_CallIntMethodA(NULL, NULL, m, args); - - return c; -} - - -jshort _Jv_JNI_CallStaticShortMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jshort s; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - s = _Jv_jni_CallIntMethod(NULL, NULL, m, ap); - va_end(ap); - - return s; -} - - -jshort _Jv_JNI_CallStaticShortMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jshort s; - - m = (methodinfo *) methodID; - - s = _Jv_jni_CallIntMethod(NULL, NULL, m, args); - - return s; -} - - -jshort _Jv_JNI_CallStaticShortMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jshort s; - - m = (methodinfo *) methodID; - - s = _Jv_jni_CallIntMethodA(NULL, NULL, m, args); - - return s; -} - - -jint _Jv_JNI_CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID, - ...) -{ - methodinfo *m; - va_list ap; - jint i; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - i = _Jv_jni_CallIntMethod(NULL, NULL, m, ap); - va_end(ap); - - return i; -} - - -jint _Jv_JNI_CallStaticIntMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jint i; - - m = (methodinfo *) methodID; - - i = _Jv_jni_CallIntMethod(NULL, NULL, m, args); - - return i; -} - - -jint _Jv_JNI_CallStaticIntMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jint i; - - m = (methodinfo *) methodID; - - i = _Jv_jni_CallIntMethodA(NULL, NULL, m, args); - - return i; -} - - -jlong _Jv_JNI_CallStaticLongMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jlong l; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - l = _Jv_jni_CallLongMethod(NULL, NULL, m, ap); - va_end(ap); - - return l; -} - - -jlong _Jv_JNI_CallStaticLongMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jlong l; - - m = (methodinfo *) methodID; - - l = _Jv_jni_CallLongMethod(NULL, NULL, m, args); - - return l; -} - - -jlong _Jv_JNI_CallStaticLongMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jlong l; - - m = (methodinfo *) methodID; - - l = _Jv_jni_CallLongMethodA(NULL, NULL, m, args); - - return l; -} - - - -jfloat _Jv_JNI_CallStaticFloatMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jfloat f; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - f = _Jv_jni_CallFloatMethod(NULL, NULL, m, ap); - va_end(ap); - - return f; -} - - -jfloat _Jv_JNI_CallStaticFloatMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jfloat f; - - m = (methodinfo *) methodID; - - f = _Jv_jni_CallFloatMethod(NULL, NULL, m, args); - - return f; -} - - -jfloat _Jv_JNI_CallStaticFloatMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jfloat f; - - m = (methodinfo *) methodID; - - f = _Jv_jni_CallFloatMethodA(NULL, NULL, m, args); - - return f; -} - - -jdouble _Jv_JNI_CallStaticDoubleMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - jdouble d; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, ap); - va_end(ap); - - return d; -} - - -jdouble _Jv_JNI_CallStaticDoubleMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - jdouble d; - - m = (methodinfo *) methodID; - - d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, args); - - return d; -} - - -jdouble _Jv_JNI_CallStaticDoubleMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - jdouble d; - - m = (methodinfo *) methodID; - - d = _Jv_jni_CallDoubleMethodA(NULL, NULL, m, args); - - return d; -} - - -void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - _Jv_jni_CallVoidMethod(NULL, NULL, m, ap); - va_end(ap); -} - - -void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethod(NULL, NULL, m, args); -} - - -void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue * args) -{ - methodinfo *m; - - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethodA(NULL, NULL, m, args); -} - - -/* Accessing Static Fields ****************************************************/ - -/* GetStaticFieldID ************************************************************ - - Returns the field ID for a static field of a class. The field is - specified by its name and signature. The GetStaticField and - SetStaticField families of accessor functions use field IDs - to retrieve static fields. - -*******************************************************************************/ - -jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - fieldinfo *f; - utf *uname; - utf *usig; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - - uname = utf_new_char((char *) name); - usig = utf_new_char((char *) sig); - - f = class_findfield(c, uname, usig); - - if (f == NULL) - exceptions_throw_nosuchfielderror(c, uname); - - return (jfieldID) f; -} - - -/* GetStaticField ******************************************************** - - This family of accessor routines returns the value of a static - field of an object. - -*******************************************************************************/ - -jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz, - jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return NULL; - - return _Jv_JNI_NewLocalRef(env, f->value.a); -} - - -jboolean _Jv_JNI_GetStaticBooleanField(JNIEnv *env, jclass clazz, - jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return false; - - return f->value.i; -} - - -jbyte _Jv_JNI_GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0; - - return f->value.i; -} - - -jchar _Jv_JNI_GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0; - - return f->value.i; -} - - -jshort _Jv_JNI_GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0; - - return f->value.i; -} - - -jint _Jv_JNI_GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0; - - return f->value.i; -} - - -jlong _Jv_JNI_GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0; - - return f->value.l; -} - - -jfloat _Jv_JNI_GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0.0; - - return f->value.f; -} - - -jdouble _Jv_JNI_GetStaticDoubleField(JNIEnv *env, jclass clazz, - jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return 0.0; - - return f->value.d; -} - - -/* SetStaticField ******************************************************* - - This family of accessor routines sets the value of a static field - of an object. - -*******************************************************************************/ - -void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jobject value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.a = value; -} - - -void _Jv_JNI_SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jboolean value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.i = value; -} - - -void _Jv_JNI_SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jbyte value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.i = value; -} - - -void _Jv_JNI_SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jchar value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.i = value; -} - - -void _Jv_JNI_SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jshort value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.i = value; -} - - -void _Jv_JNI_SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jint value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.i = value; -} - - -void _Jv_JNI_SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jlong value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.l = value; -} - - -void _Jv_JNI_SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jfloat value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.f = value; -} - - -void _Jv_JNI_SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jdouble value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = (classinfo *) clazz; - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value.d = value; -} - - -/* String Operations **********************************************************/ - -/* NewString ******************************************************************* - - Create new java.lang.String object from an array of Unicode - characters. - -*******************************************************************************/ - -jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len) -{ - java_lang_String *s; - java_chararray *a; - u4 i; - - STATISTICS(jniinvokation()); - - s = (java_lang_String *) builtin_new(class_java_lang_String); - a = builtin_newarray_char(len); - - /* javastring or characterarray could not be created */ - if ((a == NULL) || (s == NULL)) - return NULL; - - /* copy text */ - for (i = 0; i < len; i++) - a->data[i] = buf[i]; - - s->value = a; - s->offset = 0; - s->count = len; - - return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s); -} - - -static jchar emptyStringJ[]={0,0}; - -/* GetStringLength ************************************************************* - - Returns the length (the count of Unicode characters) of a Java - string. - -*******************************************************************************/ - -jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str) -{ - java_lang_String *s; - - TRACEJNICALLS("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str); - - s = (java_lang_String *) str; - - return s->count; -} - - -/******************** convertes javastring to u2-array ****************************/ - -u2 *javastring_tou2(jstring so) -{ - java_lang_String *s; - java_chararray *a; - u2 *stringbuffer; - u4 i; - - STATISTICS(jniinvokation()); - - s = (java_lang_String *) so; - - if (!s) - return NULL; - - a = s->value; - - if (!a) - return NULL; - - /* allocate memory */ - - stringbuffer = MNEW(u2, s->count + 1); - - /* copy text */ - - for (i = 0; i < s->count; i++) - stringbuffer[i] = a->data[s->offset + i]; - - /* terminate string */ - - stringbuffer[i] = '\0'; - - return stringbuffer; -} - - -/* GetStringChars ************************************************************** - - Returns a pointer to the array of Unicode characters of the - string. This pointer is valid until ReleaseStringChars() is called. - -*******************************************************************************/ - -const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy) -{ - jchar *jc; - - STATISTICS(jniinvokation()); - - jc = javastring_tou2(str); - - if (jc) { - if (isCopy) - *isCopy = JNI_TRUE; - - return jc; - } - - if (isCopy) - *isCopy = JNI_TRUE; - - return emptyStringJ; -} - - -/* ReleaseStringChars ********************************************************** - - Informs the VM that the native code no longer needs access to - chars. The chars argument is a pointer obtained from string using - GetStringChars(). - -*******************************************************************************/ - -void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars) -{ - STATISTICS(jniinvokation()); - - if (chars == emptyStringJ) - return; - - MFREE(((jchar *) chars), jchar, ((java_lang_String *) str)->count + 1); -} - - -/* NewStringUTF **************************************************************** - - Constructs a new java.lang.String object from an array of UTF-8 - characters. - -*******************************************************************************/ - -jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes) -{ - java_lang_String *s; - - TRACEJNICALLS("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes); - - s = (java_lang_String *) javastring_safe_new_from_utf8(bytes); - - return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s); -} - - -/****************** returns the utf8 length in bytes of a string *******************/ - -jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string) -{ - java_lang_String *s; - s4 length; - - TRACEJNICALLS("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string); - - s = (java_lang_String *) string; - - length = u2_utflength(s->value->data, s->count); - - return length; -} - - -/* GetStringUTFChars *********************************************************** - - Returns a pointer to an array of UTF-8 characters of the - string. This array is valid until it is released by - ReleaseStringUTFChars(). - -*******************************************************************************/ - -const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string, - jboolean *isCopy) -{ - utf *u; - - STATISTICS(jniinvokation()); - - if (string == NULL) - return ""; - - if (isCopy) - *isCopy = JNI_TRUE; - - u = javastring_toutf((java_objectheader *) string, false); - - if (u != NULL) - return u->text; - - return ""; -} - - -/* ReleaseStringUTFChars ******************************************************* - - Informs the VM that the native code no longer needs access to - utf. The utf argument is a pointer derived from string using - GetStringUTFChars(). - -*******************************************************************************/ - -void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf) -{ - STATISTICS(jniinvokation()); - - /* XXX we don't release utf chars right now, perhaps that should be done - later. Since there is always one reference the garbage collector will - never get them */ -} - - -/* Array Operations ***********************************************************/ - -/* GetArrayLength ************************************************************** - - Returns the number of elements in the array. - -*******************************************************************************/ - -jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array) -{ - java_arrayheader *a; - - STATISTICS(jniinvokation()); - - a = (java_arrayheader *) array; - - return a->size; -} - - -/* NewObjectArray ************************************************************** - - Constructs a new array holding objects in class elementClass. All - elements are initially set to initialElement. - -*******************************************************************************/ - -jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length, - jclass elementClass, jobject initialElement) -{ - classinfo *c; - java_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, c); - - if (oa == NULL) - return NULL; - - /* set all elements to initialElement */ - - for (i = 0; i < length; i++) - oa->data[i] = o; - - return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa); -} - - -jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array, - jsize index) -{ - java_objectarray *oa; - java_objectheader *o; - - STATISTICS(jniinvokation()); - - oa = (java_objectarray *) array; - - if (index >= oa->header.size) { - exceptions_throw_arrayindexoutofboundsexception(); - return NULL; - } - - o = oa->data[index]; - - return _Jv_JNI_NewLocalRef(env, (jobject) o); -} - - -void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array, - jsize index, jobject val) -{ - java_objectarray *oa; - java_objectheader *o; + classinfo *c; + fieldinfo *f; + utf *uname; + utf *usig; STATISTICS(jniinvokation()); - oa = (java_objectarray *) array; - o = (java_objectheader *) val; - - if (index >= oa->header.size) { - exceptions_throw_arrayindexoutofboundsexception(); - return; - } + c = (classinfo *) clazz; - /* check if the class of value is a subclass of the element class - of the array */ + uname = utf_new_char((char *) name); + usig = utf_new_char((char *) sig); - if (!builtin_canstore(oa, o)) - return; + f = class_findfield(c, uname, usig); + + if (f == NULL) + exceptions_throw_nosuchfielderror(c, uname); - oa->data[index] = o; + return (jfieldID) f; } -jbooleanArray _Jv_JNI_NewBooleanArray(JNIEnv *env, jsize len) -{ - java_booleanarray *ba; - - STATISTICS(jniinvokation()); +/* GetStaticField ******************************************************** - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } + This family of accessor routines returns the value of a static + field of an object. - ba = builtin_newarray_boolean(len); +*******************************************************************************/ - return (jbooleanArray) _Jv_JNI_NewLocalRef(env, (jobject) ba); -} +#define JNI_GET_STATIC_FIELD(name, type, field) \ +type _Jv_JNI_GetStatic##name##Field(JNIEnv *env, jclass clazz, \ + jfieldID fieldID) \ +{ \ + classinfo *c; \ + fieldinfo *f; \ + \ + STATISTICS(jniinvokation()); \ + \ + c = (classinfo *) clazz; \ + f = (fieldinfo *) fieldID; \ + \ + if (!(c->state & CLASS_INITIALIZED)) \ + if (!initialize_class(c)) \ + return 0; \ + \ + return f->value->field; \ +} + +JNI_GET_STATIC_FIELD(Boolean, jboolean, i) +JNI_GET_STATIC_FIELD(Byte, jbyte, i) +JNI_GET_STATIC_FIELD(Char, jchar, i) +JNI_GET_STATIC_FIELD(Short, jshort, i) +JNI_GET_STATIC_FIELD(Int, jint, i) +JNI_GET_STATIC_FIELD(Long, jlong, l) +JNI_GET_STATIC_FIELD(Float, jfloat, f) +JNI_GET_STATIC_FIELD(Double, jdouble, d) -jbyteArray _Jv_JNI_NewByteArray(JNIEnv *env, jsize len) +jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz, + jfieldID fieldID) { - java_bytearray *ba; + classinfo *c; + fieldinfo *f; STATISTICS(jniinvokation()); - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } + c = (classinfo *) clazz; + f = (fieldinfo *) fieldID; - ba = builtin_newarray_byte(len); + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return NULL; - return (jbyteArray) _Jv_JNI_NewLocalRef(env, (jobject) ba); + return _Jv_JNI_NewLocalRef(env, f->value->a); } -jcharArray _Jv_JNI_NewCharArray(JNIEnv *env, jsize len) -{ - java_chararray *ca; - - STATISTICS(jniinvokation()); +/* SetStaticField ******************************************************* - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } + This family of accessor routines sets the value of a static field + of an object. - ca = builtin_newarray_char(len); +*******************************************************************************/ - return (jcharArray) _Jv_JNI_NewLocalRef(env, (jobject) ca); -} +#define JNI_SET_STATIC_FIELD(name, type, field) \ +void _Jv_JNI_SetStatic##name##Field(JNIEnv *env, jclass clazz, \ + jfieldID fieldID, \ + type value) \ +{ \ + classinfo *c; \ + fieldinfo *f; \ + \ + STATISTICS(jniinvokation()); \ + \ + c = (classinfo *) clazz; \ + f = (fieldinfo *) fieldID; \ + \ + if (!(c->state & CLASS_INITIALIZED)) \ + if (!initialize_class(c)) \ + return; \ + \ + f->value->field = value; \ +} + +JNI_SET_STATIC_FIELD(Boolean, jboolean, i) +JNI_SET_STATIC_FIELD(Byte, jbyte, i) +JNI_SET_STATIC_FIELD(Char, jchar, i) +JNI_SET_STATIC_FIELD(Short, jshort, i) +JNI_SET_STATIC_FIELD(Int, jint, i) +JNI_SET_STATIC_FIELD(Long, jlong, l) +JNI_SET_STATIC_FIELD(Float, jfloat, f) +JNI_SET_STATIC_FIELD(Double, jdouble, d) -jshortArray _Jv_JNI_NewShortArray(JNIEnv *env, jsize len) +void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, + jobject value) { - java_shortarray *sa; + classinfo *c; + fieldinfo *f; STATISTICS(jniinvokation()); - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } + c = (classinfo *) clazz; + f = (fieldinfo *) fieldID; - sa = builtin_newarray_short(len); + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return; - return (jshortArray) _Jv_JNI_NewLocalRef(env, (jobject) sa); + f->value->a = value; } -jintArray _Jv_JNI_NewIntArray(JNIEnv *env, jsize len) -{ - java_intarray *ia; - - STATISTICS(jniinvokation()); - - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } +/* String Operations **********************************************************/ - ia = builtin_newarray_int(len); +/* NewString ******************************************************************* - return (jintArray) _Jv_JNI_NewLocalRef(env, (jobject) ia); -} + Create new java.lang.String object from an array of Unicode + characters. +*******************************************************************************/ -jlongArray _Jv_JNI_NewLongArray(JNIEnv *env, jsize len) +jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len) { - java_longarray *la; + java_lang_String *s; + java_chararray *a; + u4 i; STATISTICS(jniinvokation()); + + s = (java_lang_String *) builtin_new(class_java_lang_String); + a = builtin_newarray_char(len); - if (len < 0) { - exceptions_throw_negativearraysizeexception(); + /* javastring or characterarray could not be created */ + if ((a == NULL) || (s == NULL)) return NULL; - } - - la = builtin_newarray_long(len); - - return (jlongArray) _Jv_JNI_NewLocalRef(env, (jobject) la); -} + /* copy text */ + for (i = 0; i < len; i++) + a->data[i] = buf[i]; -jfloatArray _Jv_JNI_NewFloatArray(JNIEnv *env, jsize len) -{ - java_floatarray *fa; - - STATISTICS(jniinvokation()); - - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } - - fa = builtin_newarray_float(len); + LLNI_field_set_ref(s, value , a); + LLNI_field_set_val(s, offset, 0); + LLNI_field_set_val(s, count , len); - return (jfloatArray) _Jv_JNI_NewLocalRef(env, (jobject) fa); + return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s); } -jdoubleArray _Jv_JNI_NewDoubleArray(JNIEnv *env, jsize len) -{ - java_doublearray *da; - - STATISTICS(jniinvokation()); - - if (len < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } - - da = builtin_newarray_double(len); - - return (jdoubleArray) _Jv_JNI_NewLocalRef(env, (jobject) da); -} - +static jchar emptyStringJ[]={0,0}; -/* GetArrayElements ********************************************* +/* GetStringLength ************************************************************* - A family of functions that returns the body of the primitive array. + Returns the length (the count of Unicode characters) of a Java + string. *******************************************************************************/ -jboolean *_Jv_JNI_GetBooleanArrayElements(JNIEnv *env, jbooleanArray array, - jboolean *isCopy) -{ - java_booleanarray *ba; - - STATISTICS(jniinvokation()); - - ba = (java_booleanarray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - return ba->data; -} - - -jbyte *_Jv_JNI_GetByteArrayElements(JNIEnv *env, jbyteArray array, - jboolean *isCopy) -{ - java_bytearray *ba; - - STATISTICS(jniinvokation()); - - ba = (java_bytearray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - return ba->data; -} - - -jchar *_Jv_JNI_GetCharArrayElements(JNIEnv *env, jcharArray array, - jboolean *isCopy) -{ - java_chararray *ca; - - STATISTICS(jniinvokation()); - - ca = (java_chararray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - return ca->data; -} - - -jshort *_Jv_JNI_GetShortArrayElements(JNIEnv *env, jshortArray array, - jboolean *isCopy) -{ - java_shortarray *sa; - - STATISTICS(jniinvokation()); - - sa = (java_shortarray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - return sa->data; -} - - -jint *_Jv_JNI_GetIntArrayElements(JNIEnv *env, jintArray array, - jboolean *isCopy) -{ - java_intarray *ia; - - STATISTICS(jniinvokation()); - - ia = (java_intarray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - return ia->data; -} - - -jlong *_Jv_JNI_GetLongArrayElements(JNIEnv *env, jlongArray array, - jboolean *isCopy) -{ - java_longarray *la; - - STATISTICS(jniinvokation()); - - la = (java_longarray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - /* We cast this one to prevent a compiler warning on 64-bit - systems since GNU Classpath typedef jlong to long long. */ - - return (jlong *) la->data; -} - - -jfloat *_Jv_JNI_GetFloatArrayElements(JNIEnv *env, jfloatArray array, - jboolean *isCopy) +jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str) { - java_floatarray *fa; + java_lang_String *s; + jsize len; - STATISTICS(jniinvokation()); + TRACEJNICALLS("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str); - fa = (java_floatarray *) array; + s = (java_lang_String *) str; - if (isCopy) - *isCopy = JNI_FALSE; + LLNI_field_get_val(s, count, len); - return fa->data; + return len; } -jdouble *_Jv_JNI_GetDoubleArrayElements(JNIEnv *env, jdoubleArray array, - jboolean *isCopy) +/******************** convertes javastring to u2-array ****************************/ + +u2 *javastring_tou2(jstring so) { - java_doublearray *da; + java_lang_String *s; + java_chararray *a; + u2 *stringbuffer; + u4 i; STATISTICS(jniinvokation()); + + s = (java_lang_String *) so; - da = (java_doublearray *) array; - - if (isCopy) - *isCopy = JNI_FALSE; - - return da->data; -} - - -/* ReleaseArrayElements ***************************************** - - A family of functions that informs the VM that the native code no - longer needs access to elems. The elems argument is a pointer - derived from array using the corresponding - GetArrayElements() function. If necessary, this - function copies back all changes made to elems to the original - array. - -*******************************************************************************/ + if (!s) + return NULL; -void _Jv_JNI_ReleaseBooleanArrayElements(JNIEnv *env, jbooleanArray array, - jboolean *elems, jint mode) -{ - java_booleanarray *ba; + LLNI_field_get_ref(s, value, a); - STATISTICS(jniinvokation()); + if (!a) + return NULL; - ba = (java_booleanarray *) array; - - if (elems != ba->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(ba->data, elems, u1, ba->header.size); - break; - case 0: - MCOPY(ba->data, elems, u1, ba->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } -} + /* allocate memory */ + stringbuffer = MNEW(u2, LLNI_field_direct(s, count) + 1); -void _Jv_JNI_ReleaseByteArrayElements(JNIEnv *env, jbyteArray array, - jbyte *elems, jint mode) -{ - java_bytearray *ba; + /* copy text */ - STATISTICS(jniinvokation()); + for (i = 0; i < LLNI_field_direct(s, count); i++) + stringbuffer[i] = a->data[LLNI_field_direct(s, offset) + i]; + + /* terminate string */ - ba = (java_bytearray *) array; + stringbuffer[i] = '\0'; - if (elems != ba->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(ba->data, elems, s1, ba->header.size); - break; - case 0: - MCOPY(ba->data, elems, s1, ba->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } + return stringbuffer; } -void _Jv_JNI_ReleaseCharArrayElements(JNIEnv *env, jcharArray array, - jchar *elems, jint mode) -{ - java_chararray *ca; - - STATISTICS(jniinvokation()); +/* GetStringChars ************************************************************** - ca = (java_chararray *) array; - - if (elems != ca->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(ca->data, elems, u2, ca->header.size); - break; - case 0: - MCOPY(ca->data, elems, u2, ca->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } -} + Returns a pointer to the array of Unicode characters of the + string. This pointer is valid until ReleaseStringChars() is called. +*******************************************************************************/ -void _Jv_JNI_ReleaseShortArrayElements(JNIEnv *env, jshortArray array, - jshort *elems, jint mode) -{ - java_shortarray *sa; +const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy) +{ + jchar *jc; STATISTICS(jniinvokation()); - sa = (java_shortarray *) array; - - if (elems != sa->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(sa->data, elems, s2, sa->header.size); - break; - case 0: - MCOPY(sa->data, elems, s2, sa->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } -} + jc = javastring_tou2(str); + if (jc) { + if (isCopy) + *isCopy = JNI_TRUE; -void _Jv_JNI_ReleaseIntArrayElements(JNIEnv *env, jintArray array, jint *elems, - jint mode) -{ - java_intarray *ia; + return jc; + } - STATISTICS(jniinvokation()); + if (isCopy) + *isCopy = JNI_TRUE; - ia = (java_intarray *) array; - - if (elems != ia->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(ia->data, elems, s4, ia->header.size); - break; - case 0: - MCOPY(ia->data, elems, s4, ia->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } + return emptyStringJ; } -void _Jv_JNI_ReleaseLongArrayElements(JNIEnv *env, jlongArray array, - jlong *elems, jint mode) -{ - java_longarray *la; - - STATISTICS(jniinvokation()); +/* ReleaseStringChars ********************************************************** - la = (java_longarray *) array; - - /* We cast this one to prevent a compiler warning on 64-bit - systems since GNU Classpath typedef jlong to long long. */ - - if ((s8 *) elems != la->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(la->data, elems, s8, la->header.size); - break; - case 0: - MCOPY(la->data, elems, s8, la->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } -} + Informs the VM that the native code no longer needs access to + chars. The chars argument is a pointer obtained from string using + GetStringChars(). +*******************************************************************************/ -void _Jv_JNI_ReleaseFloatArrayElements(JNIEnv *env, jfloatArray array, - jfloat *elems, jint mode) +void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars) { - java_floatarray *fa; + java_lang_String *s; STATISTICS(jniinvokation()); - fa = (java_floatarray *) array; - - if (elems != fa->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(fa->data, elems, float, fa->header.size); - break; - case 0: - MCOPY(fa->data, elems, float, fa->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } -} - - -void _Jv_JNI_ReleaseDoubleArrayElements(JNIEnv *env, jdoubleArray array, - jdouble *elems, jint mode) -{ - java_doublearray *da; + if (chars == emptyStringJ) + return; - STATISTICS(jniinvokation()); + s = (java_lang_String *) str; - da = (java_doublearray *) array; - - if (elems != da->data) { - switch (mode) { - case JNI_COMMIT: - MCOPY(da->data, elems, double, da->header.size); - break; - case 0: - MCOPY(da->data, elems, double, da->header.size); - /* XXX TWISTI how should it be freed? */ - break; - case JNI_ABORT: - /* XXX TWISTI how should it be freed? */ - break; - } - } + MFREE(((jchar *) chars), jchar, LLNI_field_direct(s, count) + 1); } -/* GetArrayRegion ********************************************** +/* NewStringUTF **************************************************************** - A family of functions that copies a region of a primitive array - into a buffer. + Constructs a new java.lang.String object from an array of UTF-8 + characters. *******************************************************************************/ -void _Jv_JNI_GetBooleanArrayRegion(JNIEnv *env, jbooleanArray array, - jsize start, jsize len, jboolean *buf) +jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes) { - java_booleanarray *ba; + java_lang_String *s; - STATISTICS(jniinvokation()); + TRACEJNICALLS("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes); - ba = (java_booleanarray *) array; + s = (java_lang_String *) javastring_safe_new_from_utf8(bytes); - if ((start < 0) || (len < 0) || (start + len > ba->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &ba->data[start], u1, len); + return (jstring) _Jv_JNI_NewLocalRef(env, (jobject) s); } -void _Jv_JNI_GetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start, - jsize len, jbyte *buf) -{ - java_bytearray *ba; +/****************** returns the utf8 length in bytes of a string *******************/ - STATISTICS(jniinvokation()); +jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string) +{ + java_lang_String *s; + s4 length; - ba = (java_bytearray *) array; + TRACEJNICALLS("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string); - if ((start < 0) || (len < 0) || (start + len > ba->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &ba->data[start], s1, len); -} + s = (java_lang_String *) string; + length = u2_utflength(LLNI_field_direct(s, value)->data, LLNI_field_direct(s, count)); -void _Jv_JNI_GetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start, - jsize len, jchar *buf) -{ - java_chararray *ca; + return length; +} - STATISTICS(jniinvokation()); - ca = (java_chararray *) array; +/* GetStringUTFChars *********************************************************** - if ((start < 0) || (len < 0) || (start + len > ca->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &ca->data[start], u2, len); -} + Returns a pointer to an array of UTF-8 characters of the + string. This array is valid until it is released by + ReleaseStringUTFChars(). +*******************************************************************************/ -void _Jv_JNI_GetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start, - jsize len, jshort *buf) +const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string, + jboolean *isCopy) { - java_shortarray *sa; + utf *u; STATISTICS(jniinvokation()); - sa = (java_shortarray *) array; + if (string == NULL) + return ""; - if ((start < 0) || (len < 0) || (start + len > sa->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &sa->data[start], s2, len); -} + if (isCopy) + *isCopy = JNI_TRUE; + + u = javastring_toutf((java_handle_t *) string, false); + if (u != NULL) + return u->text; -void _Jv_JNI_GetIntArrayRegion(JNIEnv *env, jintArray array, jsize start, - jsize len, jint *buf) -{ - java_intarray *ia; + return ""; +} - STATISTICS(jniinvokation()); - ia = (java_intarray *) array; +/* ReleaseStringUTFChars ******************************************************* - if ((start < 0) || (len < 0) || (start + len > ia->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &ia->data[start], s4, len); -} + Informs the VM that the native code no longer needs access to + utf. The utf argument is a pointer derived from string using + GetStringUTFChars(). +*******************************************************************************/ -void _Jv_JNI_GetLongArrayRegion(JNIEnv *env, jlongArray array, jsize start, - jsize len, jlong *buf) +void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf) { - java_longarray *la; - STATISTICS(jniinvokation()); - la = (java_longarray *) array; - - if ((start < 0) || (len < 0) || (start + len > la->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &la->data[start], s8, len); + /* XXX we don't release utf chars right now, perhaps that should be done + later. Since there is always one reference the garbage collector will + never get them */ } -void _Jv_JNI_GetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start, - jsize len, jfloat *buf) -{ - java_floatarray *fa; - - STATISTICS(jniinvokation()); +/* Array Operations ***********************************************************/ - fa = (java_floatarray *) array; +/* GetArrayLength ************************************************************** - if ((start < 0) || (len < 0) || (start + len > fa->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &fa->data[start], float, len); -} + Returns the number of elements in the array. +*******************************************************************************/ -void _Jv_JNI_GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start, - jsize len, jdouble *buf) +jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array) { - java_doublearray *da; + java_arrayheader *a; STATISTICS(jniinvokation()); - da = (java_doublearray *) array; + a = (java_arrayheader *) array; - if ((start < 0) || (len < 0) || (start + len > da->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(buf, &da->data[start], double, len); + return a->size; } -/* SetArrayRegion ********************************************** +/* NewObjectArray ************************************************************** - A family of functions that copies back a region of a primitive - array from a buffer. + Constructs a new array holding objects in class elementClass. All + elements are initially set to initialElement. *******************************************************************************/ -void _Jv_JNI_SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array, - jsize start, jsize len, const jboolean *buf) +jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length, + jclass elementClass, jobject initialElement) { - java_booleanarray *ba; + classinfo *c; + java_handle_t *o; + java_objectarray *oa; + s4 i; STATISTICS(jniinvokation()); - ba = (java_booleanarray *) array; + c = (classinfo *) elementClass; + o = (java_handle_t *) initialElement; - if ((start < 0) || (len < 0) || (start + len > ba->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&ba->data[start], buf, u1, len); -} + if (length < 0) { + exceptions_throw_negativearraysizeexception(); + return NULL; + } + oa = builtin_anewarray(length, c); -void _Jv_JNI_SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start, - jsize len, const jbyte *buf) -{ - java_bytearray *ba; + if (oa == NULL) + return NULL; - STATISTICS(jniinvokation()); + /* set all elements to initialElement */ - ba = (java_bytearray *) array; + for (i = 0; i < length; i++) + oa->data[i] = o; - if ((start < 0) || (len < 0) || (start + len > ba->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&ba->data[start], buf, s1, len); + return (jobjectArray) _Jv_JNI_NewLocalRef(env, (jobject) oa); } -void _Jv_JNI_SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start, - jsize len, const jchar *buf) +jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array, + jsize index) { - java_chararray *ca; + java_objectarray *oa; + java_handle_t *o; STATISTICS(jniinvokation()); - ca = (java_chararray *) array; + oa = (java_objectarray *) array; - if ((start < 0) || (len < 0) || (start + len > ca->header.size)) + if (index >= oa->header.size) { exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&ca->data[start], buf, u2, len); + return NULL; + } + + o = oa->data[index]; + + return _Jv_JNI_NewLocalRef(env, (jobject) o); } -void _Jv_JNI_SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start, - jsize len, const jshort *buf) +void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array, + jsize index, jobject val) { - java_shortarray *sa; + java_objectarray *oa; + java_handle_t *o; STATISTICS(jniinvokation()); - sa = (java_shortarray *) array; + oa = (java_objectarray *) array; + o = (java_handle_t *) val; - if ((start < 0) || (len < 0) || (start + len > sa->header.size)) + if (index >= oa->header.size) { exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&sa->data[start], buf, s2, len); -} + return; + } + /* check if the class of value is a subclass of the element class + of the array */ -void _Jv_JNI_SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start, - jsize len, const jint *buf) -{ - java_intarray *ia; + if (!builtin_canstore(oa, o)) + return; - STATISTICS(jniinvokation()); + oa->data[index] = o; +} - ia = (java_intarray *) array; - if ((start < 0) || (len < 0) || (start + len > ia->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&ia->data[start], buf, s4, len); +#define JNI_NEW_ARRAY(name, type, intern) \ +type _Jv_JNI_New##name##Array(JNIEnv *env, jsize len) \ +{ \ + java_##intern##array *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + if (len < 0) { \ + exceptions_throw_negativearraysizeexception(); \ + return NULL; \ + } \ + \ + a = builtin_newarray_##intern(len); \ + \ + return (type) _Jv_JNI_NewLocalRef(env, (jobject) a); \ } +JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean) +JNI_NEW_ARRAY(Byte, jbyteArray, byte) +JNI_NEW_ARRAY(Char, jcharArray, char) +JNI_NEW_ARRAY(Short, jshortArray, byte) +JNI_NEW_ARRAY(Int, jintArray, int) +JNI_NEW_ARRAY(Long, jlongArray, long) +JNI_NEW_ARRAY(Float, jfloatArray, float) +JNI_NEW_ARRAY(Double, jdoubleArray, double) -void _Jv_JNI_SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, - jsize len, const jlong *buf) -{ - java_longarray *la; - STATISTICS(jniinvokation()); +/* GetArrayElements ********************************************* - la = (java_longarray *) array; + A family of functions that returns the body of the primitive array. - if ((start < 0) || (len < 0) || (start + len > la->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&la->data[start], buf, s8, len); -} +*******************************************************************************/ +#define JNI_GET_ARRAY_ELEMENTS(name, type, intern) \ +type *_Jv_JNI_Get##name##ArrayElements(JNIEnv *env, type##Array array, \ + jboolean *isCopy) \ +{ \ + java_##intern##array *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + a = (java_##intern##array *) array; \ + \ + if (isCopy) \ + *isCopy = JNI_FALSE; \ + \ + return a->data; \ +} + +JNI_GET_ARRAY_ELEMENTS(Boolean, jboolean, boolean) +JNI_GET_ARRAY_ELEMENTS(Byte, jbyte, byte) +JNI_GET_ARRAY_ELEMENTS(Char, jchar, char) +JNI_GET_ARRAY_ELEMENTS(Short, jshort, short) +JNI_GET_ARRAY_ELEMENTS(Int, jint, int) +JNI_GET_ARRAY_ELEMENTS(Long, jlong, long) +JNI_GET_ARRAY_ELEMENTS(Float, jfloat, float) +JNI_GET_ARRAY_ELEMENTS(Double, jdouble, double) -void _Jv_JNI_SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start, - jsize len, const jfloat *buf) -{ - java_floatarray *fa; - STATISTICS(jniinvokation()); +/* ReleaseArrayElements ***************************************** - fa = (java_floatarray *) array; + A family of functions that informs the VM that the native code no + longer needs access to elems. The elems argument is a pointer + derived from array using the corresponding + GetArrayElements() function. If necessary, this + function copies back all changes made to elems to the original + array. - if ((start < 0) || (len < 0) || (start + len > fa->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&fa->data[start], buf, float, len); -} +*******************************************************************************/ +#define JNI_RELEASE_ARRAY_ELEMENTS(name, type, intern, intern2) \ +void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array, \ + type *elems, jint mode) \ +{ \ + java_##intern##array *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + a = (java_##intern##array *) array; \ + \ + if (elems != a->data) { \ + switch (mode) { \ + case JNI_COMMIT: \ + MCOPY(a->data, elems, intern2, a->header.size); \ + break; \ + case 0: \ + MCOPY(a->data, elems, intern2, a->header.size); \ + /* XXX TWISTI how should it be freed? */ \ + break; \ + case JNI_ABORT: \ + /* XXX TWISTI how should it be freed? */ \ + break; \ + } \ + } \ +} + +JNI_RELEASE_ARRAY_ELEMENTS(Boolean, jboolean, boolean, u1) +JNI_RELEASE_ARRAY_ELEMENTS(Byte, jbyte, byte, s1) +JNI_RELEASE_ARRAY_ELEMENTS(Char, jchar, char, u2) +JNI_RELEASE_ARRAY_ELEMENTS(Short, jshort, short, s2) +JNI_RELEASE_ARRAY_ELEMENTS(Int, jint, int, s4) +JNI_RELEASE_ARRAY_ELEMENTS(Long, jlong, long, s8) +JNI_RELEASE_ARRAY_ELEMENTS(Float, jfloat, float, float) +JNI_RELEASE_ARRAY_ELEMENTS(Double, jdouble, double, double) -void _Jv_JNI_SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start, - jsize len, const jdouble *buf) -{ - java_doublearray *da; - STATISTICS(jniinvokation()); +/* GetArrayRegion ********************************************** + + A family of functions that copies a region of a primitive array + into a buffer. - da = (java_doublearray *) array; +*******************************************************************************/ - if ((start < 0) || (len < 0) || (start + len > da->header.size)) - exceptions_throw_arrayindexoutofboundsexception(); - else - MCOPY(&da->data[start], buf, double, len); -} +#define JNI_GET_ARRAY_REGION(name, type, intern, intern2) \ +void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array, \ + jsize start, jsize len, type *buf) \ +{ \ + java_##intern##array *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + a = (java_##intern##array *) array; \ + \ + if ((start < 0) || (len < 0) || (start + len > a->header.size)) \ + exceptions_throw_arrayindexoutofboundsexception(); \ + else \ + MCOPY(buf, &a->data[start], intern2, len); \ +} + +JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1) +JNI_GET_ARRAY_REGION(Byte, jbyte, byte, s1) +JNI_GET_ARRAY_REGION(Char, jchar, char, u2) +JNI_GET_ARRAY_REGION(Short, jshort, short, s2) +JNI_GET_ARRAY_REGION(Int, jint, int, s4) +JNI_GET_ARRAY_REGION(Long, jlong, long, s8) +JNI_GET_ARRAY_REGION(Float, jfloat, float, float) +JNI_GET_ARRAY_REGION(Double, jdouble, double, double) + + +/* SetArrayRegion ********************************************** + + A family of functions that copies back a region of a primitive + array from a buffer. + +*******************************************************************************/ + +#define JNI_SET_ARRAY_REGION(name, type, intern, intern2) \ +void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array, \ + jsize start, jsize len, const type *buf) \ +{ \ + java_##intern##array *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + a = (java_##intern##array *) array; \ + \ + if ((start < 0) || (len < 0) || (start + len > a->header.size)) \ + exceptions_throw_arrayindexoutofboundsexception(); \ + else \ + MCOPY(&a->data[start], buf, intern2, len); \ +} + +JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1) +JNI_SET_ARRAY_REGION(Byte, jbyte, byte, s1) +JNI_SET_ARRAY_REGION(Char, jchar, char, u2) +JNI_SET_ARRAY_REGION(Short, jshort, short, s2) +JNI_SET_ARRAY_REGION(Int, jint, int, s4) +JNI_SET_ARRAY_REGION(Long, jlong, long, s8) +JNI_SET_ARRAY_REGION(Float, jfloat, float, float) +JNI_SET_ARRAY_REGION(Double, jdouble, double, double) /* Registering Native Methods *************************************************/ @@ -5566,10 +3277,10 @@ void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, STATISTICS(jniinvokation()); s = (java_lang_String *) str; - ca = s->value; + LLNI_field_get_ref(s, value, ca); - if ((start < 0) || (len < 0) || (start > s->count) || - (start + len > s->count)) { + if ((start < 0) || (len < 0) || (start > LLNI_field_direct(s, count)) || + (start + len > LLNI_field_direct(s, count))) { exceptions_throw_stringindexoutofboundsexception(); return; } @@ -5598,16 +3309,16 @@ void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start, TRACEJNICALLS("_Jv_JNI_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf); s = (java_lang_String *) str; - ca = s->value; + LLNI_field_get_ref(s, value, ca); - if ((start < 0) || (len < 0) || (start > s->count) || - (start + len > s->count)) { + if ((start < 0) || (len < 0) || (start > LLNI_field_direct(s, count)) || + (start + len > LLNI_field_direct(s, count))) { exceptions_throw_stringindexoutofboundsexception(); return; } for (i = 0; i < len; i++) - buf[i] = ca->data[s->offset + start + i]; + buf[i] = ca->data[LLNI_field_direct(s, offset) + start + i]; buf[i] = '\0'; } @@ -5708,11 +3419,11 @@ jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj) hashtable_global_ref_entry *gre; u4 key; /* hashkey */ u4 slot; /* slot in hashtable */ - java_objectheader *o; + java_handle_t *o; STATISTICS(jniinvokation()); - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; LOCK_MONITOR_ENTER(hashtable_global_ref->header); @@ -5779,11 +3490,11 @@ void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef) hashtable_global_ref_entry *prevgre; u4 key; /* hashkey */ u4 slot; /* slot in hashtable */ - java_objectheader *o; + java_handle_t *o; STATISTICS(jniinvokation()); - o = (java_objectheader *) globalRef; + o = (java_handle_t *) globalRef; LOCK_MONITOR_ENTER(hashtable_global_ref->header); @@ -5848,7 +3559,7 @@ void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef) jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env) { - java_objectheader *o; + java_handle_t *o; STATISTICS(jniinvokation()); @@ -5871,7 +3582,7 @@ jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env) jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity) { #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU) - java_objectheader *nbuf; + java_handle_t *nbuf; # if SIZEOF_VOID_P == 8 gnu_classpath_Pointer64 *paddress; @@ -5894,7 +3605,7 @@ jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity) /* fill gnu.classpath.Pointer{32,64} with address */ - paddress->data = (ptrint) address; + LLNI_field_set_val(paddress, data, (ptrint) address); /* create a java.nio.DirectByteBufferImpl$ReadWrite object */ @@ -5927,10 +3638,11 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf) #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU) java_nio_DirectByteBufferImpl *nbuf; # if SIZEOF_VOID_P == 8 - gnu_classpath_Pointer64 *address; + gnu_classpath_Pointer64 *paddress; # else - gnu_classpath_Pointer32 *address; + gnu_classpath_Pointer32 *paddress; # endif + void *address; STATISTICS(jniinvokation()); @@ -5940,15 +3652,20 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf) nbuf = (java_nio_DirectByteBufferImpl *) buf; # if SIZEOF_VOID_P == 8 - address = (gnu_classpath_Pointer64 *) nbuf->address; + LLNI_field_get_ref(nbuf, address, paddress); + /* this was the cast to avaoid warning: (gnu_classpath_Pointer64 *) nbuf->address; */ # else - address = (gnu_classpath_Pointer32 *) nbuf->address; + LLNI_field_get_ref(nbuf, address, paddress); + /* this was the cast to avaoid warning: (gnu_classpath_Pointer32 *) nbuf->address; */ # endif - if (address == NULL) + if (paddress == NULL) return NULL; - return (void *) address->data; + LLNI_field_get_val(paddress, data, address); + /* this was the cast to avaoid warning: (void *) paddress->data */ + + return address; #else vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration"); @@ -5969,19 +3686,22 @@ void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf) jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf) { #if defined(ENABLE_JAVASE) && defined(WITH_CLASSPATH_GNU) - java_objectheader *o; - java_nio_Buffer *nbuf; + java_handle_t *o; + java_nio_Buffer *nbuf; + jlong capacity; STATISTICS(jniinvokation()); - o = (java_objectheader *) buf; + o = (java_handle_t *) buf; if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl)) return -1; nbuf = (java_nio_Buffer *) o; - return (jlong) nbuf->cap; + LLNI_field_get_val(nbuf, cap, capacity); + + return capacity; #else vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration"); @@ -6043,7 +3763,7 @@ static s4 jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon) if (!threads_attach_current_thread(vm_aargs, false)) return JNI_ERR; - if (!jni_init_localref_table()) + if (!localref_table_init()) return JNI_ERR; } #endif diff --git a/src/native/jni.h b/src/native/jni.h index 8848d5245..e295b00f1 100644 --- a/src/native/jni.h +++ b/src/native/jni.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: jni.h 8132 2007-06-22 11:15:47Z twisti $ + $Id: jni.h 8297 2007-08-12 00:02:48Z michi $ */ @@ -52,10 +52,6 @@ #ifndef _JNI_H #define _JNI_H -/* forward typedefs ***********************************************************/ - -typedef struct localref_table localref_table; - #include "vm/types.h" @@ -99,41 +95,12 @@ extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface; extern struct JNINativeInterface_ _Jv_JNINativeInterface; -/* local reference table ******************************************************/ - -#define LOCALREFTABLE_CAPACITY 16 - -/* localref_table ************************************************************** - - ATTENTION: keep this structure a multiple of 8-bytes!!! This is - essential for the native stub on 64-bit architectures. - -*******************************************************************************/ - -struct localref_table { - s4 capacity; /* table size */ - s4 used; /* currently used references */ - s4 localframes; /* number of current frames */ - s4 PADDING; /* 8-byte padding */ - localref_table *prev; /* link to prev table (LocalFrame) */ - java_objectheader *refs[LOCALREFTABLE_CAPACITY]; /* references */ -}; - -#if defined(ENABLE_THREADS) -#define LOCALREFTABLE (THREADOBJECT->_localref_table) -#else -extern localref_table *_no_threads_localref_table; - -#define LOCALREFTABLE (_no_threads_localref_table) -#endif - - /* hashtable_global_ref_entry *************************************************/ typedef struct hashtable_global_ref_entry hashtable_global_ref_entry; struct hashtable_global_ref_entry { - java_objectheader *o; /* object pointer of global ref */ + java_object_t *o; /* object pointer of global ref */ s4 refs; /* references of the current pointer */ hashtable_global_ref_entry *hashlink; /* link for external chaining */ }; @@ -143,9 +110,8 @@ struct hashtable_global_ref_entry { /* initialize JNI subsystem */ bool jni_init(void); -bool jni_init_localref_table(void); -java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o, +java_handle_t *_Jv_jni_invokeNative(methodinfo *m, java_handle_t *o, java_objectarray *params); #endif /* _JNI_H */ diff --git a/src/native/localref.c b/src/native/localref.c new file mode 100644 index 000000000..09d89b352 --- /dev/null +++ b/src/native/localref.c @@ -0,0 +1,285 @@ +/* src/native/localref.c - Management of local reference tables + + Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, + C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, + E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, + J. Wenninger, Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + $Id$ + +*/ + + +#include "config.h" + +#include +#include + +#include "mm/memory.h" + +#include "native/localref.h" + +#include "threads/threads-common.h" + + +/* global variables ***********************************************************/ + +#if !defined(ENABLE_THREADS) +localref_table *_no_threads_localref_table; +#endif + + +/* localref_table_init ********************************************************* + + Initializes the local references table of the current thread. + +*******************************************************************************/ + +bool localref_table_init(void) +{ + localref_table *lrt; + + assert(LOCALREFTABLE == NULL); + +#if defined(ENABLE_GC_CACAO) + /* XXX this one will never get freed for the main thread; + call jni_free_localref_table() if you want to do it! */ + lrt = NEW(localref_table); +#else + lrt = GCNEW(localref_table); +#endif + + if (lrt == NULL) + return false; + + localref_table_add(lrt); + + return true; +} + +/* localref_table_add ********************************************************** + + Add a new local references table to the current thread. + +*******************************************************************************/ + +void localref_table_add(localref_table *lrt) +{ + /* initialize the local reference table */ + + lrt->capacity = LOCALREFTABLE_CAPACITY; + lrt->used = 0; + lrt->localframes = 1; + lrt->prev = LOCALREFTABLE; + + /* clear the references array (memset is faster the a for-loop) */ + + MSET(lrt->refs, 0, void*, LOCALREFTABLE_CAPACITY); + + /* add given local references table to this thread */ + + LOCALREFTABLE = lrt; +} + + +/* localref_table_remove ******************************************************* + + Remoces the local references table from the current thread. + +*******************************************************************************/ + +void localref_table_remove() +{ + localref_table *lrt; + + /* get current local reference table from thread */ + + lrt = LOCALREFTABLE; + + assert(lrt->localframes == 1); + assert(lrt->prev != NULL); + + lrt = lrt->prev; + + LOCALREFTABLE = lrt; +} + + +/* localref_frame_push ********************************************************* + + Creates a new local reference frame, in which at least a given + number of local references can be created. + +*******************************************************************************/ + +bool localref_frame_push(int32_t capacity) +{ + localref_table *lrt; + localref_table *nlrt; + int32_t additionalrefs; + + assert(capacity > 0); + + /* Allocate new local reference table on Java heap. Calculate the + additional memory we have to allocate. */ + + if (capacity > LOCALREFTABLE_CAPACITY) + additionalrefs = capacity - LOCALREFTABLE_CAPACITY; + else + additionalrefs = 0; + +#if defined(ENABLE_GC_CACAO) + nlrt = MNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P); +#else + nlrt = GCMNEW(u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P); +#endif + + if (nlrt == NULL) + return false; + + /* get current local reference table from thread */ + + lrt = LOCALREFTABLE; + + /* Set up the new local reference table and add it to the local + frames chain. */ + + nlrt->capacity = capacity; + nlrt->used = 0; + nlrt->localframes = lrt->localframes + 1; + nlrt->prev = lrt; + + /* store new local reference table in thread */ + + LOCALREFTABLE = nlrt; + + return true; +} + + +/* localref_frame_pop_all ****************************************************** + + Pops off all the local reference frames of the current table. + +*******************************************************************************/ + +void localref_frame_pop_all(void) +{ + localref_table *lrt; + localref_table *plrt; + int32_t localframes; + int32_t additionalrefs; + + /* get current local reference table from thread */ + + lrt = LOCALREFTABLE; + + localframes = lrt->localframes; + + /* Don't delete the top local frame, as this one is allocated in + the native stub on the stack and is freed automagically on + return. */ + + if (localframes == 1) + return; + + /* release all current local frames */ + + for (; localframes > 1; localframes--) { + /* get previous frame */ + + plrt = lrt->prev; + + /* clear all reference entries */ + + MSET(lrt->refs, 0, void*, lrt->capacity); + + lrt->prev = NULL; + +#if defined(ENABLE_GC_CACAO) + /* for the exact GC local reference tables are not on the heap, + so we need to free them explicitly here. */ + + if (lrt->capacity > LOCALREFTABLE_CAPACITY) + additionalrefs = lrt->capacity - LOCALREFTABLE_CAPACITY; + else + additionalrefs = 0; + + MFREE(lrt, u1, sizeof(localref_table) + additionalrefs * SIZEOF_VOID_P); +#endif + + /* set new local references table */ + + lrt = plrt; + } + + /* store new local reference table in thread */ + + LOCALREFTABLE = lrt; +} + + +/* localref_dump *************************************************************** + + Dumps all local reference tables, including all frames. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void localref_dump() +{ + localref_table *lrt; + int i; + + /* get current local reference table from thread */ + + lrt = LOCALREFTABLE; + + printf("\n--------- Local Reference Tables Dump ---------\n"); + + while (lrt != NULL) { + printf("Frame #%d, Used=%d, Capacity=%d, Addr=%p:\n", lrt->localframes, lrt->used, lrt->capacity, (void *) lrt); + + for (i = 0; i < lrt->used; i++) { + printf("\t0x%08lx ", (intptr_t) lrt->refs[i]); + } + + if (lrt->used != 0) + printf("\n"); + + lrt = lrt->prev; + } +} +#endif + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/native.c b/src/native/native.c index 813ec3e2c..579e460d8 100644 --- a/src/native/native.c +++ b/src/native/native.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: native.c 8179 2007-07-05 11:21:08Z michi $ + $Id: native.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -557,8 +557,7 @@ lt_dlhandle native_library_open(utf *filename) *******************************************************************************/ #if defined(ENABLE_LTDL) -void native_library_add(utf *filename, java_objectheader *loader, - lt_dlhandle handle) +void native_library_add(utf *filename, classloader *loader, lt_dlhandle handle) { hashtable_classloader_entry *cle; hashtable_library_loader_entry *le; @@ -646,7 +645,7 @@ void native_library_add(utf *filename, java_objectheader *loader, #if defined(ENABLE_LTDL) hashtable_library_name_entry *native_library_find(utf *filename, - java_objectheader *loader) + classloader *loader) { hashtable_classloader_entry *cle; hashtable_library_loader_entry *le; @@ -763,7 +762,7 @@ functionptr native_findfunction(utf *cname, utf *mname, utf *desc, functionptr native_resolve_function(methodinfo *m) { - java_objectheader *cl; + classloader *cl; utf *name; utf *newname; functionptr f; @@ -775,7 +774,7 @@ functionptr native_resolve_function(methodinfo *m) #endif #if defined(WITH_CLASSPATH_SUN) methodinfo *method_findNative; - java_objectheader *s; + java_handle_t *s; #endif cl = m->class->classloader; @@ -905,10 +904,10 @@ functionptr native_resolve_function(methodinfo *m) *******************************************************************************/ -java_objectheader *native_new_and_init(classinfo *c) +java_handle_t *native_new_and_init(classinfo *c) { - methodinfo *m; - java_objectheader *o; + methodinfo *m; + java_handle_t *o; if (c == NULL) vm_abort("native_new_and_init: c == NULL"); @@ -938,10 +937,10 @@ java_objectheader *native_new_and_init(classinfo *c) } -java_objectheader *native_new_and_init_string(classinfo *c, java_objectheader *s) +java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s) { - methodinfo *m; - java_objectheader *o; + methodinfo *m; + java_handle_t *o; if (c == NULL) vm_abort("native_new_and_init_string: c == NULL"); diff --git a/src/native/native.h b/src/native/native.h index b88668af0..f468d8fff 100644 --- a/src/native/native.h +++ b/src/native/native.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: native.h 8179 2007-07-05 11:21:08Z michi $ + $Id: native.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -133,20 +133,19 @@ functionptr native_findfunction(utf *cname, utf *mname, utf *desc, # if defined(ENABLE_LTDL) lt_dlhandle native_library_open(utf *filename); -void native_library_add(utf *filename, java_objectheader *loader, +void native_library_add(utf *filename, classloader *loader, lt_dlhandle handle); hashtable_library_name_entry *native_library_find(utf *filename, - java_objectheader *loader); + classloader *loader); # endif functionptr native_resolve_function(methodinfo *m); #endif /* defined(WITH_STATIC_CLASSPATH) */ -java_objectheader *native_new_and_init(classinfo *c); +java_handle_t *native_new_and_init(classinfo *c); -java_objectheader *native_new_and_init_string(classinfo *c, - java_objectheader *s); +java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s); #endif /* _NATIVE_H */ diff --git a/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c index c9e82a7b7..3db610c64 100644 --- a/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c +++ b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c @@ -85,7 +85,7 @@ JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jcla /* check for error and throw one in case */ if (result == 0) { - name = javastring_toutf((java_objectheader *) libName, false); + name = javastring_toutf((java_handle_t *) libName, false); exceptions_throw_unsatisfiedlinkerror(name); } } diff --git a/src/native/vm/cldc1.1/java_lang_Class.c b/src/native/vm/cldc1.1/java_lang_Class.c index dd4ff460c..1a6a39af2 100644 --- a/src/native/vm/cldc1.1/java_lang_Class.c +++ b/src/native/vm/cldc1.1/java_lang_Class.c @@ -87,8 +87,8 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Class_forName(JNIEnv *env, jcl */ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, java_lang_Class* this) { - classinfo *c; - java_objectheader *o; + classinfo *c; + java_handle_t *o; c = (classinfo *) this; diff --git a/src/native/vm/cldc1.1/java_lang_Object.c b/src/native/vm/cldc1.1/java_lang_Object.c index b6eb7513e..dc0c6c553 100644 --- a/src/native/vm/cldc1.1/java_lang_Object.c +++ b/src/native/vm/cldc1.1/java_lang_Object.c @@ -78,10 +78,10 @@ void _Jv_java_lang_Object_init(void) */ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj) { - java_objectheader *o; - classinfo *c; + java_handle_t *o; + classinfo *c; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; if (o == NULL) return NULL; diff --git a/src/native/vm/cldc1.1/java_lang_String.c b/src/native/vm/cldc1.1/java_lang_String.c index ad60b48bd..7d2dc5353 100644 --- a/src/native/vm/cldc1.1/java_lang_String.c +++ b/src/native/vm/cldc1.1/java_lang_String.c @@ -246,7 +246,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_String_equals(JNIEnv *env, java_lang_String* */ JNIEXPORT java_lang_String* JNICALL Java_java_lang_String_intern(JNIEnv *env, java_lang_String *this) { - java_objectheader *o; + java_handle_t *o; if (this == NULL) return NULL; diff --git a/src/native/vm/cldc1.1/java_lang_System.c b/src/native/vm/cldc1.1/java_lang_System.c index 3547a504b..25097feec 100644 --- a/src/native/vm/cldc1.1/java_lang_System.c +++ b/src/native/vm/cldc1.1/java_lang_System.c @@ -92,12 +92,12 @@ JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz JNIEXPORT java_lang_String* JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, java_lang_String *s) { - java_objectheader *so; - char* key; - char* value; - java_objectheader *result; + java_handle_t *so; + char* key; + char* value; + java_handle_t *result; - so = (java_objectheader *) s; + so = (java_handle_t *) s; /* build an ASCII string out of the java/lang/String passed */ diff --git a/src/native/vm/cldc1.1/java_lang_Throwable.c b/src/native/vm/cldc1.1/java_lang_Throwable.c index 68f86c537..e13bdef6d 100644 --- a/src/native/vm/cldc1.1/java_lang_Throwable.c +++ b/src/native/vm/cldc1.1/java_lang_Throwable.c @@ -74,9 +74,9 @@ void _Jv_java_lang_Throwable_init(void) */ JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, java_lang_Throwable *this) { - java_objectheader *o; + java_handle_t *o; - o = (java_objectheader *) this; + o = (java_handle_t *) this; exceptions_print_exception(o); stacktrace_print_trace(o); diff --git a/src/native/vm/gnu/Makefile.am b/src/native/vm/gnu/Makefile.am index d7ea29e40..915bc2c82 100644 --- a/src/native/vm/gnu/Makefile.am +++ b/src/native/vm/gnu/Makefile.am @@ -26,7 +26,7 @@ ## ## Authors: Christian Thalinger ## -## $Id: Makefile.am 8123 2007-06-20 23:50:55Z michi $ +## $Id: Makefile.am 8249 2007-07-31 12:59:03Z panzi $ ## Process this file with automake to produce Makefile.in @@ -42,6 +42,11 @@ lib_LTLIBRARIES = \ libjdwp.la endif +if ENABLE_ANNOTATIONS +SUN_REFLECT_SOURCES = \ + sun_reflect_ConstantPool.c +endif + libnativevmcore_la_SOURCES = \ gnu_classpath_VMStackWalker.c \ gnu_classpath_VMSystemProperties.c \ @@ -63,7 +68,8 @@ libnativevmcore_la_SOURCES = \ java_lang_reflect_Method.c \ java_lang_reflect_VMProxy.c \ java_security_VMAccessController.c \ - java_util_concurrent_atomic_AtomicLong.c + java_util_concurrent_atomic_AtomicLong.c \ + $(SUN_REFLECT_SOURCES) if ENABLE_JVMTI libjdwp_la_SOURCES = \ diff --git a/src/native/vm/gnu/gnu_classpath_VMStackWalker.c b/src/native/vm/gnu/gnu_classpath_VMStackWalker.c index 8104fbee8..716bd47d2 100644 --- a/src/native/vm/gnu/gnu_classpath_VMStackWalker.c +++ b/src/native/vm/gnu/gnu_classpath_VMStackWalker.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: gnu_classpath_VMStackWalker.c 7918 2007-05-20 20:42:18Z michi $ + $Id: gnu_classpath_VMStackWalker.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -114,9 +114,9 @@ JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingCl */ JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz) { - java_objectarray *oa; - classinfo *c; - classloader *cl; + java_objectarray *oa; + classinfo *c; + classloader *cl; oa = stacktrace_getClassContext(); @@ -143,10 +143,10 @@ JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCal */ JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz) { - java_objectarray *oa; - classinfo *c; - classloader *cl; - s4 i; + java_objectarray *oa; + classinfo *c; + classloader *cl; + s4 i; oa = stacktrace_getClassContext(); diff --git a/src/native/vm/gnu/gnu_classpath_VMSystemProperties.c b/src/native/vm/gnu/gnu_classpath_VMSystemProperties.c index f4ad3f8b0..d1b1abc25 100644 --- a/src/native/vm/gnu/gnu_classpath_VMSystemProperties.c +++ b/src/native/vm/gnu/gnu_classpath_VMSystemProperties.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: gnu_classpath_VMSystemProperties.c 7910 2007-05-16 08:02:52Z twisti $ + $Id: gnu_classpath_VMSystemProperties.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -79,9 +79,9 @@ void _Jv_gnu_classpath_VMSystemProperties_init(void) */ JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *properties) { - java_objectheader *p; + java_handle_t *p; - p = (java_objectheader *) properties; + p = (java_handle_t *) properties; if (p == NULL) { exceptions_throw_nullpointerexception(); @@ -101,13 +101,13 @@ JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env */ JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties) { - java_objectheader *p; + java_handle_t *p; #if defined(WITH_JRE_LAYOUT) char *path; s4 len; #endif - p = (java_objectheader *) properties; + p = (java_handle_t *) properties; if (p == NULL) { exceptions_throw_nullpointerexception(); diff --git a/src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c b/src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c index 780a6e8f1..8c0a5514a 100644 --- a/src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c +++ b/src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c @@ -83,7 +83,7 @@ void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void) JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz) { classinfo *class_java_lang_management_MemoryUsage; - java_objectheader *o; + java_handle_t *o; java_lang_management_MemoryUsage *mu; methodinfo *m; s8 init; diff --git a/src/native/vm/gnu/java_lang_VMClass.c b/src/native/vm/gnu/java_lang_VMClass.c index ced8cc112..60f893237 100644 --- a/src/native/vm/gnu/java_lang_VMClass.c +++ b/src/native/vm/gnu/java_lang_VMClass.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_VMClass.c 8169 2007-06-30 12:33:50Z twisti $ + $Id: java_lang_VMClass.c 8249 2007-07-31 12:59:03Z panzi $ */ @@ -66,7 +66,7 @@ static JNINativeMethod methods[] = { { "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_VMClass_forName }, { "isArray", "(Ljava/lang/Class;)Z", (void *) (ptrint) &Java_java_lang_VMClass_isArray }, { "throwException", "(Ljava/lang/Throwable;)V", (void *) (ptrint) &Java_java_lang_VMClass_throwException }, -#if 0 +#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS) { "getDeclaredAnnotations", "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;", (void *) (ptrint) &Java_java_lang_VMClass_getDeclaredAnnotations }, #endif { "getEnclosingClass", "(Ljava/lang/Class;)Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_VMClass_getEnclosingClass }, @@ -295,7 +295,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass } -#if 0 +#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS) /* * Class: java/lang/VMClass * Method: getDeclaredAnnotations @@ -303,6 +303,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass */ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass) { + return _Jv_java_lang_Class_getDeclaredAnnotations(klass); } #endif diff --git a/src/native/vm/gnu/java_lang_VMClassLoader.c b/src/native/vm/gnu/java_lang_VMClassLoader.c index 23082c5c2..845816915 100644 --- a/src/native/vm/gnu/java_lang_VMClassLoader.c +++ b/src/native/vm/gnu/java_lang_VMClassLoader.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_VMClassLoader.c 8141 2007-06-25 13:35:26Z michi $ + $Id: java_lang_VMClassLoader.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -53,6 +53,7 @@ #include "vm/builtin.h" #include "vm/exceptions.h" #include "vm/initialize.h" +#include "vm/primitive.h" #include "vm/stringlocal.h" #include "vm/vm.h" @@ -63,7 +64,6 @@ #include "vmcore/linker.h" #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/statistics.h" #include "vmcore/suck.h" #include "vmcore/zip.h" @@ -175,7 +175,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv /* create utf string in which '.' is replaced by '/' */ - u = javastring_toutf((java_objectheader *) name, true); + u = javastring_toutf((java_handle_t *) name, true); /* load class */ @@ -201,9 +201,9 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv */ JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name) { - java_objectheader *o; /* vector being created */ + java_handle_t *o; /* vector being created */ methodinfo *m; /* "add" method of vector */ - java_objectheader *path; /* path to be added */ + java_handle_t *path; /* path to be added */ list_classpath_entry *lce; /* classpath entry */ utf *utfname; /* utf to look for */ char *buffer; /* char buffer */ @@ -218,7 +218,7 @@ JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResour /* get the resource name as utf string */ - utfname = javastring_toutf((java_objectheader *) name, false); + utfname = javastring_toutf((java_handle_t *) name, false); if (utfname == NULL) return NULL; @@ -364,7 +364,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass( /* replace `.' by `/', this is required by the classcache */ - u = javastring_toutf((java_objectheader *) name, true); + u = javastring_toutf((java_handle_t *) name, true); /* lookup for defining classloader */ diff --git a/src/native/vm/gnu/java_lang_VMRuntime.c b/src/native/vm/gnu/java_lang_VMRuntime.c index 202ada6f4..6eeb01bb9 100644 --- a/src/native/vm/gnu/java_lang_VMRuntime.c +++ b/src/native/vm/gnu/java_lang_VMRuntime.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_VMRuntime.c 8147 2007-06-27 09:23:24Z twisti $ + $Id: java_lang_VMRuntime.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -277,9 +277,9 @@ JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *e */ JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *libname, java_lang_ClassLoader *loader) { - java_objectheader *cl; + classloader *cl; - cl = (java_objectheader *) loader; + cl = (classloader *) loader; #if defined(ENABLE_JNI) return _Jv_java_lang_Runtime_loadLibrary(env, libname, cl); @@ -296,18 +296,18 @@ JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclas */ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, java_lang_String *libname) { - utf *u; - char *buffer; - int32_t buffer_len; - int32_t dumpsize; - java_objectheader *o; + utf *u; + char *buffer; + int32_t buffer_len; + int32_t dumpsize; + java_handle_t *o; if (libname == NULL) { exceptions_throw_nullpointerexception(); return NULL; } - u = javastring_toutf((java_objectheader *) libname, false); + u = javastring_toutf((java_handle_t *) libname, false); /* calculate length of library name */ diff --git a/src/native/vm/gnu/java_lang_VMThread.c b/src/native/vm/gnu/java_lang_VMThread.c index 124c41f0e..4ce14308d 100644 --- a/src/native/vm/gnu/java_lang_VMThread.c +++ b/src/native/vm/gnu/java_lang_VMThread.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_VMThread.c 8123 2007-06-20 23:50:55Z michi $ + $Id: java_lang_VMThread.c 8284 2007-08-10 08:58:39Z michi $ */ @@ -32,6 +32,7 @@ #include #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_ThreadGroup.h" @@ -91,7 +92,11 @@ void _Jv_java_lang_VMThread_init(void) */ JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this) { - return _Jv_java_lang_Thread_countStackFrames(this->thread); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + return _Jv_java_lang_Thread_countStackFrames(thread); } @@ -102,7 +107,11 @@ JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, */ JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, int64_t stacksize) { - _Jv_java_lang_Thread_start(this->thread, stacksize); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + _Jv_java_lang_Thread_start(thread, stacksize); } @@ -113,7 +122,11 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMTh */ JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this) { - _Jv_java_lang_Thread_interrupt(this->thread); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + _Jv_java_lang_Thread_interrupt(thread); } @@ -124,7 +137,11 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_ */ JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this) { - return _Jv_java_lang_Thread_isInterrupted(this->thread); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + return _Jv_java_lang_Thread_isInterrupted(thread); } @@ -135,7 +152,11 @@ JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, jav */ JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this) { - _Jv_java_lang_Thread_suspend(this->thread); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + _Jv_java_lang_Thread_suspend(thread); } @@ -146,7 +167,11 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VM */ JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this) { - _Jv_java_lang_Thread_resume(this->thread); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + _Jv_java_lang_Thread_resume(thread); } @@ -157,7 +182,11 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMT */ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority) { - _Jv_java_lang_Thread_setPriority(this->thread, priority); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + _Jv_java_lang_Thread_setPriority(thread, priority); } @@ -168,7 +197,11 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, ja */ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t) { - _Jv_java_lang_Thread_stop(this->thread, t); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + _Jv_java_lang_Thread_stop(thread, t); } @@ -223,7 +256,11 @@ JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass */ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this) { - return _Jv_java_lang_Thread_getState(this->thread); + java_lang_Thread *thread; + + LLNI_field_get_ref(this, thread, thread); + + return _Jv_java_lang_Thread_getState(thread); } diff --git a/src/native/vm/gnu/java_lang_VMThrowable.c b/src/native/vm/gnu/java_lang_VMThrowable.c index feb5fa25a..e7a2427eb 100644 --- a/src/native/vm/gnu/java_lang_VMThrowable.c +++ b/src/native/vm/gnu/java_lang_VMThrowable.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_VMThrowable.c 7910 2007-05-16 08:02:52Z twisti $ + $Id: java_lang_VMThrowable.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -34,6 +34,7 @@ #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/gnu_classpath_Pointer.h" @@ -100,7 +101,7 @@ JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackT if (stc == NULL) return NULL; - o->vmData = (gnu_classpath_Pointer *) stc; + LLNI_field_set_ref(o, vmData, (gnu_classpath_Pointer *) stc); return o; } @@ -133,12 +134,13 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNI /* get the stacktrace buffer from the VMThrowable object */ - stc = (stacktracecontainer *) this->vmData; + /*XXX stc = (stacktracecontainer *) this->vmData;*/ + LLNI_field_get_ref(this, vmData, stc); stb = &(stc->stb); /* get the class of the Throwable object */ - c = t->header.vftbl->class; + LLNI_class_get(t, c); assert(stb != NULL); @@ -255,13 +257,13 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNI /* fill the java.lang.StackTraceElement element */ - o->fileName = filename; - o->lineNumber = linenumber; - o->declaringClass = declaringclass; - o->methodName = (java_lang_String *) javastring_new(ste->method->name); - o->isNative = (ste->method->flags & ACC_NATIVE) ? 1 : 0; + LLNI_field_set_ref(o, fileName , filename); + LLNI_field_set_val(o, lineNumber , linenumber); + LLNI_field_set_ref(o, declaringClass, declaringclass); + LLNI_field_set_ref(o, methodName , (java_lang_String *) javastring_new(ste->method->name)); + LLNI_field_set_val(o, isNative , (ste->method->flags & ACC_NATIVE) ? 1 : 0); - oa->data[i] = (java_objectheader *) o; + oa->data[i] = o; } return oa; diff --git a/src/native/vm/gnu/java_lang_reflect_Constructor.c b/src/native/vm/gnu/java_lang_reflect_Constructor.c index b4a353122..3a82a63aa 100644 --- a/src/native/vm/gnu/java_lang_reflect_Constructor.c +++ b/src/native/vm/gnu/java_lang_reflect_Constructor.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_reflect_Constructor.c 8123 2007-06-20 23:50:55Z michi $ + $Id: java_lang_reflect_Constructor.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -32,9 +32,14 @@ #include #include +#if defined(ENABLE_ANNOTATIONS) +#include "vm/vm.h" +#endif + #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Class.h" @@ -42,6 +47,11 @@ #include "native/include/java_lang_String.h" #include "native/include/java_lang_reflect_Constructor.h" +#if defined(ENABLE_ANNOTATIONS) +#include "native/include/sun_reflect_ConstantPool.h" +#include "native/vm/reflect.h" +#endif + #include "native/vm/java_lang_reflect_Constructor.h" #include "vmcore/utf8.h" @@ -50,11 +60,15 @@ /* native methods implemented by this file ************************************/ static JNINativeMethod methods[] = { - { "getModifiersInternal", "()I", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getModifiers }, - { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getParameterTypes }, - { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getExceptionTypes }, - { "constructNative", "([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_constructNative }, - { "getSignature", "()Ljava/lang/String;", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getSignature }, + { "getModifiersInternal", "()I", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getModifiers }, + { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getParameterTypes }, + { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getExceptionTypes }, + { "constructNative", "([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_constructNative }, + { "getSignature", "()Ljava/lang/String;", (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getSignature }, +#if defined(ENABLE_ANNOTATIONS) + { "declaredAnnotations", "()Ljava/util/Map;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_declaredAnnotations }, + { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_getParameterAnnotations }, +#endif }; @@ -83,13 +97,50 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_construct { /* just to be sure */ - assert(this->clazz == declaringClass); - assert(this->slot == slot); + assert(LLNI_field_direct(this, clazz) == declaringClass); + assert(LLNI_field_direct(this, slot) == slot); return _Jv_java_lang_reflect_Constructor_newInstance(env, this, args); } +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/reflect/Constructor + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; + */ +JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this) +{ + java_handle_t *o = (java_handle_t*)this; + + if (this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return reflect_get_declaredannotatios(&(this->declaredAnnotations), this->annotations, this->clazz, o->vftbl->class); +} + + +/* + * Class: java/lang/reflect/Constructor + * Method: getParameterAnnotations + * Signature: ()[[Ljava/lang/annotation/Annotation; + */ +JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this) +{ + java_handle_t *o = (java_handle_t*)this; + + if (this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return reflect_get_parameterannotations((java_handle_t*)this->parameterAnnotations, this->slot, this->clazz, o->vftbl->class); +} +#endif + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/native/vm/gnu/java_lang_reflect_Field.c b/src/native/vm/gnu/java_lang_reflect_Field.c index af9fb08d8..b35f70a14 100644 --- a/src/native/vm/gnu/java_lang_reflect_Field.c +++ b/src/native/vm/gnu/java_lang_reflect_Field.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_reflect_Field.c 8132 2007-06-22 11:15:47Z twisti $ + $Id: java_lang_reflect_Field.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -33,6 +33,7 @@ #include #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Boolean.h" @@ -49,18 +50,23 @@ #include "native/include/java_lang_reflect_Field.h" +#if defined(ENABLE_ANNOTATIONS) +#include "native/include/sun_reflect_ConstantPool.h" +#include "native/vm/reflect.h" +#endif + #include "vm/access.h" #include "vm/builtin.h" #include "vm/exceptions.h" #include "vm/global.h" #include "vm/initialize.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/stringlocal.h" #include "vm/jit/stacktrace.h" #include "vmcore/loader.h" -#include "vmcore/primitive.h" #include "vmcore/utf8.h" @@ -88,6 +94,9 @@ static JNINativeMethod methods[] = { { "setFloat", "(Ljava/lang/Object;F)V", (void *) (intptr_t) &Java_java_lang_reflect_Field_setFloat }, { "setDouble", "(Ljava/lang/Object;D)V", (void *) (intptr_t) &Java_java_lang_reflect_Field_setDouble }, { "getSignature", "()Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_reflect_Field_getSignature }, +#if defined(ENABLE_ANNOTATIONS) + { "declaredAnnotations", "()Ljava/util/Map;", (void *) (intptr_t) &Java_java_lang_reflect_Field_declaredAnnotations }, +#endif }; @@ -126,14 +135,18 @@ static void *cacao_get_field_address(java_lang_reflect_Field *this, { classinfo *c; fieldinfo *f; + int32_t slot; + int32_t flag; - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* check field access */ /* check if we should bypass security checks (AccessibleObject) */ - if (this->flag == false) { + LLNI_field_get_val(this, flag, flag); + if (flag == false) { /* this function is always called like this: java.lang.reflect.Field.xxx (Native Method) @@ -152,9 +165,9 @@ static void *cacao_get_field_address(java_lang_reflect_Field *this, if (!initialize_class(c)) return NULL; - /* return value address */ + /* return value pointer */ - return &(f->value); + return f->value; } else { /* obj is required for not-static fields */ @@ -164,8 +177,8 @@ static void *cacao_get_field_address(java_lang_reflect_Field *this, return NULL; } - if (builtin_instanceof((java_objectheader *) o, c)) - return (void *) ((intptr_t) o + f->offset); + if (builtin_instanceof((java_handle_t *) o, c)) + return (void *) (((intptr_t) o) + f->offset); } /* exception path */ @@ -185,9 +198,11 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getModifiersInternal(JNIE { classinfo *c; fieldinfo *f; + int32_t slot; - c = (classinfo *) this->clazz; - f = &(c->fields[this->slot]); + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &(c->fields[slot]); return f->flags; } @@ -203,9 +218,11 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv * classinfo *c; typedesc *desc; classinfo *ret; + int32_t slot; - c = (classinfo *) this->clazz; - desc = c->fields[this->slot].parseddesc; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + desc = c->fields[slot].parseddesc; if (desc == NULL) return NULL; @@ -222,126 +239,55 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv * * Method: get * Signature: (Ljava/lang/Object;)Ljava/lang/Object; */ -JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Field_get(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *o) +JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Field_get(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *object) { classinfo *c; fieldinfo *f; void *addr; + int32_t slot; + imm_union value; + java_handle_t *o; - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get address of the source field value */ - if ((addr = cacao_get_field_address(this, o)) == NULL) + if ((addr = cacao_get_field_address(this, object)) == NULL) return NULL; switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BOOLEAN: { - java_lang_Boolean *bo; - - /* create wrapping class */ - - if (!(bo = (java_lang_Boolean *) builtin_new(class_java_lang_Boolean))) - return NULL; - - /* set the object value */ - - bo->value = *((int32_t *) addr); - - /* return the wrapped object */ - - return (java_lang_Object *) bo; - } - - case PRIMITIVETYPE_BYTE: { - java_lang_Byte *bo; - - if (!(bo = (java_lang_Byte *) builtin_new(class_java_lang_Byte))) - return NULL; - - bo->value = *((int32_t *) addr); - - return (java_lang_Object *) bo; - } - - case PRIMITIVETYPE_CHAR: { - java_lang_Character *co; - - if (!(co = (java_lang_Character *) builtin_new(class_java_lang_Character))) - return NULL; - - co->value = *((int32_t *) addr); - - return (java_lang_Object *) co; - } - - case PRIMITIVETYPE_SHORT: { - java_lang_Short *so; - - if (!(so = (java_lang_Short *) builtin_new(class_java_lang_Short))) - return NULL; - - so->value = (int32_t) *((int32_t *) addr); - - return (java_lang_Object *) so; - } - - case PRIMITIVETYPE_INT: { - java_lang_Integer *io; - - if (!(io = (java_lang_Integer *) builtin_new(class_java_lang_Integer))) - return NULL; - - io->value = *((int32_t *) addr); - - return (java_lang_Object *) io; - } - - case PRIMITIVETYPE_LONG: { - java_lang_Long *lo; - - if (!(lo = (java_lang_Long *) builtin_new(class_java_lang_Long))) - return NULL; - - lo->value = *((int64_t *) addr); - - return (java_lang_Object *) lo; - } - - case PRIMITIVETYPE_FLOAT: { - java_lang_Float *fo; - - if (!(fo = (java_lang_Float *) builtin_new(class_java_lang_Float))) - return NULL; - - fo->value = *((float *) addr); - - return (java_lang_Object *) fo; - } - - case PRIMITIVETYPE_DOUBLE: { - java_lang_Double *_do; + case PRIMITIVETYPE_BOOLEAN: + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + value.i = *((int32_t *) addr); + break; - if (!(_do = (java_lang_Double *) builtin_new(class_java_lang_Double))) - return NULL; + case PRIMITIVETYPE_LONG: + value.l = *((int64_t *) addr); + break; - _do->value = *((double *) addr); + case PRIMITIVETYPE_FLOAT: + value.f = *((float *) addr); + break; - return (java_lang_Object *) _do; - } + case PRIMITIVETYPE_DOUBLE: + value.d = *((double *) addr); + break; case TYPE_ADR: - return (java_lang_Object *) *((java_objectheader **) addr); +#warning this whole thing needs to be inside a critical section! + return (java_lang_Object *) *((java_handle_t **) addr); } - /* this must not happen */ - - assert(0); + /* Now box the primitive types. */ - /* keep compiler happy */ + o = primitive_box(f->parseddesc->decltype, value); - return NULL; + return (java_lang_Object *) o; } @@ -355,11 +301,13 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getBoolean(JNIEnv *env, j classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -388,11 +336,13 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getByte(JNIEnv *env, java classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -421,11 +371,13 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getChar(JNIEnv *env, java classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -454,11 +406,13 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getShort(JNIEnv *env, jav classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -488,11 +442,13 @@ JNIEXPORT int32_t JNICALL Java_java_lang_reflect_Field_getInt(JNIEnv *env , java classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -524,11 +480,13 @@ JNIEXPORT int64_t JNICALL Java_java_lang_reflect_Field_getLong(JNIEnv *env, java classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -562,11 +520,13 @@ JNIEXPORT float JNICALL Java_java_lang_reflect_Field_getFloat(JNIEnv *env, java_ classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -602,11 +562,13 @@ JNIEXPORT double JNICALL Java_java_lang_reflect_Field_getDouble(JNIEnv *env , ja classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -646,11 +608,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r fieldinfo *sf; fieldinfo *df; void *faddr; + int32_t slot; /* get the class and the field */ - dc = (classinfo *) this->clazz; - df = &dc->fields[this->slot]; + LLNI_field_get_cls(this, clazz, dc); + LLNI_field_get_val(this, slot , slot); + df = &dc->fields[slot]; /* get the address of the destination field */ @@ -662,7 +626,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r if (value == NULL) sc = NULL; else - sc = value->header.vftbl->class; + LLNI_class_get(value, sc); /* The fieldid is used to set the new value, for primitive types the value has to be retrieved from the wrapping @@ -679,7 +643,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BOOLEAN: - val = ((java_lang_Boolean *) value)->value; + LLNI_field_get_val((java_lang_Boolean *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -698,7 +662,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BYTE: - val = ((java_lang_Byte *) value)->value; + LLNI_field_get_val((java_lang_Byte *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -717,7 +681,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_CHAR: - val = ((java_lang_Character *) value)->value; + LLNI_field_get_val((java_lang_Character *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -738,10 +702,10 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BYTE: - val = ((java_lang_Byte *) value)->value; + LLNI_field_get_val((java_lang_Byte *) value, value, val); break; case PRIMITIVETYPE_SHORT: - val = ((java_lang_Short *) value)->value; + LLNI_field_get_val((java_lang_Short *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -762,16 +726,16 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BYTE: - val = ((java_lang_Byte *) value)->value; + LLNI_field_get_val((java_lang_Byte *) value, value, val); break; case PRIMITIVETYPE_CHAR: - val = ((java_lang_Character *) value)->value; + LLNI_field_get_val((java_lang_Character *) value, value, val); break; case PRIMITIVETYPE_SHORT: - val = ((java_lang_Short *) value)->value; + LLNI_field_get_val((java_lang_Short *) value, value, val); break; case PRIMITIVETYPE_INT: - val = ((java_lang_Integer *) value)->value; + LLNI_field_get_val((java_lang_Integer *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -792,19 +756,19 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BYTE: - val = ((java_lang_Byte *) value)->value; + LLNI_field_get_val((java_lang_Byte *) value, value, val); break; case PRIMITIVETYPE_CHAR: - val = ((java_lang_Character *) value)->value; + LLNI_field_get_val((java_lang_Character *) value, value, val); break; case PRIMITIVETYPE_SHORT: - val = ((java_lang_Short *) value)->value; + LLNI_field_get_val((java_lang_Short *) value, value, val); break; case PRIMITIVETYPE_INT: - val = ((java_lang_Integer *) value)->value; + LLNI_field_get_val((java_lang_Integer *) value, value, val); break; case PRIMITIVETYPE_LONG: - val = ((java_lang_Long *) value)->value; + LLNI_field_get_val((java_lang_Long *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -825,22 +789,22 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BYTE: - val = ((java_lang_Byte *) value)->value; + LLNI_field_get_val((java_lang_Byte *) value, value, val); break; case PRIMITIVETYPE_CHAR: - val = ((java_lang_Character *) value)->value; + LLNI_field_get_val((java_lang_Character *) value, value, val); break; case PRIMITIVETYPE_SHORT: - val = ((java_lang_Short *) value)->value; + LLNI_field_get_val((java_lang_Short *) value, value, val); break; case PRIMITIVETYPE_INT: - val = ((java_lang_Integer *) value)->value; + LLNI_field_get_val((java_lang_Integer *) value, value, val); break; case PRIMITIVETYPE_LONG: - val = ((java_lang_Long *) value)->value; + LLNI_field_get_val((java_lang_Long *) value, value, val); break; case PRIMITIVETYPE_FLOAT: - val = ((java_lang_Float *) value)->value; + LLNI_field_get_val((java_lang_Float *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -861,25 +825,25 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r switch (sf->parseddesc->decltype) { case PRIMITIVETYPE_BYTE: - val = ((java_lang_Byte *) value)->value; + LLNI_field_get_val((java_lang_Byte *) value, value, val); break; case PRIMITIVETYPE_CHAR: - val = ((java_lang_Character *) value)->value; + LLNI_field_get_val((java_lang_Character *) value, value, val); break; case PRIMITIVETYPE_SHORT: - val = ((java_lang_Short *) value)->value; + LLNI_field_get_val((java_lang_Short *) value, value, val); break; case PRIMITIVETYPE_INT: - val = ((java_lang_Integer *) value)->value; + LLNI_field_get_val((java_lang_Integer *) value, value, val); break; case PRIMITIVETYPE_LONG: - val = ((java_lang_Long *) value)->value; + LLNI_field_get_val((java_lang_Long *) value, value, val); break; case PRIMITIVETYPE_FLOAT: - val = ((java_lang_Float *) value)->value; + LLNI_field_get_val((java_lang_Float *) value, value, val); break; case PRIMITIVETYPE_DOUBLE: - val = ((java_lang_Double *) value)->value; + LLNI_field_get_val((java_lang_Double *) value, value, val); break; default: exceptions_throw_illegalargumentexception(); @@ -894,7 +858,7 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_set(JNIEnv *env, java_lang_r /* check if value is an instance of the destination class */ /* XXX TODO */ - /* if (!builtin_instanceof((java_objectheader *) value, df->class)) */ + /* if (!builtin_instanceof((java_handle_t *) value, df->class)) */ /* break; */ *((java_lang_Object **) faddr) = value; @@ -917,11 +881,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setBoolean(JNIEnv *env, java classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -952,11 +918,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setByte(JNIEnv *env, java_la classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -998,11 +966,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar(JNIEnv *env, java_la classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -1043,11 +1013,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort(JNIEnv *env, java_l classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -1088,11 +1060,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt(JNIEnv *env, java_lan classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -1132,11 +1106,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong(JNIEnv *env, java_la classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -1173,11 +1149,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat(JNIEnv *env, java_l classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -1211,11 +1189,13 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble(JNIEnv *env, java_ classinfo *c; fieldinfo *f; void *addr; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; /* get the address of the field with an internal helper */ @@ -1243,14 +1223,16 @@ JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble(JNIEnv *env, java_ */ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JNIEnv *env, java_lang_reflect_Field* this) { - classinfo *c; - fieldinfo *f; - java_objectheader *o; + classinfo *c; + fieldinfo *f; + java_handle_t *o; + int32_t slot; /* get the class and the field */ - c = (classinfo *) this->clazz; - f = &c->fields[this->slot]; + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + f = &c->fields[slot]; if (f->signature == NULL) return NULL; @@ -1263,6 +1245,26 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JN } +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/reflect/Field + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; + */ +JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Field_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Field* this) +{ + java_handle_t *o = (java_handle_t*)this; + + if (this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return reflect_get_declaredannotatios(&(this->declaredAnnotations), this->annotations, this->clazz, o->vftbl->class); +} +#endif + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/native/vm/gnu/java_lang_reflect_Method.c b/src/native/vm/gnu/java_lang_reflect_Method.c index 96888b080..826fbdc19 100644 --- a/src/native/vm/gnu/java_lang_reflect_Method.c +++ b/src/native/vm/gnu/java_lang_reflect_Method.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_reflect_Method.c 8132 2007-06-22 11:15:47Z twisti $ + $Id: java_lang_reflect_Method.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -31,15 +31,25 @@ #include +#if defined(ENABLE_ANNOTATIONS) +#include "vm/vm.h" +#endif + #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Object.h" #include "native/include/java_lang_Class.h" #include "native/include/java_lang_String.h" +#if defined(ENABLE_ANNOTATIONS) +#include "native/include/sun_reflect_ConstantPool.h" +#include "native/vm/reflect.h" +#endif + #include "native/include/java_lang_reflect_Method.h" #include "native/vm/java_lang_reflect_Method.h" @@ -58,12 +68,17 @@ /* native methods implemented by this file ************************************/ static JNINativeMethod methods[] = { - { "getModifiersInternal", "()I", (void *) (ptrint) &Java_java_lang_reflect_Method_getModifiersInternal }, - { "getReturnType", "()Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getReturnType }, - { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterTypes }, - { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getExceptionTypes }, - { "invokeNative", "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_invokeNative }, - { "getSignature", "()Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_reflect_Method_getSignature }, + { "getModifiersInternal", "()I", (void *) (ptrint) &Java_java_lang_reflect_Method_getModifiersInternal }, + { "getReturnType", "()Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getReturnType }, + { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterTypes }, + { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getExceptionTypes }, + { "invokeNative", "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_invokeNative }, + { "getSignature", "()Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_reflect_Method_getSignature }, +#if defined(ENABLE_ANNOTATIONS) + { "getDefaultValue", "()Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_getDefaultValue }, + { "declaredAnnotations", "()Ljava/util/Map;", (void *) (ptrint) &Java_java_lang_reflect_Method_declaredAnnotations }, + { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;", (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterAnnotations }, +#endif }; @@ -92,9 +107,11 @@ JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv * { classinfo *c; methodinfo *m; + int32_t slot; - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + m = &(c->methods[slot]); return m->flags; } @@ -110,9 +127,11 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(J classinfo *c; methodinfo *m; classinfo *result; + int32_t slot; - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + m = &(c->methods[slot]); result = method_returntype_get(m); @@ -129,9 +148,11 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTy { classinfo *c; methodinfo *m; + int32_t slot; - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + m = &(c->methods[slot]); return method_get_parametertypearray(m); } @@ -146,9 +167,11 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTy { classinfo *c; methodinfo *m; + int32_t slot; - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + m = &(c->methods[slot]); return method_get_exceptionarray(m); } @@ -163,8 +186,8 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(J { /* just to be sure */ - assert(this->clazz == clazz); - assert(this->slot == slot); + assert(LLNI_field_direct(this, clazz) == clazz); + assert(LLNI_field_direct(this, slot) == slot); return _Jv_java_lang_reflect_Method_invoke(this, o, args); } @@ -177,12 +200,14 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(J */ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this) { - classinfo *c; - methodinfo *m; - java_objectheader *o; + classinfo *c; + methodinfo *m; + java_handle_t *o; + int32_t slot; - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + m = &(c->methods[slot]); if (m->signature == NULL) return NULL; @@ -194,6 +219,104 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(J return (java_lang_String *) o; } +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/reflect/Method + * Method: getDefaultValue + * Signature: ()Ljava/lang/Object; + */ +JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefaultValue(JNIEnv *env, struct java_lang_reflect_Method* this) +{ + static methodinfo *m_parseAnnotationDefault = NULL; + utf *utf_parseAnnotationDefault = NULL; + utf *utf_desc = NULL; + sun_reflect_ConstantPool *constantPool = NULL; + java_handle_t *o = (java_handle_t*)this; + + if (this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + constantPool = + (sun_reflect_ConstantPool*)native_new_and_init( + class_sun_reflect_ConstantPool); + + if(constantPool == NULL) { + /* out of memory */ + return NULL; + } + + constantPool->constantPoolOop = (java_lang_Object*)this->clazz; + + /* only resolve the method the first time */ + if (m_parseAnnotationDefault == NULL) { + utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault"); + utf_desc = utf_new_char( + "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)" + "Ljava/lang/Object;"); + + if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) { + /* out of memory */ + return NULL; + } + + m_parseAnnotationDefault = class_resolveclassmethod( + class_sun_reflect_annotation_AnnotationParser, + utf_parseAnnotationDefault, + utf_desc, + o->vftbl->class, + true); + + if (m_parseAnnotationDefault == NULL) + { + /* method not found */ + return NULL; + } + } + + return (java_lang_Object*)vm_call_method( + m_parseAnnotationDefault, NULL, + this, this->annotationDefault, constantPool); +} + + +/* + * Class: java/lang/reflect/Method + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; + */ +JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Method* this) +{ + java_handle_t *o = (java_handle_t*)this; + + if (this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return reflect_get_declaredannotatios(&(this->declaredAnnotations), this->annotations, this->clazz, o->vftbl->class); +} + + +/* + * Class: java/lang/reflect/Method + * Method: getParameterAnnotations + * Signature: ()[[Ljava/lang/annotation/Annotation; + */ +JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Method* this) +{ + java_handle_t *o = (java_handle_t*)this; + + if (this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return reflect_get_parameterannotations((java_handle_t*)this->parameterAnnotations, this->slot, this->clazz, o->vftbl->class); +} +#endif + /* * These are local overrides for various environment variables in Emacs. diff --git a/src/native/vm/java_lang_Class.c b/src/native/vm/java_lang_Class.c index c4f7c76fb..d263a63c4 100644 --- a/src/native/vm/java_lang_Class.c +++ b/src/native/vm/java_lang_Class.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_Class.c 8245 2007-07-31 09:55:04Z michi $ + $Id: java_lang_Class.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -38,6 +38,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" /* keep this order of the native includes */ @@ -73,13 +74,17 @@ #include "vm/exceptions.h" #include "vm/global.h" #include "vm/initialize.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/stringlocal.h" #include "vmcore/class.h" #include "vmcore/loader.h" -#include "vmcore/primitive.h" +#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS) +#include "vmcore/annotation.h" +#include "native/include/sun_reflect_ConstantPool.h" +#endif /* * Class: java/lang/Class @@ -90,6 +95,7 @@ java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass) { classinfo *c; java_lang_String *s; + java_chararray *ca; u4 i; c = (classinfo *) klass; @@ -103,9 +109,11 @@ java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass) /* return string where '/' is replaced by '.' */ - for (i = 0; i < s->value->header.size; i++) { - if (s->value->data[i] == '/') - s->value->data[i] = '.'; + LLNI_field_get_ref(s, value, ca); + + for (i = 0; i < ca->header.size; i++) { + if (ca->data[i] == '/') + ca->data[i] = '.'; } return s; @@ -126,11 +134,11 @@ java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name) #if defined(ENABLE_JAVASE) classloader *cl; #endif - utf *ufile; - utf *uname; - classinfo *c; - u2 *pos; - s4 i; + utf *ufile; + utf *uname; + classinfo *c; + u2 *pos; + s4 i; #if defined(ENABLE_JAVASE) cl = loader_hashtable_classloader_add((java_objectheader *) loader); @@ -145,12 +153,12 @@ java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name) /* create utf string in which '.' is replaced by '/' */ - ufile = javastring_toutf((java_objectheader *) name, true); - uname = javastring_toutf((java_objectheader *) name, false); + ufile = javastring_toutf((java_handle_t *) name, true); + uname = javastring_toutf((java_handle_t *) name, false); /* name must not contain '/' (mauve test) */ - for (i = 0, pos = name->value->data + name->offset; i < name->count; i++, pos++) { + for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) { if (*pos == '/') { exceptions_throw_classnotfoundexception(uname); return NULL; @@ -192,11 +200,11 @@ java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name) */ s4 _Jv_java_lang_Class_isInstance(java_lang_Class *klass, java_lang_Object *o) { - classinfo *c; - java_objectheader *ob; + classinfo *c; + java_handle_t *ob; c = (classinfo *) klass; - ob = (java_objectheader *) o; + ob = (java_handle_t *) o; if (!(c->state & CLASS_LINKED)) if (!link_class(c)) @@ -312,7 +320,7 @@ java_objectarray *_Jv_java_lang_Class_getInterfaces(java_lang_Class *klass) for (i = 0; i < c->interfacescount; i++) { ic = c->interfaces[i].cls; - oa->data[i] = (java_objectheader *) ic; + oa->data[i] = ic; } return oa; @@ -482,7 +490,7 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredClasses(java_lang_Class *klass, if (!link_class(inner)) return NULL; - oa->data[pos++] = (java_objectheader *) inner; + oa->data[pos++] = inner; } } @@ -532,7 +540,7 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredFields(java_lang_Class *klass, /* store object into array */ - oa->data[pos++] = (java_objectheader *) rf; + oa->data[pos++] = rf; } } @@ -595,7 +603,7 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredMethods(java_lang_Class *klass, /* store object into array */ - oa->data[pos++] = (java_objectheader *) rm; + oa->data[pos++] = rm; } } @@ -646,7 +654,7 @@ java_objectarray *_Jv_java_lang_Class_getDeclaredConstructors(java_lang_Class *k /* store object into array */ - oa->data[pos++] = (java_objectheader *) rc; + oa->data[pos++] = rc; } } @@ -698,15 +706,15 @@ JNIEXPORT int32_t JNICALL _Jv_java_lang_Class_isArray(JNIEnv *env, java_lang_Cla */ void _Jv_java_lang_Class_throwException(java_lang_Throwable *t) { - java_objectheader *o; + java_handle_t *o; - o = (java_objectheader *) t; + o = (java_handle_t *) t; exceptions_set_exception(o); } -#if 0 +#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS) /* * Class: java/lang/Class * Method: getDeclaredAnnotations @@ -714,6 +722,72 @@ void _Jv_java_lang_Class_throwException(java_lang_Throwable *t) */ java_objectarray *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass) { + classinfo *c = (classinfo*)klass; + static methodinfo *m_parseAnnotationsIntoArray = NULL; + utf *utf_parseAnnotationsIntoArray = NULL; + utf *utf_desc = NULL; + java_bytearray *annotations = NULL; + sun_reflect_ConstantPool *constantPool = NULL; + uint32_t size = 0; + + if (c == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* Return null for arrays and primitives: */ + if (class_is_primitive(c) || class_is_array(c)) { + return NULL; + } + + if (c->annotations != NULL) { + size = c->annotations->size; + annotations = builtin_newarray_byte(size); + + if(annotations != NULL) { + MCOPY(annotations->data, c->annotations->data, uint8_t, size); + } + } + + constantPool = + (sun_reflect_ConstantPool*)native_new_and_init( + class_sun_reflect_ConstantPool); + + if(constantPool == NULL) { + /* out of memory */ + return NULL; + } + + constantPool->constantPoolOop = (java_lang_Object*)klass; + + /* only resolve the method the first time */ + if (m_parseAnnotationsIntoArray == NULL) { + utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray"); + utf_desc = utf_new_char( + "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)" + "[Ljava/lang/annotation/Annotation;"); + + if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) { + /* out of memory */ + return NULL; + } + + m_parseAnnotationsIntoArray = class_resolveclassmethod( + class_sun_reflect_annotation_AnnotationParser, + utf_parseAnnotationsIntoArray, + utf_desc, + class_java_lang_Class, + true); + + if (m_parseAnnotationsIntoArray == NULL) { + /* method not found */ + return NULL; + } + } + + return vm_call_method( + m_parseAnnotationsIntoArray, NULL, + annotations, constantPool, klass); } #endif @@ -877,8 +951,8 @@ java_lang_reflect_Method *_Jv_java_lang_Class_getEnclosingMethod(java_lang_Class */ java_lang_String *_Jv_java_lang_Class_getClassSignature(java_lang_Class* klass) { - classinfo *c; - java_objectheader *o; + classinfo *c; + java_handle_t *o; c = (classinfo *) klass; diff --git a/src/native/vm/java_lang_Class.h b/src/native/vm/java_lang_Class.h index 758974791..4d9896e7f 100644 --- a/src/native/vm/java_lang_Class.h +++ b/src/native/vm/java_lang_Class.h @@ -83,7 +83,7 @@ JNIEXPORT int32_t JNICALL _Jv_java_lang_Class_isArray(JNIEnv *env, java_lan #if defined(ENABLE_JAVASE) void _Jv_java_lang_Class_throwException(java_lang_Throwable *t); -#if 0 +#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS) java_objectarray *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass); #endif diff --git a/src/native/vm/java_lang_ClassLoader.c b/src/native/vm/java_lang_ClassLoader.c index 3fcac77bf..bb209a3c7 100644 --- a/src/native/vm/java_lang_ClassLoader.c +++ b/src/native/vm/java_lang_ClassLoader.c @@ -39,6 +39,7 @@ #include "vm/global.h" /* required by native headers */ #include "native/jni.h" +#include "native/llni.h" /* keep this order of the native includes */ @@ -107,7 +108,7 @@ java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl if (name != NULL) { /* convert '.' to '/' in java string */ - utfname = javastring_toutf((java_objectheader *) name, true); + utfname = javastring_toutf((java_handle_t *) name, true); } else { utfname = NULL; @@ -120,7 +121,7 @@ java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl if (jvmti) jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, - loader, (java_objectheader *) pd, + loader, (java_handle_t *) pd, &new_class_data_len, &new_class_data); #endif @@ -145,7 +146,7 @@ java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl #if defined(WITH_CLASSPATH_GNU) /* set ProtectionDomain */ - o->pd = pd; + LLNI_field_set_ref(o, pd, pd); #endif return o; diff --git a/src/native/vm/java_lang_Object.c b/src/native/vm/java_lang_Object.c index be107dde0..f5ff5afa7 100644 --- a/src/native/vm/java_lang_Object.c +++ b/src/native/vm/java_lang_Object.c @@ -34,6 +34,7 @@ #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/include/java_lang_Object.h" #include "native/include/java_lang_String.h" /* required by j.l.CL */ @@ -68,17 +69,14 @@ */ java_lang_Class *_Jv_java_lang_Object_getClass(java_lang_Object *obj) { - java_objectheader *o; - classinfo *c; + classinfo *c; - o = (java_objectheader *) obj; - - if (o == NULL) { + if (obj == NULL) { exceptions_throw_nullpointerexception(); return NULL; } - c = o->vftbl->class; + LLNI_class_get(obj, c); return (java_lang_Class *) c; } @@ -92,7 +90,7 @@ java_lang_Class *_Jv_java_lang_Object_getClass(java_lang_Object *obj) void _Jv_java_lang_Object_notify(java_lang_Object *this) { #if defined(ENABLE_THREADS) - lock_notify_object(&this->header); + lock_notify_object(&LLNI_field_direct(this, header)); #endif } @@ -105,7 +103,7 @@ void _Jv_java_lang_Object_notify(java_lang_Object *this) void _Jv_java_lang_Object_notifyAll(java_lang_Object *this) { #if defined(ENABLE_THREADS) - lock_notify_all_object(&this->header); + lock_notify_all_object(&LLNI_field_direct(this, header)); #endif } @@ -123,7 +121,7 @@ void _Jv_java_lang_Object_wait(java_lang_Object *o, s8 ms, s4 ns) #endif #if defined(ENABLE_THREADS) - lock_wait_for_object(&o->header, ms, ns); + lock_wait_for_object(&LLNI_field_direct(o, header), ms, ns); #endif #if defined(ENABLE_JVMTI) @@ -143,10 +141,10 @@ void _Jv_java_lang_Object_wait(java_lang_Object *o, s8 ms, s4 ns) */ java_lang_Object *_Jv_java_lang_Object_clone(java_lang_Cloneable *this) { - java_objectheader *o; - java_objectheader *co; + java_handle_t *o; + java_handle_t *co; - o = (java_objectheader *) this; + o = (java_handle_t *) this; co = builtin_clone(NULL, o); diff --git a/src/native/vm/java_lang_Runtime.c b/src/native/vm/java_lang_Runtime.c index daa4bf0f2..4a363e368 100644 --- a/src/native/vm/java_lang_Runtime.c +++ b/src/native/vm/java_lang_Runtime.c @@ -108,9 +108,9 @@ void _Jv_java_lang_Runtime_gc(void) * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I */ #if defined(ENABLE_JNI) -s4 _Jv_java_lang_Runtime_loadLibrary(JNIEnv *env, java_lang_String *libname, java_objectheader *cl) +s4 _Jv_java_lang_Runtime_loadLibrary(JNIEnv *env, java_lang_String *libname, classloader *cl) #else -s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, java_objectheader *cl) +s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, classloader *cl) #endif { #if defined(ENABLE_LTDL) @@ -126,7 +126,7 @@ s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, java_objectheade return 0; } - name = javastring_toutf((java_objectheader *) libname, false); + name = javastring_toutf((java_handle_t *) libname, false); /* is the library already loaded? */ diff --git a/src/native/vm/java_lang_Runtime.h b/src/native/vm/java_lang_Runtime.h index 2061a651e..eed7b92a9 100644 --- a/src/native/vm/java_lang_Runtime.h +++ b/src/native/vm/java_lang_Runtime.h @@ -45,9 +45,9 @@ s8 _Jv_java_lang_Runtime_totalMemory(void); void _Jv_java_lang_Runtime_gc(void); #if defined(ENABLE_JNI) -s4 _Jv_java_lang_Runtime_loadLibrary(JNIEnv *env, java_lang_String *libname, java_objectheader *cl); +s4 _Jv_java_lang_Runtime_loadLibrary(JNIEnv *env, java_lang_String *libname, classloader *cl); #else -s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, java_objectheader *cl); +s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, classloader *cl); #endif #if defined(ENABLE_JAVASE) diff --git a/src/native/vm/java_lang_Thread.c b/src/native/vm/java_lang_Thread.c index 421c1823e..0e33fc253 100644 --- a/src/native/vm/java_lang_Thread.c +++ b/src/native/vm/java_lang_Thread.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_Thread.c 8132 2007-06-22 11:15:47Z twisti $ + $Id: java_lang_Thread.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -31,6 +31,7 @@ #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_String.h" @@ -108,7 +109,7 @@ void _Jv_java_lang_Thread_interrupt(java_lang_Thread *this) threadobject *thread; #if defined(WITH_CLASSPATH_GNU) - thread = (threadobject *) this->vmThread->vmdata; + thread = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata); #elif defined(WITH_CLASSPATH_CLDC1_1) thread = (threadobject *) this->vm_thread; #endif @@ -129,8 +130,11 @@ s4 _Jv_java_lang_Thread_isAlive(java_lang_Thread *this) threadobject *t; # if defined(WITH_CLASSPATH_GNU) - t = (threadobject *) this->vmThread->vmdata; + + t = (threadobject *) LLNI_field_direct(LLNI_field_direct(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)) { @@ -143,8 +147,14 @@ s4 _Jv_java_lang_Thread_isAlive(java_lang_Thread *this) if (t == NULL) return 0; + # elif defined(WITH_CLASSPATH_CLDC1_1) + t = (threadobject *) this->vm_thread; + + if (t == NULL) + return 0; + # else # error unknown classpath configuration # endif @@ -169,7 +179,7 @@ s4 _Jv_java_lang_Thread_isInterrupted(java_lang_Thread *this) threadobject *t; # if defined(WITH_CLASSPATH_GNU) - t = (threadobject *) this->vmThread->vmdata; + t = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata); # elif defined(WITH_CLASSPATH_SUN) /* XXX this is just a quick hack */ @@ -225,7 +235,7 @@ void _Jv_java_lang_Thread_setPriority(java_lang_Thread *this, s4 priority) threadobject *t; # if defined(WITH_CLASSPATH_GNU) - t = (threadobject *) this->vmThread->vmdata; + t = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata); # elif defined(WITH_CLASSPATH_SUN) /* XXX this is just a quick hack */ @@ -289,13 +299,13 @@ java_lang_Thread *_Jv_java_lang_Thread_currentThread(void) log_text("t ptr is NULL\n"); # if defined(ENABLE_JAVASE) - if (t->group == NULL) { + if (LLNI_field_direct(t, group) == NULL) { /* ThreadGroup of currentThread is not initialized */ - t->group = (java_lang_ThreadGroup *) + LLNI_field_direct(t, group) = (java_lang_ThreadGroup *) native_new_and_init(class_java_lang_ThreadGroup); - if (t->group == NULL) + if (LLNI_field_direct(t, group) == NULL) log_text("unable to create ThreadGroup"); } # endif @@ -346,9 +356,9 @@ s4 _Jv_java_lang_Thread_interrupted(void) s4 _Jv_java_lang_Thread_holdsLock(java_lang_Object* obj) { #if defined(ENABLE_THREADS) - java_objectheader *o; + java_handle_t *o; - o = (java_objectheader *) obj; + o = (java_handle_t *) obj; if (o == NULL) { exceptions_throw_nullpointerexception(); @@ -370,12 +380,12 @@ s4 _Jv_java_lang_Thread_holdsLock(java_lang_Object* obj) java_lang_String *_Jv_java_lang_Thread_getState(java_lang_Thread *this) { #if defined(ENABLE_THREADS) - threadobject *thread; - utf *u; - java_objectheader *o; + threadobject *thread; + utf *u; + java_handle_t *o; # if defined(WITH_CLASSPATH_GNU) - thread = (threadobject *) this->vmThread->vmdata; + thread = (threadobject *) LLNI_field_direct(LLNI_field_direct(this, vmThread), vmdata); # elif defined(WITH_CLASSPATH_CLDC1_1) thread = (threadobject *) this->vm_thread; # endif diff --git a/src/native/vm/java_lang_reflect_Method.c b/src/native/vm/java_lang_reflect_Method.c index 0830afd22..7e48c32e9 100644 --- a/src/native/vm/java_lang_reflect_Method.c +++ b/src/native/vm/java_lang_reflect_Method.c @@ -34,6 +34,7 @@ #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Object.h" @@ -58,18 +59,21 @@ java_lang_Object *_Jv_java_lang_reflect_Method_invoke(java_lang_reflect_Method * classinfo *c; methodinfo *m; s4 override; + int32_t slot; + + LLNI_field_get_cls(this, clazz, c); + LLNI_field_get_val(this, slot , slot); + m = &(c->methods[slot]); - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); /* check method access */ /* check if we should bypass security checks (AccessibleObject) */ #if defined(WITH_CLASSPATH_GNU) - override = this->flag; + LLNI_field_get_val(this, flag, override); #elif defined(WITH_CLASSPATH_SUN) - override = this->override; + LLNI_field_get_val(this, override, override); #else # error unknown classpath configuration #endif @@ -87,7 +91,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, (java_objectheader *) o, args); + return (java_lang_Object *) _Jv_jni_invokeNative(m, (java_handle_t *) o, args); } diff --git a/src/native/vm/nativevm.c b/src/native/vm/nativevm.c index fdf4aa063..bc1f0b9b8 100644 --- a/src/native/vm/nativevm.c +++ b/src/native/vm/nativevm.c @@ -81,6 +81,10 @@ bool nativevm_preinit(void) _Jv_java_util_concurrent_atomic_AtomicLong_init(); _Jv_sun_misc_Unsafe_init(); +#if defined(ENABLE_ANNOTATIONS) + _Jv_sun_reflect_ConstantPool_init(); +#endif + # elif defined(WITH_CLASSPATH_SUN) utf *u; diff --git a/src/native/vm/nativevm.h b/src/native/vm/nativevm.h index 8920fa859..f2b824bcc 100644 --- a/src/native/vm/nativevm.h +++ b/src/native/vm/nativevm.h @@ -68,6 +68,10 @@ void _Jv_java_security_VMAccessController_init(); void _Jv_java_util_concurrent_atomic_AtomicLong_init(); void _Jv_sun_misc_Unsafe_init(); +#if defined(ENABLE_ANNOTATIONS) +void _Jv_sun_reflect_ConstantPool_init(); +#endif + # elif defined(WITH_CLASSPATH_SUN) void _Jv_sun_misc_Unsafe_init(); diff --git a/src/native/vm/sun_misc_Unsafe.c b/src/native/vm/sun_misc_Unsafe.c index fcc6d571b..11ec8c5c4 100644 --- a/src/native/vm/sun_misc_Unsafe.c +++ b/src/native/vm/sun_misc_Unsafe.c @@ -34,6 +34,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Object.h" /* before c.l.C */ @@ -371,9 +372,11 @@ JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, su { classinfo *c; fieldinfo *f; + int32_t slot; - c = (classinfo *) field->clazz; - f = &c->fields[field->slot]; + LLNI_field_get_cls(field, clazz, c); + LLNI_field_get_val(field, slot , slot); + f = &c->fields[slot]; return (int64_t) f->offset; } @@ -431,11 +434,13 @@ JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, su { classinfo *c; fieldinfo *f; + int32_t slot; - c = (classinfo *) field->clazz; - f = &(c->fields[field->slot]); + LLNI_field_get_cls(field, clazz, c); + LLNI_field_get_val(field, slot , slot); + f = &(c->fields[slot]); - return (int64_t) (intptr_t) &(f->value); + return (int64_t) (intptr_t) f->value; } @@ -532,12 +537,12 @@ JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, sun_misc */ JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, sun_misc_Unsafe *this, java_lang_String *name, java_bytearray *b, int32_t off, int32_t len, java_lang_ClassLoader *loader, java_security_ProtectionDomain *protectionDomain) { - java_objectheader *cl; - utf *utfname; - classinfo *c; - java_lang_Class *o; + classloader *cl; + utf *utfname; + classinfo *c; + java_lang_Class *o; - cl = (java_objectheader *) loader; + cl = (classloader *) loader; /* check if data was passed */ @@ -556,7 +561,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_ if (name != NULL) { /* convert '.' to '/' in java string */ - utfname = javastring_toutf((java_objectheader *) name, true); + utfname = javastring_toutf((java_handle_t *) name, true); } else { utfname = NULL; @@ -576,7 +581,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_ #if defined(WITH_CLASSPATH_GNU) /* set ProtectionDomain */ - o->pd = protectionDomain; + LLNI_field_set_ref(o, pd, protectionDomain); #endif return o; @@ -590,9 +595,9 @@ JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_ */ JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Throwable *ee) { - java_objectheader *o; + java_handle_t *o; - o = (java_objectheader *) ee; + o = (java_handle_t *) ee; exceptions_set_exception(o); } diff --git a/src/threads/critical.c b/src/threads/critical.c index 5dda6b4c1..d49ca068d 100644 --- a/src/threads/critical.c +++ b/src/threads/critical.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -37,8 +38,6 @@ #include "toolbox/avl.h" -#include "vm/jit/asmpart.h" - /* the AVL tree containing the critical sections */ @@ -47,8 +46,7 @@ static avl_tree_t *criticaltree; /* prototypes *****************************************************************/ -static s4 critical_comparator(const void *treenode, const void *node); -static void critical_register_asm_critical_sections(void); +static int critical_comparator(const void *treenode, const void *node); /* critical_init *************************************************************** @@ -60,8 +58,6 @@ static void critical_register_asm_critical_sections(void); void critical_init(void) { criticaltree = avl_create(&critical_comparator); - - critical_register_asm_critical_sections(); } @@ -78,7 +74,7 @@ void critical_init(void) *******************************************************************************/ -static s4 critical_comparator(const void *treenode, const void *node) +static int critical_comparator(const void *treenode, const void *node) { const critical_section_node_t *treecsn; const critical_section_node_t *csn; @@ -160,24 +156,6 @@ u1 *critical_find_restart_point(u1 *pc) } -/* critical_register_asm_critical_sections ************************************* - - Register critical sections defined in the array asm_criticalsections. - -*******************************************************************************/ - -static void critical_register_asm_critical_sections(void) -{ - /* XXX TWISTI: this is just a quick hack */ -#if defined(ENABLE_JIT) && defined(ENABLE_THREADS) - critical_section_node_t *n = &asm_criticalsections; - - while (n->start) - critical_section_register(n++); -#endif -} - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/threads/native/lock.c b/src/threads/native/lock.c index a10877933..fd5e6f5fa 100644 --- a/src/threads/native/lock.c +++ b/src/threads/native/lock.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: lock.c 7954 2007-05-23 17:58:18Z twisti $ + $Id: lock.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -426,7 +426,7 @@ static void lock_hashtable_grow(void) static void lock_record_finalizer(void *object, void *p); #endif -static lock_record_t *lock_hashtable_get(java_objectheader *o) +static lock_record_t *lock_hashtable_get(java_object_t *o) { ptrint lockword; u4 slot; @@ -499,7 +499,7 @@ static lock_record_t *lock_hashtable_get(java_objectheader *o) *******************************************************************************/ -static void lock_hashtable_remove(java_objectheader *o) +static void lock_hashtable_remove(java_object_t *o) { ptrint lockword; lock_record_t *lr; @@ -557,11 +557,11 @@ static void lock_hashtable_remove(java_objectheader *o) static void lock_record_finalizer(void *object, void *p) { - java_objectheader *o; - ptrint lockword; - lock_record_t *lr; + java_object_t *o; + ptrint lockword; + lock_record_t *lr; - o = (java_objectheader *) object; + o = (java_object_t *) object; /* check for a finalizer function */ @@ -598,7 +598,7 @@ static void lock_record_finalizer(void *object, void *p) *******************************************************************************/ -void lock_init_object_lock(java_objectheader *o) +void lock_init_object_lock(java_object_t *o) { assert(o); @@ -683,7 +683,7 @@ static inline void lock_record_exit(threadobject *t, lock_record_t *lr) *******************************************************************************/ -static void lock_inflate(threadobject *t, java_objectheader *o, lock_record_t *lr) +static void lock_inflate(threadobject *t, java_object_t *o, lock_record_t *lr) { ptrint lockword; @@ -736,7 +736,7 @@ static void lock_inflate(threadobject *t, java_objectheader *o, lock_record_t *l *******************************************************************************/ -bool lock_monitor_enter(java_objectheader *o) +bool lock_monitor_enter(java_object_t *o) { threadobject *t; /* CAUTION: This code assumes that ptrint is unsigned! */ @@ -888,7 +888,7 @@ bool lock_monitor_enter(java_objectheader *o) *******************************************************************************/ -bool lock_monitor_exit(java_objectheader *o) +bool lock_monitor_exit(java_object_t *o) { threadobject *t; ptrint lockword; @@ -1143,7 +1143,7 @@ static void lock_record_wait(threadobject *thread, lock_record_t *lr, s8 millis, *******************************************************************************/ -static void lock_monitor_wait(threadobject *t, java_objectheader *o, s8 millis, s4 nanos) +static void lock_monitor_wait(threadobject *t, java_object_t *o, s8 millis, s4 nanos) { ptrint lockword; lock_record_t *lr; @@ -1246,7 +1246,7 @@ static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one) *******************************************************************************/ -static void lock_monitor_notify(threadobject *t, java_objectheader *o, bool one) +static void lock_monitor_notify(threadobject *t, java_object_t *o, bool one) { ptrint lockword; lock_record_t *lr; @@ -1306,7 +1306,7 @@ static void lock_monitor_notify(threadobject *t, java_objectheader *o, bool one) *******************************************************************************/ -bool lock_is_held_by_current_thread(java_objectheader *o) +bool lock_is_held_by_current_thread(java_object_t *o) { threadobject *t; ptrint lockword; @@ -1352,7 +1352,7 @@ bool lock_is_held_by_current_thread(java_objectheader *o) *******************************************************************************/ -void lock_wait_for_object(java_objectheader *o, s8 millis, s4 nanos) +void lock_wait_for_object(java_object_t *o, s8 millis, s4 nanos) { threadobject *thread; @@ -1371,7 +1371,7 @@ void lock_wait_for_object(java_objectheader *o, s8 millis, s4 nanos) *******************************************************************************/ -void lock_notify_object(java_objectheader *o) +void lock_notify_object(java_object_t *o) { threadobject *thread; @@ -1390,7 +1390,7 @@ void lock_notify_object(java_objectheader *o) *******************************************************************************/ -void lock_notify_all_object(java_objectheader *o) +void lock_notify_all_object(java_object_t *o) { threadobject *thread; diff --git a/src/threads/native/lock.h b/src/threads/native/lock.h index 094584386..b6cf995ca 100644 --- a/src/threads/native/lock.h +++ b/src/threads/native/lock.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: lock.h 7954 2007-05-23 17:58:18Z twisti $ + $Id: lock.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -66,7 +66,7 @@ struct lock_waiter_t { *******************************************************************************/ struct lock_record_t { - java_objectheader *object; /* object for which this lock is */ + java_object_t *object; /* object for which this lock is */ struct threadobject *owner; /* current owner of this monitor */ s4 count; /* recursive lock count */ pthread_mutex_t mutex; /* mutex for synchronizing */ @@ -91,10 +91,10 @@ struct lock_hashtable_t { /* defines ********************************************************************/ -#define LOCK_INIT_OBJECT_LOCK(o) lock_init_object_lock((java_objectheader *) (o)) +#define LOCK_INIT_OBJECT_LOCK(o) lock_init_object_lock((java_object_t *) (o)) -#define LOCK_MONITOR_ENTER(o) lock_monitor_enter((java_objectheader *) (o)) -#define LOCK_MONITOR_EXIT(o) lock_monitor_exit((java_objectheader *) (o)) +#define LOCK_MONITOR_ENTER(o) lock_monitor_enter((java_object_t *) (o)) +#define LOCK_MONITOR_EXIT(o) lock_monitor_exit((java_object_t *) (o)) #endif /* _LOCK_H */ diff --git a/src/threads/native/threads.c b/src/threads/native/threads.c index 5b3da0ffc..035b96bcd 100644 --- a/src/threads/native/threads.c +++ b/src/threads/native/threads.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: threads.c 8181 2007-07-05 20:23:10Z michi $ + $Id: threads.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -61,6 +61,7 @@ #endif #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Object.h" #include "native/include/java_lang_String.h" @@ -857,10 +858,10 @@ void threads_mutex_join_unlock(void) bool threads_init(void) { - threadobject *mainthread; - java_objectheader *threadname; - java_lang_Thread *t; - java_objectheader *o; + threadobject *mainthread; + java_handle_t *threadname; + java_lang_Thread *t; + java_handle_t *o; #if defined(ENABLE_JAVASE) java_lang_ThreadGroup *threadgroup; @@ -947,11 +948,11 @@ bool threads_init(void) /* set the thread */ - vmt->thread = t; - vmt->vmdata = (java_lang_Object *) mainthread; + LLNI_field_set_ref(vmt, thread, t); + LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) mainthread); /* call java.lang.Thread.(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */ - o = (java_objectheader *) t; + o = (java_handle_t *) t; (void) vm_call_method(method_thread_init, o, vmt, threadname, NORM_PRIORITY, false); @@ -971,7 +972,7 @@ bool threads_init(void) /* call public Thread(String name) */ - o = (java_objectheader *) t; + o = (java_handle_t *) t; (void) vm_call_method(method_thread_init, o, threadname); #else @@ -982,7 +983,7 @@ bool threads_init(void) return false; #if defined(ENABLE_JAVASE) - t->group = threadgroup; + LLNI_field_set_ref(t, group, threadgroup); # if defined(WITH_CLASSPATH_GNU) /* add main thread to java.lang.ThreadGroup */ @@ -993,7 +994,7 @@ bool threads_init(void) class_java_lang_ThreadGroup, true); - o = (java_objectheader *) threadgroup; + o = (java_handle_t *) threadgroup; (void) vm_call_method(m, o, t); @@ -1058,7 +1059,7 @@ static void *threads_startup_thread(void *arg) sem_t *psem; classinfo *c; methodinfo *m; - java_objectheader *o; + java_handle_t *o; functionptr function; #if defined(ENABLE_INTRP) @@ -1098,7 +1099,7 @@ static void *threads_startup_thread(void *arg) /* set our priority */ - threads_set_thread_priority(thread->tid, thread->object->priority); + threads_set_thread_priority(thread->tid, LLNI_field_direct(thread->object, priority)); /* thread is completely initialized */ @@ -1165,11 +1166,11 @@ static void *threads_startup_thread(void *arg) #if defined(WITH_CLASSPATH_GNU) /* we need to start the run method of java.lang.VMThread */ - vmt = (java_lang_VMThread *) thread->object->vmThread; - o = (java_objectheader *) vmt; + vmt = (java_lang_VMThread *) LLNI_field_direct(thread->object, vmThread); + o = (java_handle_t *) vmt; #elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1) - o = (java_objectheader *) thread->object; + o = (java_handle_t *) thread->object; #else # error unknown classpath configuration #endif @@ -1329,13 +1330,14 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) { threadobject *thread; utf *u; - java_objectheader *s; - java_objectheader *o; + java_handle_t *s; + java_handle_t *o; java_lang_Thread *t; #if defined(ENABLE_JAVASE) java_lang_ThreadGroup *group; threadobject *mainthread; + classinfo *c; methodinfo *m; #endif @@ -1408,8 +1410,8 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) /* set the thread */ - vmt->thread = t; - vmt->vmdata = (java_lang_Object *) thread; + LLNI_field_set_ref(vmt, thread, t); + LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) thread); #elif defined(WITH_CLASSPATH_SUN) @@ -1417,7 +1419,7 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) #elif defined(WITH_CLASSPATH_CLDC1_1) - t->vm_thread = (java_lang_Object *) thread; + LLNI_field_set_val(t, vm_thread, (java_lang_Object *) thread); #else # error unknown classpath configuration @@ -1435,7 +1437,7 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) /* get the main thread */ mainthread = threads_list_first(); - group = mainthread->object->group; + group = LLNI_field_direct(mainthread->object, group); #endif } @@ -1445,7 +1447,7 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) /* for convenience */ - o = (java_objectheader *) thread->object; + o = (java_handle_t *) thread->object; #if defined(WITH_CLASSPATH_GNU) (void) vm_call_method(method_thread_init, o, vmt, s, NORM_PRIORITY, @@ -1460,17 +1462,19 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) #if defined(ENABLE_JAVASE) /* store the thread group in the object */ - thread->object->group = group; + LLNI_field_direct(thread->object, group) = group; /* add thread to given thread-group */ - m = class_resolveclassmethod(group->header.vftbl->class, + LLNI_class_get(group, c); + + m = class_resolveclassmethod(c, utf_addThread, utf_java_lang_Thread__V, class_java_lang_ThreadGroup, true); - o = (java_objectheader *) group; + o = (java_handle_t *) group; (void) vm_call_method(m, o, t); @@ -1492,8 +1496,9 @@ bool threads_detach_thread(threadobject *thread) { #if defined(ENABLE_JAVASE) java_lang_ThreadGroup *group; + classinfo *c; methodinfo *m; - java_objectheader *o; + java_handle_t *o; java_lang_Thread *t; #endif @@ -1502,19 +1507,21 @@ bool threads_detach_thread(threadobject *thread) #if defined(ENABLE_JAVASE) /* remove thread from the thread group */ - group = thread->object->group; + group = LLNI_field_direct(thread->object, group); /* XXX TWISTI: should all threads be in a ThreadGroup? */ if (group != NULL) { + LLNI_class_get(group, c); + # if defined(WITH_CLASSPATH_GNU) - m = class_resolveclassmethod(group->header.vftbl->class, + m = class_resolveclassmethod(c, utf_removeThread, utf_java_lang_Thread__V, class_java_lang_ThreadGroup, true); # elif defined(WITH_CLASSPATH_SUN) - m = class_resolveclassmethod(group->header.vftbl->class, + m = class_resolveclassmethod(c, utf_remove, utf_java_lang_Thread__V, class_java_lang_ThreadGroup, @@ -1526,7 +1533,7 @@ bool threads_detach_thread(threadobject *thread) if (m == NULL) return false; - o = (java_objectheader *) group; + o = (java_handle_t *) group; t = thread->object; (void) vm_call_method(m, o, t); diff --git a/src/threads/native/threads.h b/src/threads/native/threads.h index c938e3875..dc6c22066 100644 --- a/src/threads/native/threads.h +++ b/src/threads/native/threads.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: threads.h 8245 2007-07-31 09:55:04Z michi $ + $Id: threads.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -44,6 +44,7 @@ typedef struct threadobject threadobject; #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/include/java_lang_Thread.h" #include "threads/native/lock.h" @@ -140,7 +141,7 @@ struct threadobject { u1 *pc; /* current PC (used for profiling) */ - java_objectheader *_exceptionptr; /* current exception */ + java_object_t *_exceptionptr; /* current exception */ stackframeinfo *_stackframeinfo; /* current native stackframeinfo */ localref_table *_localref_table; /* JNI local references */ diff --git a/src/threads/none/threads.h b/src/threads/none/threads.h index 19146040a..044bc3259 100644 --- a/src/threads/none/threads.h +++ b/src/threads/none/threads.h @@ -46,7 +46,7 @@ /* exception pointer **********************************************************/ -extern java_objectheader *_no_threads_exceptionptr; +extern java_object_t *_no_threads_exceptionptr; #define exceptionptr (&_no_threads_exceptionptr) diff --git a/src/threads/threads-common.c b/src/threads/threads-common.c index 5a0b8da5c..42f55ee72 100644 --- a/src/threads/threads-common.c +++ b/src/threads/threads-common.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: threads-common.c 8137 2007-06-22 16:41:36Z michi $ + $Id: threads-common.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -37,6 +38,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/include/java_lang_Object.h" #include "native/include/java_lang_String.h" @@ -94,7 +96,7 @@ bool threads_pthreads_implementation_nptl; void threads_preinit(void) { threadobject *mainthread; -#if defined(__LINUX__) +#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION) char *pathbuf; size_t len; #endif @@ -327,7 +329,8 @@ threadobject *threads_thread_new(void) void threads_thread_free(threadobject *t) { - s4 index; + int32_t index; + uint32_t state; /* lock the threads-lists */ @@ -341,15 +344,19 @@ void threads_thread_free(threadobject *t) list_remove_unsynced(list_threads, t); - /* Clear memory, but keep the thread-index. */ + /* Clear memory, but keep the thread-index and the + thread-state. */ + /* ATTENTION: Do this after list_remove, otherwise the linkage pointers are invalid. */ index = t->index; + state = t->state; MZERO(t, threadobject, 1); t->index = index; + t->state = state; /* add the thread to the free list */ @@ -412,12 +419,12 @@ bool threads_thread_start_internal(utf *name, functionptr f) if (vmt == NULL) return false; - vmt->thread = object; - vmt->vmdata = (java_lang_Object *) t; + LLNI_field_set_ref(vmt, thread, object); + LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) t); - object->vmThread = vmt; + LLNI_field_set_ref(object, vmThread, vmt); #elif defined(WITH_CLASSPATH_CLDC1_1) - object->vm_thread = (java_lang_Object *) t; + LLNI_field_set_val(object, vm_thread, (java_lang_Object *) t); #endif t->object = object; @@ -425,18 +432,18 @@ bool threads_thread_start_internal(utf *name, functionptr f) /* set java.lang.Thread fields */ #if defined(WITH_CLASSPATH_GNU) - object->name = (java_lang_String *) javastring_new(name); + LLNI_field_set_ref(object, name , (java_lang_String *) javastring_new(name)); #elif defined(WITH_CLASSPATH_CLDC1_1) /* FIXME: In cldc the name is a char[] */ -/* object->name = (java_chararray *) javastring_new(name); */ - object->name = NULL; +/* LLNI_field_set_ref(object, name , (java_chararray *) javastring_new(name)); */ + LLNI_field_set_ref(object, name , NULL); #endif #if defined(ENABLE_JAVASE) - object->daemon = true; + LLNI_field_set_val(object, daemon , true); #endif - object->priority = NORM_PRIORITY; + LLNI_field_set_val(object, priority, NORM_PRIORITY); /* start the thread */ @@ -461,6 +468,9 @@ bool threads_thread_start_internal(utf *name, functionptr f) void threads_thread_start(java_lang_Thread *object) { threadobject *thread; +#if defined(WITH_CLASSPATH_GNU) + java_lang_VMThread *vmt; +#endif /* Enter the join-mutex, so if the main-thread is currently waiting to join all threads, the number of non-daemon threads @@ -479,7 +489,7 @@ void threads_thread_start(java_lang_Thread *object) #if defined(ENABLE_JAVASE) /* is this a daemon thread? */ - if (object->daemon == true) + if (LLNI_field_direct(object, daemon) == true) thread->flags |= THREAD_FLAG_DAEMON; #endif @@ -493,12 +503,14 @@ void threads_thread_start(java_lang_Thread *object) thread->object = object; #if defined(WITH_CLASSPATH_GNU) - assert(object->vmThread); - assert(object->vmThread->vmdata == NULL); + LLNI_field_get_ref(object, vmThread, vmt); + + assert(vmt); + assert(LLNI_field_direct(vmt, vmdata) == NULL); - object->vmThread->vmdata = (java_lang_Object *) thread; + LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) thread); #elif defined(WITH_CLASSPATH_CLDC1_1) - object->vm_thread = (java_lang_Object *) thread; + LLNI_field_set_val(object, vm_thread, (java_lang_Object *) thread); #endif /* Start the thread. Don't pass a function pointer (NULL) since @@ -529,7 +541,7 @@ void threads_thread_print_info(threadobject *t) /* get thread name */ #if defined(WITH_CLASSPATH_GNU) - name = javastring_toutf((java_objectheader *) object->name, false); + name = javastring_toutf((java_handle_t *) LLNI_field_direct(object, name), false); #elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1) /* FIXME: In cldc the name is a char[] */ /* name = object->name; */ @@ -545,7 +557,7 @@ void threads_thread_print_info(threadobject *t) if (t->flags & THREAD_FLAG_DAEMON) printf(" daemon"); - printf(" prio=%d", object->priority); + printf(" prio=%d", LLNI_field_direct(object, priority)); #if SIZEOF_VOID_P == 8 printf(" t=0x%016lx tid=0x%016lx (%ld)", diff --git a/src/toolbox/avl.c b/src/toolbox/avl.c index 54195c0aa..ded095ab5 100644 --- a/src/toolbox/avl.c +++ b/src/toolbox/avl.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: avl.c 7862 2007-05-03 14:53:39Z twisti $ + $Id: avl.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -63,7 +63,7 @@ avl_tree_t *avl_create(avl_comparator *comparator) #if defined(ENABLE_THREADS) /* create lock object for this tree */ - t->lock = NEW(java_objectheader); + t->lock = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(t->lock); #endif diff --git a/src/toolbox/avl.h b/src/toolbox/avl.h index 9e9b05229..5b2ce8808 100644 --- a/src/toolbox/avl.h +++ b/src/toolbox/avl.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: avl.h 7860 2007-05-03 12:30:05Z twisti $ + $Id: avl.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -58,7 +58,7 @@ typedef struct avl_node_t avl_node_t; struct avl_tree_t { #if defined(ENABLE_THREADS) - java_objectheader *lock; /* threads lock object */ + java_object_t *lock; /* threads lock object */ #endif avl_node_t *root; /* pointer to root node */ avl_comparator *comparator; /* pointer to comparison function */ diff --git a/src/toolbox/hashtable.c b/src/toolbox/hashtable.c index 4c394c79c..fa3519266 100644 --- a/src/toolbox/hashtable.c +++ b/src/toolbox/hashtable.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: hashtable.c 7813 2007-04-25 19:20:13Z twisti $ + $Id: hashtable.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -51,11 +51,11 @@ void hashtable_create(hashtable *hash, u4 size) /* initialize locking pointer */ #if defined(ENABLE_THREADS) - /* We need to seperately allocate a java_objectheader here, as we + /* We need to seperately allocate a java_object_t here, as we need to store the lock object in the new hashtable if it's resized. Otherwise we get an IllegalMonitorStateException. */ - hash->header = NEW(java_objectheader); + hash->header = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(hash->header); #endif @@ -91,7 +91,7 @@ hashtable *hashtable_resize(hashtable *hash, u4 size) /* We need to store the old lock object in the new hashtable. Otherwise we get an IllegalMonitorStateException. */ - FREE(newhash->header, java_objectheader); + FREE(newhash->header, java_object_t); newhash->header = hash->header; #endif diff --git a/src/toolbox/hashtable.h b/src/toolbox/hashtable.h index 056dbc1c0..f88f6f888 100644 --- a/src/toolbox/hashtable.h +++ b/src/toolbox/hashtable.h @@ -27,7 +27,7 @@ Authors: Reinhard Grafl Christian Thalinger - $Id: hashtable.h 7246 2007-01-29 18:49:05Z twisti $ + $Id: hashtable.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -102,7 +102,7 @@ hashtable.ptr-->+-------------------+ struct hashtable { #if defined(ENABLE_THREADS) - java_objectheader *header; /* required for locking */ + java_object_t *header; /* required for locking */ #endif u4 size; /* current size of the hashtable */ u4 entries; /* number of entries in the table */ diff --git a/src/toolbox/list.h b/src/toolbox/list.h index 230a80fa2..0552d6bbf 100644 --- a/src/toolbox/list.h +++ b/src/toolbox/list.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: list.h 7905 2007-05-14 14:11:33Z twisti $ + $Id: list.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -109,7 +109,7 @@ typedef struct list_t list_t; struct list_t { #if defined(ENABLE_THREADS) - java_objectheader lock; /* threads lock object */ + java_object_t lock; /* threads lock object */ #endif listnode_t *first; listnode_t *last; diff --git a/src/toolbox/util.c b/src/toolbox/util.c index 548823e1e..a69287905 100644 --- a/src/toolbox/util.c +++ b/src/toolbox/util.c @@ -28,7 +28,7 @@ Changes: - $Id: util.c 5252 2006-08-18 13:07:21Z twisti $ + $Id: util.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -43,8 +43,6 @@ #include "vm/types.h" #include "mm/memory.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" #include "vm/vm.h" diff --git a/src/vm/Makefile.am b/src/vm/Makefile.am index 96c640035..9659f3127 100644 --- a/src/vm/Makefile.am +++ b/src/vm/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 7869 2007-05-05 08:08:49Z pm $ +## $Id: Makefile.am 8288 2007-08-10 15:12:00Z twisti $ ## Process this file with automake to produce Makefile.in @@ -59,6 +59,8 @@ libvm_la_SOURCES = \ initialize.c \ initialize.h \ jit_interface.h \ + primitive.c \ + primitive.h \ properties.c \ properties.h \ resolve.c \ diff --git a/src/vm/builtin.c b/src/vm/builtin.c index 43db6a30b..cb958cc05 100644 --- a/src/vm/builtin.c +++ b/src/vm/builtin.c @@ -28,7 +28,7 @@ calls instead of machine instructions, using the C calling convention. - $Id: builtin.c 8245 2007-07-31 09:55:04Z michi $ + $Id: builtin.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -55,6 +55,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/include/java_lang_String.h" #include "native/include/java_lang_Throwable.h" @@ -68,14 +69,15 @@ #include "vm/exceptions.h" #include "vm/global.h" #include "vm/initialize.h" +#include "vm/primitive.h" #include "vm/stringlocal.h" #include "vm/jit/asmpart.h" #include "vmcore/class.h" +#include "vmcore/linker.h" #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/rt-timing.h" #if defined(ENABLE_VMLOG) @@ -397,7 +399,7 @@ bool builtintable_replace_function(void *iptr_) *******************************************************************************/ -s4 builtin_instanceof(java_objectheader *o, classinfo *class) +s4 builtin_instanceof(java_handle_t *o, classinfo *class) { if (o == NULL) return 0; @@ -414,7 +416,7 @@ s4 builtin_instanceof(java_objectheader *o, classinfo *class) *******************************************************************************/ -s4 builtin_checkcast(java_objectheader *o, classinfo *class) +s4 builtin_checkcast(java_handle_t *o, classinfo *class) { if (o == NULL) return 1; @@ -484,7 +486,7 @@ static s4 builtin_descriptorscompatible(arraydescriptor *desc, *******************************************************************************/ -s4 builtin_arraycheckcast(java_objectheader *o, classinfo *targetclass) +s4 builtin_arraycheckcast(java_handle_t *o, classinfo *targetclass) { arraydescriptor *desc; @@ -500,7 +502,7 @@ s4 builtin_arraycheckcast(java_objectheader *o, classinfo *targetclass) } -s4 builtin_arrayinstanceof(java_objectheader *o, classinfo *targetclass) +s4 builtin_arrayinstanceof(java_handle_t *o, classinfo *targetclass) { if (o == NULL) return 0; @@ -516,10 +518,11 @@ s4 builtin_arrayinstanceof(java_objectheader *o, classinfo *targetclass) *******************************************************************************/ -void *builtin_throw_exception(java_objectheader *xptr) +void *builtin_throw_exception(java_handle_t *xptr) { #if !defined(NDEBUG) java_lang_Throwable *t; + java_lang_String *s; char *logtext; s4 logtextlen; s4 dumpsize; @@ -527,6 +530,10 @@ void *builtin_throw_exception(java_objectheader *xptr) if (opt_verbose) { t = (java_lang_Throwable *) xptr; + /* get detail message */ + if (t) + LLNI_field_get_ref(t, detailMessage, s); + /* calculate message length */ logtextlen = strlen("Builtin exception thrown: ") + strlen("0"); @@ -534,11 +541,11 @@ void *builtin_throw_exception(java_objectheader *xptr) if (t) { logtextlen += utf_bytes(xptr->vftbl->class->name); - if (t->detailMessage) { + if (s) { logtextlen += strlen(": ") + - u2_utflength(t->detailMessage->value->data - + t->detailMessage->offset, - t->detailMessage->count); + u2_utflength(LLNI_field_direct(s, value)->data + + LLNI_field_direct(s, offset), + LLNI_field_direct(s,count)); } } else { @@ -556,10 +563,10 @@ void *builtin_throw_exception(java_objectheader *xptr) if (t) { utf_cat_classname(logtext, xptr->vftbl->class->name); - if (t->detailMessage) { + if (s) { char *buf; - buf = javastring_tochar((java_objectheader *) t->detailMessage); + buf = javastring_tochar((java_handle_t *) s); strcat(logtext, ": "); strcat(logtext, buf); MFREE(buf, char, strlen(buf) + 1); @@ -597,15 +604,15 @@ void *builtin_throw_exception(java_objectheader *xptr) *******************************************************************************/ -s4 builtin_canstore(java_objectarray *oa, java_objectheader *o) +s4 builtin_canstore(java_objectarray *oa, java_handle_t *o) { arraydescriptor *desc; arraydescriptor *valuedesc; vftbl_t *componentvftbl; vftbl_t *valuevftbl; - s4 base; - castinfo classvalues; - s4 result; + int32_t baseval; + uint32_t diffval; + int result; if (o == NULL) return 1; @@ -629,20 +636,22 @@ s4 builtin_canstore(java_objectarray *oa, java_objectheader *o) if (valuevftbl == componentvftbl) return 1; - ASM_GETCLASSVALUES_ATOMIC(componentvftbl, valuevftbl, &classvalues); + LOCK_MONITOR_ENTER(linker_classrenumber_lock); - base = classvalues.super_baseval; + baseval = componentvftbl->baseval; - if (base <= 0) { + if (baseval <= 0) { /* an array of interface references */ - result = ((valuevftbl->interfacetablelength > -base) && - (valuevftbl->interfacetable[base] != NULL)); + result = ((valuevftbl->interfacetablelength > -baseval) && + (valuevftbl->interfacetable[baseval] != NULL)); } else { - result = ((unsigned) (classvalues.sub_baseval - classvalues.super_baseval) - <= (unsigned) classvalues.super_diffval); + diffval = valuevftbl->baseval - componentvftbl->baseval; + result = diffval <= (uint32_t) componentvftbl->diffval; } + + LOCK_MONITOR_EXIT(linker_classrenumber_lock); } else if (valuedesc == NULL) { /* {oa has dimension > 1} */ @@ -670,16 +679,17 @@ s4 builtin_canstore(java_objectarray *oa, java_objectheader *o) /* This is an optimized version where a is guaranteed to be one-dimensional */ -s4 builtin_canstore_onedim (java_objectarray *a, java_objectheader *o) +s4 builtin_canstore_onedim (java_objectarray *a, java_handle_t *o) { arraydescriptor *desc; - vftbl_t *elementvftbl; - vftbl_t *valuevftbl; - s4 res; - int base; - castinfo classvalues; + vftbl_t *elementvftbl; + vftbl_t *valuevftbl; + int32_t baseval; + uint32_t diffval; + int result; - if (!o) return 1; + if (o == NULL) + return 1; /* The following is guaranteed (by verifier checks): * @@ -698,30 +708,37 @@ s4 builtin_canstore_onedim (java_objectarray *a, java_objectheader *o) if (valuevftbl == elementvftbl) return 1; - ASM_GETCLASSVALUES_ATOMIC(elementvftbl, valuevftbl, &classvalues); + LOCK_MONITOR_ENTER(linker_classrenumber_lock); + + baseval = elementvftbl->baseval; - if ((base = classvalues.super_baseval) <= 0) + if (baseval <= 0) { /* an array of interface references */ - return (valuevftbl->interfacetablelength > -base && - valuevftbl->interfacetable[base] != NULL); + result = ((valuevftbl->interfacetablelength > -baseval) && + (valuevftbl->interfacetable[baseval] != NULL)); + } + else { + diffval = valuevftbl->baseval - elementvftbl->baseval; + result = diffval <= (uint32_t) elementvftbl->diffval; + } - res = (unsigned) (classvalues.sub_baseval - classvalues.super_baseval) - <= (unsigned) classvalues.super_diffval; + LOCK_MONITOR_EXIT(linker_classrenumber_lock); - return res; + return result; } /* This is an optimized version where a is guaranteed to be a * one-dimensional array of a class type */ -s4 builtin_canstore_onedim_class(java_objectarray *a, java_objectheader *o) +s4 builtin_canstore_onedim_class(java_objectarray *a, java_handle_t *o) { - vftbl_t *elementvftbl; - vftbl_t *valuevftbl; - s4 res; - castinfo classvalues; + vftbl_t *elementvftbl; + vftbl_t *valuevftbl; + uint32_t diffval; + int result; - if (!o) return 1; + if (o == NULL) + return 1; /* The following is guaranteed (by verifier checks): * @@ -740,12 +757,14 @@ s4 builtin_canstore_onedim_class(java_objectarray *a, java_objectheader *o) if (valuevftbl == elementvftbl) return 1; - ASM_GETCLASSVALUES_ATOMIC(elementvftbl, valuevftbl, &classvalues); + LOCK_MONITOR_ENTER(linker_classrenumber_lock); - res = (unsigned) (classvalues.sub_baseval - classvalues.super_baseval) - <= (unsigned) classvalues.super_diffval; + diffval = valuevftbl->baseval - elementvftbl->baseval; + result = diffval <= (uint32_t) elementvftbl->diffval; - return res; + LOCK_MONITOR_EXIT(linker_classrenumber_lock); + + return result; } @@ -758,9 +777,9 @@ s4 builtin_canstore_onedim_class(java_objectarray *a, java_objectheader *o) *******************************************************************************/ -java_objectheader *builtin_new(classinfo *c) +java_handle_t *builtin_new(classinfo *c) { - java_objectheader *o; + java_object_t *o; #if defined(ENABLE_RT_TIMING) struct timespec time_start, time_end; #endif @@ -1162,7 +1181,7 @@ static java_arrayheader *builtin_multianewarray_intern(int n, if (!ea) return NULL; - ((java_objectarray *) a)->data[i] = (java_objectheader *) ea; + ((java_objectarray *) a)->data[i] = (java_object_t *) ea; } return a; @@ -1216,10 +1235,10 @@ java_arrayheader *builtin_multianewarray(int n, classinfo *arrayclass, static s4 methodindent = 0; static u4 callcount = 0; -java_objectheader *builtin_trace_exception(java_objectheader *xptr, - methodinfo *m, - void *pos, - s4 indent) +java_handle_t *builtin_trace_exception(java_handle_t *xptr, + methodinfo *m, + void *pos, + s4 indent) { char *logtext; s4 logtextlen; @@ -1369,7 +1388,7 @@ static char *builtin_print_argument(char *logtext, s4 *logtextlen, typedesc *paramtype, s8 value) { imm_union imu; - java_objectheader *o; + java_handle_t *o; classinfo *c; utf *u; u4 len; @@ -1417,7 +1436,7 @@ static char *builtin_print_argument(char *logtext, s4 *logtextlen, /* cast to java.lang.Object */ - o = (java_objectheader *) (ptrint) value; + o = (java_handle_t *) (ptrint) value; /* check return argument for java.lang.Class or java.lang.String */ @@ -2663,7 +2682,7 @@ bool builtin_arraycopy(java_arrayheader *src, s4 srcStart, if (destStart <= srcStart) { for (i = 0; i < len; i++) { - java_objectheader *o = oas->data[srcStart + i]; + java_handle_t *o = oas->data[srcStart + i]; if (!builtin_canstore(oad, o)) return false; @@ -2679,7 +2698,7 @@ bool builtin_arraycopy(java_arrayheader *src, s4 srcStart, index have been copied before the throw. */ for (i = len - 1; i >= 0; i--) { - java_objectheader *o = oas->data[srcStart + i]; + java_handle_t *o = oas->data[srcStart + i]; if (!builtin_canstore(oad, o)) return false; @@ -2735,13 +2754,13 @@ s8 builtin_currenttimemillis(void) *******************************************************************************/ -java_objectheader *builtin_clone(void *env, java_objectheader *o) +java_handle_t *builtin_clone(void *env, java_handle_t *o) { arraydescriptor *ad; java_arrayheader *ah; u4 size; classinfo *c; - java_objectheader *co; /* cloned object header */ + java_handle_t *co; /* cloned object header */ /* get the array descriptor */ diff --git a/src/vm/builtin.h b/src/vm/builtin.h index b8adcda68..0b4dc18c9 100644 --- a/src/vm/builtin.h +++ b/src/vm/builtin.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: builtin.h 8056 2007-06-10 14:49:57Z michi $ + $Id: builtin.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -122,24 +122,24 @@ bool builtintable_replace_function(void *iptr); * ICMD_BUILTIN3.) */ -s4 builtin_instanceof(java_objectheader *obj, classinfo *class); +s4 builtin_instanceof(java_handle_t *obj, classinfo *class); #define BUILTIN_instanceof (functionptr) builtin_instanceof -s4 builtin_checkcast(java_objectheader *obj, classinfo *class); +s4 builtin_checkcast(java_handle_t *obj, classinfo *class); /* NOT AN OP */ -s4 builtin_arrayinstanceof(java_objectheader *o, classinfo *targetclass); +s4 builtin_arrayinstanceof(java_handle_t *o, classinfo *targetclass); #define BUILTIN_arrayinstanceof (functionptr) builtin_arrayinstanceof -s4 builtin_arraycheckcast(java_objectheader *o, classinfo *targetclass); +s4 builtin_arraycheckcast(java_handle_t *o, classinfo *targetclass); #define BUILTIN_arraycheckcast (functionptr) builtin_arraycheckcast -void *builtin_throw_exception(java_objectheader *exception); +void *builtin_throw_exception(java_handle_t *exception); /* NOT AN OP */ -java_objectheader *builtin_trace_exception(java_objectheader *xptr, +java_handle_t *builtin_trace_exception(java_handle_t *xptr, methodinfo *m, void *pos, s4 indent); /* NOT AN OP */ -java_objectheader *builtin_new(classinfo *c); +java_handle_t *builtin_new(classinfo *c); #define BUILTIN_new (functionptr) builtin_new java_objectheader *builtin_fast_new(classinfo *c); #define BUILTIN_FAST_new (functionptr) builtin_fast_new @@ -171,7 +171,7 @@ java_arrayheader *builtin_multianewarray(int n, classinfo *arrayclass, long *dims); #define BUILTIN_multianewarray (functionptr) builtin_multianewarray -s4 builtin_canstore(java_objectarray *oa, java_objectheader *o); +s4 builtin_canstore(java_objectarray *oa, java_handle_t *o); #define BUILTIN_canstore (functionptr) builtin_canstore #if defined(TRACE_ARGS_NUM) @@ -297,7 +297,7 @@ s8 asm_builtin_d2l(double a); float builtin_d2f(double a); #define BUILTIN_d2f (functionptr) builtin_d2f -java_objectheader *builtin_clone(void *env, java_objectheader *o); +java_handle_t *builtin_clone(void *env, java_handle_t *o); #define BUILTIN_clone (functionptr) builtin_clone bool builtin_arraycopy(java_arrayheader *src, s4 srcStart, diff --git a/src/vm/exceptions.c b/src/vm/exceptions.c index f1fceffa6..e8e44651e 100644 --- a/src/vm/exceptions.c +++ b/src/vm/exceptions.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: exceptions.c 8244 2007-07-31 09:30:28Z michi $ + $Id: exceptions.c 8296 2007-08-11 22:38:38Z pm $ */ @@ -43,6 +43,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_String.h" @@ -51,7 +52,6 @@ #include "threads/lock-common.h" #include "threads/threads-common.h" -#include "toolbox/logging.h" #include "toolbox/util.h" #include "vm/builtin.h" @@ -61,7 +61,6 @@ #include "vm/vm.h" #include "vm/jit/asmpart.h" -#include "vm/jit/disass.h" #include "vm/jit/jit.h" #include "vm/jit/methodheader.h" #include "vm/jit/patcher-common.h" @@ -80,7 +79,7 @@ /* for raising exceptions from native methods *********************************/ #if !defined(ENABLE_THREADS) -java_objectheader *_no_threads_exceptionptr = NULL; +java_object_t *_no_threads_exceptionptr = NULL; #endif @@ -203,7 +202,7 @@ bool exceptions_init(void) *******************************************************************************/ -java_objectheader *exceptions_get_exception(void) +java_handle_t *exceptions_get_exception(void) { /* return the exception */ @@ -217,7 +216,7 @@ java_objectheader *exceptions_get_exception(void) *******************************************************************************/ -void exceptions_set_exception(java_objectheader *o) +void exceptions_set_exception(java_handle_t *o) { /* set the exception */ @@ -244,9 +243,9 @@ void exceptions_clear_exception(void) *******************************************************************************/ -java_objectheader *exceptions_get_and_clear_exception(void) +java_handle_t *exceptions_get_and_clear_exception(void) { - java_objectheader *o; + java_handle_t *o; /* get the exception */ @@ -271,9 +270,9 @@ java_objectheader *exceptions_get_and_clear_exception(void) *******************************************************************************/ -static java_objectheader *exceptions_new_class(classinfo *c) +static java_handle_t *exceptions_new_class(classinfo *c) { - java_objectheader *o; + java_handle_t *o; o = native_new_and_init(c); @@ -293,10 +292,10 @@ static java_objectheader *exceptions_new_class(classinfo *c) *******************************************************************************/ -static java_objectheader *exceptions_new_utf(utf *classname) +static java_handle_t *exceptions_new_utf(utf *classname) { - classinfo *c; - java_objectheader *o; + classinfo *c; + java_handle_t *o; c = load_class_bootstrap(classname); @@ -321,7 +320,7 @@ static java_objectheader *exceptions_new_utf(utf *classname) static void exceptions_throw_class(classinfo *c) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_class(c); @@ -367,10 +366,10 @@ static void exceptions_throw_utf(utf *classname) *******************************************************************************/ static void exceptions_throw_utf_throwable(utf *classname, - java_objectheader *cause) + java_handle_t *cause) { classinfo *c; - java_objectheader *o; + java_handle_t *o; methodinfo *m; java_lang_Throwable *object; @@ -417,11 +416,11 @@ static void exceptions_throw_utf_throwable(utf *classname, *******************************************************************************/ static void exceptions_throw_utf_exception(utf *classname, - java_objectheader *exception) + java_handle_t *exception) { - classinfo *c; - java_objectheader *o; - methodinfo *m; + classinfo *c; + java_handle_t *o; + methodinfo *m; c = load_class_bootstrap(classname); @@ -463,11 +462,12 @@ static void exceptions_throw_utf_exception(utf *classname, *******************************************************************************/ -static void exceptions_throw_utf_cause(utf *classname, java_objectheader *cause) +static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause) { classinfo *c; - java_objectheader *o; + java_handle_t *o; methodinfo *m; + java_lang_String *s; java_lang_Throwable *object; object = (java_lang_Throwable *) cause; @@ -495,7 +495,9 @@ static void exceptions_throw_utf_cause(utf *classname, java_objectheader *cause) if (m == NULL) return; - (void) vm_call_method(m, o, object->detailMessage); + LLNI_field_get_ref(object, detailMessage, s); + + (void) vm_call_method(m, o, s); /* call initCause */ @@ -529,11 +531,11 @@ static void exceptions_throw_utf_cause(utf *classname, java_objectheader *cause) *******************************************************************************/ -static java_objectheader *exceptions_new_utf_javastring(utf *classname, - java_objectheader *message) +static java_handle_t *exceptions_new_utf_javastring(utf *classname, + java_handle_t *message) { - java_objectheader *o; - classinfo *c; + java_handle_t *o; + classinfo *c; c = load_class_bootstrap(classname); @@ -559,10 +561,10 @@ static java_objectheader *exceptions_new_utf_javastring(utf *classname, *******************************************************************************/ -static java_objectheader *exceptions_new_class_utf(classinfo *c, utf *message) +static java_handle_t *exceptions_new_class_utf(classinfo *c, utf *message) { - java_objectheader *o; - java_objectheader *s; + java_handle_t *o; + java_handle_t *s; s = javastring_new(message); @@ -593,10 +595,10 @@ static java_objectheader *exceptions_new_class_utf(classinfo *c, utf *message) *******************************************************************************/ -static java_objectheader *exceptions_new_utf_utf(utf *classname, utf *message) +static java_handle_t *exceptions_new_utf_utf(utf *classname, utf *message) { - classinfo *c; - java_objectheader *o; + classinfo *c; + java_handle_t *o; c = load_class_bootstrap(classname); @@ -622,7 +624,7 @@ static java_objectheader *exceptions_new_utf_utf(utf *classname, utf *message) static void exceptions_throw_class_utf(classinfo *c, utf *message) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_class_utf(c, message); @@ -643,7 +645,7 @@ static void exceptions_throw_class_utf(classinfo *c, utf *message) static void exceptions_throw_utf_utf(utf *classname, utf *message) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_utf_utf(classname, message); @@ -657,9 +659,9 @@ static void exceptions_throw_utf_utf(utf *classname, utf *message) *******************************************************************************/ -java_objectheader *exceptions_new_abstractmethoderror(void) +java_handle_t *exceptions_new_abstractmethoderror(void) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_utf(utf_java_lang_AbstractMethodError); @@ -674,9 +676,9 @@ java_objectheader *exceptions_new_abstractmethoderror(void) *******************************************************************************/ #if defined(ENABLE_JAVAME_CLDC1_1) -static java_objectheader *exceptions_new_error(utf *message) +static java_handle_t *exceptions_new_error(utf *message) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_class_utf(class_java_lang_Error, message); @@ -692,10 +694,10 @@ static java_objectheader *exceptions_new_error(utf *message) *******************************************************************************/ -java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra) +java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra) { - stackframeinfo sfi; - java_objectheader *e; + stackframeinfo sfi; + java_handle_t *e; /* create the stackframeinfo (XPC is equal to RA) */ @@ -723,9 +725,9 @@ java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra) *******************************************************************************/ -java_objectheader *exceptions_new_arraystoreexception(void) +java_handle_t *exceptions_new_arraystoreexception(void) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_utf(utf_java_lang_ArrayStoreException); @@ -867,7 +869,7 @@ void exceptions_throw_noclassdeffounderror(utf *name) *******************************************************************************/ -void exceptions_throw_noclassdeffounderror_cause(java_objectheader *cause) +void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause) { exceptions_throw_utf_cause(utf_java_lang_NoClassDefFoundError, cause); } @@ -917,7 +919,7 @@ void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name) *******************************************************************************/ -void exceptions_throw_exceptionininitializererror(java_objectheader *cause) +void exceptions_throw_exceptionininitializererror(java_handle_t *cause) { exceptions_throw_utf_throwable(utf_java_lang_ExceptionInInitializerError, cause); @@ -1032,9 +1034,9 @@ void exceptions_throw_internalerror(const char *message, ...) void exceptions_throw_linkageerror(const char *message, classinfo *c) { - java_objectheader *o; - char *msg; - s4 msglen; + java_handle_t *o; + char *msg; + s4 msglen; /* calculate exception message length */ @@ -1383,9 +1385,9 @@ void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type) *******************************************************************************/ -java_objectheader *exceptions_new_arithmeticexception(void) +java_handle_t *exceptions_new_arithmeticexception(void) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_utf_utf(utf_java_lang_ArithmeticException, utf_division_by_zero); @@ -1401,11 +1403,11 @@ java_objectheader *exceptions_new_arithmeticexception(void) *******************************************************************************/ -java_objectheader *exceptions_new_arrayindexoutofboundsexception(s4 index) +java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index) { - java_objectheader *o; - methodinfo *m; - java_objectheader *s; + java_handle_t *o; + methodinfo *m; + java_handle_t *s; /* convert the index into a String, like Sun does */ @@ -1465,10 +1467,10 @@ void exceptions_throw_arraystoreexception(void) *******************************************************************************/ -java_objectheader *exceptions_new_classcastexception(java_objectheader *o) +java_handle_t *exceptions_new_classcastexception(java_handle_t *o) { - java_objectheader *e; - utf *classname; + java_handle_t *e; + utf *classname; classname = o->vftbl->class->name; @@ -1563,7 +1565,7 @@ void exceptions_throw_interruptedexception(void) *******************************************************************************/ -void exceptions_throw_invocationtargetexception(java_objectheader *cause) +void exceptions_throw_invocationtargetexception(java_handle_t *cause) { exceptions_throw_utf_throwable(utf_java_lang_reflect_InvocationTargetException, cause); @@ -1589,9 +1591,9 @@ void exceptions_throw_negativearraysizeexception(void) *******************************************************************************/ -java_objectheader *exceptions_new_nullpointerexception(void) +java_handle_t *exceptions_new_nullpointerexception(void) { - java_objectheader *o; + java_handle_t *o; o = exceptions_new_class(class_java_lang_NullPointerException); @@ -1618,7 +1620,7 @@ void exceptions_throw_nullpointerexception(void) *******************************************************************************/ -void exceptions_throw_privilegedactionexception(java_objectheader *exception) +void exceptions_throw_privilegedactionexception(java_handle_t *exception) { exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException, exception); @@ -1647,10 +1649,10 @@ void exceptions_throw_stringindexoutofboundsexception(void) void exceptions_classnotfoundexception_to_noclassdeffounderror(void) { - java_objectheader *o; - java_objectheader *cause; + java_handle_t *o; + java_handle_t *cause; java_lang_Throwable *object; - java_objectheader *s; + java_lang_String *s; /* get the cause */ @@ -1666,10 +1668,10 @@ void exceptions_classnotfoundexception_to_noclassdeffounderror(void) /* create new error */ object = (java_lang_Throwable *) cause; - s = (java_objectheader *) object->detailMessage; + LLNI_field_get_ref(object, detailMessage, s); o = exceptions_new_utf_javastring(utf_java_lang_NoClassDefFoundError, - s); + (java_handle_t *) s); /* we had an exception while creating the error */ @@ -1690,10 +1692,10 @@ void exceptions_classnotfoundexception_to_noclassdeffounderror(void) *******************************************************************************/ -java_objectheader *exceptions_fillinstacktrace(void) +java_handle_t *exceptions_fillinstacktrace(void) { - java_objectheader *o; - methodinfo *m; + java_handle_t *o; + methodinfo *m; /* get exception */ @@ -1725,85 +1727,6 @@ java_objectheader *exceptions_fillinstacktrace(void) } -/* exceptions_new_hardware_exception ******************************************* - - Creates the correct exception for a hardware-exception thrown and - caught by a signal handler. - -*******************************************************************************/ - -java_objectheader *exceptions_new_hardware_exception(u1 *xpc, s4 type, ptrint val) -{ - java_objectheader *e; - java_objectheader *o; - s4 index; - - switch (type) { - case EXCEPTION_HARDWARE_NULLPOINTER: - e = exceptions_new_nullpointerexception(); - break; - - case EXCEPTION_HARDWARE_ARITHMETIC: - e = exceptions_new_arithmeticexception(); - break; - - case EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS: - index = (s4) val; - e = exceptions_new_arrayindexoutofboundsexception(index); - break; - - case EXCEPTION_HARDWARE_CLASSCAST: - o = (java_objectheader *) val; - e = exceptions_new_classcastexception(o); - break; - - case EXCEPTION_HARDWARE_EXCEPTION: - e = exceptions_fillinstacktrace(); - break; - - case EXCEPTION_HARDWARE_PATCHER: -#if defined(ENABLE_REPLACEMENT) - if (replace_me_wrapper(xpc)) { - e = NULL; - break; - } -#endif - e = patcher_handler(xpc); - break; - - default: - /* let's try to get a backtrace */ - - codegen_get_pv_from_pc(xpc); - - /* if that does not work, print more debug info */ - - log_println("exceptions_new_hardware_exception: unknown exception type %d", type); - -#if SIZEOF_VOID_P == 8 - log_println("PC=0x%016lx", xpc); -#else - log_println("PC=0x%08x", xpc); -#endif - -#if defined(ENABLE_DISASSEMBLER) - log_println("machine instruction at PC:"); - disassinstr(xpc); -#endif - - vm_abort("Exiting..."); - - /* keep compiler happy */ - - e = NULL; - } - - /* return the exception object */ - - return e; -} - - /* exceptions_handle_exception ************************************************* Try to find an exception handler for the given exception and return it. @@ -1823,7 +1746,7 @@ java_objectheader *exceptions_new_hardware_exception(u1 *xpc, s4 type, ptrint va *******************************************************************************/ #if defined(ENABLE_JIT) -u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp) +u1 *exceptions_handle_exception(java_object_t *xptr, u1 *xpc, u1 *pv, u1 *sp) { methodinfo *m; codeinfo *code; @@ -1834,7 +1757,7 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp classref_or_classinfo cr; classinfo *c; #if defined(ENABLE_THREADS) - java_objectheader *o; + java_object_t *o; #endif #ifdef __S390__ @@ -1975,12 +1898,12 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp if (issync) { /* get synchronization object */ -# if (defined(__MIPS__) && (SIZEOF_VOID_P == 4)) || defined(__I386__) +# if (defined(__MIPS__) && (SIZEOF_VOID_P == 4)) || defined(__I386__) || defined(__S390__) || defined(__POWERPC__) /* XXX change this if we ever want to use 4-byte stackslots */ - o = *((java_objectheader **) (sp + issync - 8)); + o = *((java_object_t **) (sp + issync - 8)); # else - o = *((java_objectheader **) (sp + issync - SIZEOF_VOID_P)); -#endif + o = *((java_object_t **) (sp + issync - SIZEOF_VOID_P)); +# endif assert(o != NULL); @@ -2006,12 +1929,14 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp *******************************************************************************/ -void exceptions_print_exception(java_objectheader *xptr) +void exceptions_print_exception(java_handle_t *xptr) { java_lang_Throwable *t; #if defined(ENABLE_JAVASE) java_lang_Throwable *cause; #endif + java_lang_String *s; + classinfo *c; utf *u; t = (java_lang_Throwable *) xptr; @@ -2022,15 +1947,18 @@ void exceptions_print_exception(java_objectheader *xptr) } #if defined(ENABLE_JAVASE) - cause = t->cause; + LLNI_field_set_ref(t, cause, cause); #endif /* print the root exception */ - utf_display_printable_ascii_classname(t->header.vftbl->class->name); + LLNI_class_get(t, c); + utf_display_printable_ascii_classname(c->name); - if (t->detailMessage != NULL) { - u = javastring_toutf((java_objectheader *) t->detailMessage, false); + LLNI_field_get_ref(t, detailMessage, s); + + if (s != NULL) { + u = javastring_toutf((java_handle_t *) s, false); printf(": "); utf_display_printable_ascii(u); @@ -2043,11 +1971,14 @@ void exceptions_print_exception(java_objectheader *xptr) if ((cause != NULL) && (cause != t)) { printf("Caused by: "); - utf_display_printable_ascii_classname(cause->header.vftbl->class->name); + + LLNI_class_get(cause, c); + utf_display_printable_ascii_classname(c->name); - if (cause->detailMessage != NULL) { - u = javastring_toutf((java_objectheader *) cause->detailMessage, - false); + LLNI_field_get_ref(cause, detailMessage, s); + + if (s != NULL) { + u = javastring_toutf((java_handle_t *) s, false); printf(": "); utf_display_printable_ascii(u); @@ -2068,7 +1999,7 @@ void exceptions_print_exception(java_objectheader *xptr) void exceptions_print_current_exception(void) { - java_objectheader *o; + java_handle_t *o; o = exceptions_get_exception(); @@ -2088,10 +2019,10 @@ void exceptions_print_current_exception(void) void exceptions_print_stacktrace(void) { - java_objectheader *oxptr; - java_objectheader *xptr; - classinfo *c; - methodinfo *m; + java_handle_t *oxptr; + java_handle_t *xptr; + classinfo *c; + methodinfo *m; /* get original exception */ diff --git a/src/vm/exceptions.h b/src/vm/exceptions.h index 803e5a11a..627169e7d 100644 --- a/src/vm/exceptions.h +++ b/src/vm/exceptions.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: exceptions.h 8243 2007-07-31 08:57:54Z michi $ + $Id: exceptions.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -54,7 +54,7 @@ a base of NULL which should result in a NullPointerException. NOTE: In exceptions_init() we have a check whether the offset of - java_objectheader.data[0] is greater than the largest displacement + java_arrayheader.data[0] is greater than the largest displacement defined below. Otherwise normal array loads/stores could trigger an exception. @@ -74,34 +74,34 @@ /* function prototypes ********************************************************/ -bool exceptions_init(void); +bool exceptions_init(void); -java_objectheader *exceptions_get_exception(void); -void exceptions_set_exception(java_objectheader *o); -void exceptions_clear_exception(void); -java_objectheader *exceptions_get_and_clear_exception(void); +java_handle_t *exceptions_get_exception(void); +void exceptions_set_exception(java_handle_t *o); +void exceptions_clear_exception(void); +java_handle_t *exceptions_get_and_clear_exception(void); -java_objectheader *new_exception_utfmessage(const char *classname, +java_handle_t *new_exception_utfmessage(const char *classname, utf *message); /* functions to generate compiler exceptions */ -java_objectheader *exceptions_new_abstractmethoderror(void); -java_objectheader *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra); -java_objectheader *exceptions_new_arraystoreexception(void); +java_handle_t *exceptions_new_abstractmethoderror(void); +java_handle_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra); +java_handle_t *exceptions_new_arraystoreexception(void); void exceptions_throw_abstractmethoderror(void); void exceptions_throw_classcircularityerror(classinfo *c); void exceptions_throw_classformaterror(classinfo *c, const char *message, ...); void exceptions_throw_classnotfoundexception(utf *name); void exceptions_throw_noclassdeffounderror(utf *name); -void exceptions_throw_noclassdeffounderror_cause(java_objectheader *cause); +void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause); void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name); void exceptions_throw_linkageerror(const char *message, classinfo *c); void exceptions_throw_nosuchfielderror(classinfo *c, utf *name); void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc); -void exceptions_throw_exceptionininitializererror(java_objectheader *cause); +void exceptions_throw_exceptionininitializererror(java_handle_t *cause); void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message); void exceptions_throw_instantiationerror(classinfo *c); @@ -112,13 +112,13 @@ void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type); void exceptions_throw_unsatisfiedlinkerror(utf *name); void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi); -java_objectheader *exceptions_new_arithmeticexception(void); +java_handle_t *exceptions_new_arithmeticexception(void); -java_objectheader *exceptions_new_arrayindexoutofboundsexception(s4 index); +java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index); void exceptions_throw_arrayindexoutofboundsexception(void); void exceptions_throw_arraystoreexception(void); -java_objectheader *exceptions_new_classcastexception(java_objectheader *o); +java_handle_t *exceptions_new_classcastexception(java_handle_t *o); void exceptions_throw_clonenotsupportedexception(void); void exceptions_throw_illegalaccessexception(utf *message); @@ -126,21 +126,19 @@ void exceptions_throw_illegalargumentexception(void); void exceptions_throw_illegalmonitorstateexception(void); void exceptions_throw_interruptedexception(void); void exceptions_throw_instantiationexception(classinfo *c); -void exceptions_throw_invocationtargetexception(java_objectheader *cause); +void exceptions_throw_invocationtargetexception(java_handle_t *cause); void exceptions_throw_negativearraysizeexception(void); -java_objectheader *exceptions_new_nullpointerexception(void); +java_handle_t *exceptions_new_nullpointerexception(void); void exceptions_throw_nullpointerexception(void); -void exceptions_throw_privilegedactionexception(java_objectheader *cause); +void exceptions_throw_privilegedactionexception(java_handle_t *cause); void exceptions_throw_stringindexoutofboundsexception(void); void exceptions_classnotfoundexception_to_noclassdeffounderror(void); -java_objectheader *exceptions_fillinstacktrace(void); +java_handle_t *exceptions_fillinstacktrace(void); -java_objectheader *exceptions_new_hardware_exception(u1 *xpc, s4 type, ptrint val); - -void exceptions_print_exception(java_objectheader *xptr); +void exceptions_print_exception(java_handle_t *xptr); void exceptions_print_current_exception(void); void exceptions_print_stacktrace(void); diff --git a/src/vm/finalizer.c b/src/vm/finalizer.c index 4c77e4af2..d265cfae0 100644 --- a/src/vm/finalizer.c +++ b/src/vm/finalizer.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: finalizer.c 7831 2007-04-26 12:48:16Z twisti $ + $Id: finalizer.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -52,7 +52,7 @@ /* global variables ***********************************************************/ #if defined(ENABLE_THREADS) -static java_objectheader *lock_thread_finalizer; +static java_object_t *lock_thread_finalizer; #endif @@ -65,7 +65,7 @@ static java_objectheader *lock_thread_finalizer; bool finalizer_init(void) { #if defined(ENABLE_THREADS) - lock_thread_finalizer = NEW(java_objectheader); + lock_thread_finalizer = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer); #endif @@ -168,9 +168,9 @@ void finalizer_notify(void) void finalizer_run(void *o, void *p) { - java_objectheader *ob; + java_object_t *ob; - ob = (java_objectheader *) o; + ob = (java_object_t *) o; /* call the finalizer function */ diff --git a/src/vm/global.h b/src/vm/global.h index 94e04cf3f..07963d38f 100644 --- a/src/vm/global.h +++ b/src/vm/global.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: global.h 8245 2007-07-31 09:55:04Z michi $ + $Id: global.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -81,7 +81,7 @@ typedef union { /* forward typedefs ***********************************************************/ -typedef struct java_objectheader java_objectheader; +typedef struct java_object_t java_object_t; typedef struct java_objectarray java_objectarray; @@ -196,7 +196,7 @@ typedef struct java_objectarray java_objectarray; /* data structures of the runtime system **************************************/ -/* java_objectheader *********************************************************** +/* java_object_t *************************************************************** All objects (and arrays) which resides on the heap need the following header at the beginning of the data structure. @@ -213,7 +213,7 @@ typedef struct java_objectarray java_objectarray; #define HDRFLAG_HASH_ATTACHED 0x20 #define HDRFLAG_REFERENCING 0x40 -struct java_objectheader { /* header for all objects */ +struct java_object_t { /* header for all objects */ struct _vftbl *vftbl; /* pointer to virtual function table */ #if defined(ENABLE_THREADS) struct lock_record_t *monitorPtr; @@ -224,6 +224,15 @@ struct java_objectheader { /* header for all objects */ }; +#if 0 +typedef struct java_handle_t { + java_object_t *heap_object; +} java_handle_t; +#else +typedef java_object_t java_handle_t; +#endif + + /* arrays ********************************************************************** All arrays are objects (they need the object header with a pointer @@ -233,7 +242,7 @@ struct java_objectheader { /* header for all objects */ */ typedef struct java_arrayheader { /* header for all arrays */ - java_objectheader objheader; /* object header */ + java_object_t objheader; /* object header */ s4 size; /* array size */ } java_arrayheader; @@ -288,8 +297,8 @@ typedef struct java_doublearray { use the same machine code */ struct java_objectarray { - java_arrayheader header; - java_objectheader *data[1]; + java_arrayheader header; + java_object_t *data[1]; }; diff --git a/src/vm/initialize.c b/src/vm/initialize.c index 9619b9656..e7b9df436 100644 --- a/src/vm/initialize.c +++ b/src/vm/initialize.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: initialize.c 7813 2007-04-25 19:20:13Z twisti $ + $Id: initialize.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -130,8 +130,8 @@ bool initialize_class(classinfo *c) static bool initialize_class_intern(classinfo *c) { - methodinfo *m; - java_objectheader *xptr; + methodinfo *m; + java_handle_t *xptr; /* maybe the class is not already linked */ diff --git a/src/vm/jit/Makefile.am b/src/vm/jit/Makefile.am index bd8275b91..65b45aa90 100644 --- a/src/vm/jit/Makefile.am +++ b/src/vm/jit/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 8145 2007-06-27 08:54:10Z michi $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -36,7 +36,6 @@ DIST_SUBDIRS = \ loop \ optimizing \ schedule \ - tools \ verify \ \ intrp \ @@ -54,7 +53,6 @@ DIST_SUBDIRS = \ SUBDIRS = \ optimizing \ - tools \ $(ARCH_DIR) ARCH_LIB = \ diff --git a/src/vm/jit/alpha/Makefile.am b/src/vm/jit/alpha/Makefile.am index 7e4a6db83..ae5f78ef3 100644 --- a/src/vm/jit/alpha/Makefile.am +++ b/src/vm/jit/alpha/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/alpha/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: -## -## $Id: Makefile.am 4826 2006-04-24 16:06:16Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -43,10 +37,6 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h \ @@ -76,10 +66,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/alpha/arch.h b/src/vm/jit/alpha/arch.h index ae3ea3714..3706b4cec 100644 --- a/src/vm/jit/alpha/arch.h +++ b/src/vm/jit/alpha/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $ + $Id: arch.h 8247 2007-07-31 12:06:44Z michi $ */ @@ -106,7 +106,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 4 /* bytes */ -#define REPLACEMENT_STUB_SIZE 5 /* words */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/alpha/asmpart.S b/src/vm/jit/alpha/asmpart.S index 9a35eefbc..8e9f02b20 100644 --- a/src/vm/jit/alpha/asmpart.S +++ b/src/vm/jit/alpha/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8198 2007-07-12 07:16:24Z twisti $ + $Id: asmpart.S 8279 2007-08-09 09:36:57Z michi $ */ @@ -31,7 +31,6 @@ #include "vm/jit/alpha/md-abi.h" #include "vm/jit/alpha/md-asm.h" -#include "vm/jit/alpha/offsets.h" #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" @@ -59,17 +58,9 @@ .globl asm_abstractmethoderror -#if defined(ENABLE_REPLACEMENT) - .globl asm_replacement_out - .globl asm_replacement_in -#endif - .globl asm_compare_and_swap .globl asm_memory_barrier - .globl asm_criticalsections - .globl asm_getclassvalues_atomic - .globl asm_md_init .globl asm_cacheflush @@ -410,251 +401,6 @@ asm_abstractmethoderror: .end asm_abstractmethoderror -#if defined(ENABLE_REPLACEMENT) - -/* asm_replacement_out ********************************************************* - - This code is jumped to from the replacement-out stubs that are executed - when a thread reaches an activated replacement point. - - The purpose of asm_replacement_out is to read out the parts of the - execution state that cannot be accessed from C code, store this state, - and then call the C function replace_me. - - Stack layout: - 16 start of stack inside method to replace - 0 rplpoint * info on the replacement point that was reached - - NOTE: itmp3 has been clobbered by the replacement-out stub! - -*******************************************************************************/ - -/* some room to accomodate changes of the stack frame size during replacement */ - /* XXX we should find a cleaner solution here */ -#define REPLACEMENT_ROOM 512 - -#define REPLACEMENT_STACK_OFFSET ((sizeexecutionstate + REPLACEMENT_ROOM + 0xf) & ~0xf) - - .ent asm_replacement_out - -asm_replacement_out: - /* create stack frame */ - lda sp,-(REPLACEMENT_STACK_OFFSET)(sp) - - /* save registers in execution state */ - stq $0 ,( 0*8+offes_intregs)(sp) - stq $1 ,( 1*8+offes_intregs)(sp) - stq $2 ,( 2*8+offes_intregs)(sp) - stq $3 ,( 3*8+offes_intregs)(sp) - stq $4 ,( 4*8+offes_intregs)(sp) - stq $5 ,( 5*8+offes_intregs)(sp) - stq $6 ,( 6*8+offes_intregs)(sp) - stq $7 ,( 7*8+offes_intregs)(sp) - stq $8 ,( 8*8+offes_intregs)(sp) - stq $9 ,( 9*8+offes_intregs)(sp) - stq $10,(10*8+offes_intregs)(sp) - stq $11,(11*8+offes_intregs)(sp) - stq $12,(12*8+offes_intregs)(sp) - stq $13,(13*8+offes_intregs)(sp) - stq $14,(14*8+offes_intregs)(sp) - stq $15,(15*8+offes_intregs)(sp) - stq $16,(16*8+offes_intregs)(sp) - stq $17,(17*8+offes_intregs)(sp) - stq $18,(18*8+offes_intregs)(sp) - stq $19,(19*8+offes_intregs)(sp) - stq $20,(20*8+offes_intregs)(sp) - stq $21,(21*8+offes_intregs)(sp) - stq $22,(22*8+offes_intregs)(sp) - stq $23,(23*8+offes_intregs)(sp) - stq $24,(24*8+offes_intregs)(sp) - stq $25,(25*8+offes_intregs)(sp) - stq $26,(26*8+offes_intregs)(sp) - stq $27,(27*8+offes_intregs)(sp) - stq $28,(28*8+offes_intregs)(sp) - stq $29,(29*8+offes_intregs)(sp) - stq $30,(30*8+offes_intregs)(sp) - stq $31,(31*8+offes_intregs)(sp) - - stt $f0 ,( 0*8+offes_fltregs)(sp) - stt $f1 ,( 1*8+offes_fltregs)(sp) - stt $f2 ,( 2*8+offes_fltregs)(sp) - stt $f3 ,( 3*8+offes_fltregs)(sp) - stt $f4 ,( 4*8+offes_fltregs)(sp) - stt $f5 ,( 5*8+offes_fltregs)(sp) - stt $f6 ,( 6*8+offes_fltregs)(sp) - stt $f7 ,( 7*8+offes_fltregs)(sp) - stt $f8 ,( 8*8+offes_fltregs)(sp) - stt $f9 ,( 9*8+offes_fltregs)(sp) - stt $f10,(10*8+offes_fltregs)(sp) - stt $f11,(11*8+offes_fltregs)(sp) - stt $f12,(12*8+offes_fltregs)(sp) - stt $f13,(13*8+offes_fltregs)(sp) - stt $f14,(14*8+offes_fltregs)(sp) - stt $f15,(15*8+offes_fltregs)(sp) - stt $f16,(16*8+offes_fltregs)(sp) - stt $f17,(17*8+offes_fltregs)(sp) - stt $f18,(18*8+offes_fltregs)(sp) - stt $f19,(19*8+offes_fltregs)(sp) - stt $f20,(20*8+offes_fltregs)(sp) - stt $f21,(21*8+offes_fltregs)(sp) - stt $f22,(22*8+offes_fltregs)(sp) - stt $f23,(23*8+offes_fltregs)(sp) - stt $f24,(24*8+offes_fltregs)(sp) - stt $f25,(25*8+offes_fltregs)(sp) - stt $f26,(26*8+offes_fltregs)(sp) - stt $f27,(27*8+offes_fltregs)(sp) - stt $f28,(28*8+offes_fltregs)(sp) - stt $f29,(29*8+offes_fltregs)(sp) - stt $f30,(30*8+offes_fltregs)(sp) - stt $f31,(31*8+offes_fltregs)(sp) - - /* calculate sp of method */ - lda itmp1,(REPLACEMENT_STACK_OFFSET + 2*8)(sp) - stq itmp1,(offes_sp)(sp) - - br ra,L_asm_replacement_out_load_gp -L_asm_replacement_out_load_gp: - ldgp gp,0(ra) /* load gp */ - - /* store pv */ - stq pv,(offes_pv)(sp) - - /* call replace_me */ - ldq a0,-(2*8)(itmp1) /* arg0: rplpoint * */ - mov sp,a1 /* arg1: execution state */ - jmp zero,replace_me /* call C function replace_me */ - jmp zero,abort /* NEVER REACHED */ - - .end asm_replacement_out - -/* asm_replacement_in ********************************************************** - - This code writes the given execution state and jumps to the replacement - code. - - This function never returns! - - NOTE: itmp3 is not restored! - - C prototype: - void asm_replacement_in(executionstate *es, replace_safestack_t *st); - -*******************************************************************************/ - - .ent asm_replacement_in - -asm_replacement_in: - /* a0 == executionstate *es */ - - /* get arguments */ - mov a1,s1 /* replace_safestack_t *st */ - mov a0,s2 /* executionstate *es == safe stack */ - - /* switch to the safe stack */ - mov s2,sp - - /* call replace_build_execution_state(st) */ - mov s1,a0 - jsr ra,replace_build_execution_state - - /* set new sp */ - ldq sp,(offes_sp)(s2) - - /* build stack frame */ - lda sp,(-sizeexecutionstate)(sp) - - /* call replace_free_safestack(st,& of allocated executionstate_t) */ - mov sp,a1 /* tmpes */ - mov s1,a0 /* st */ - jsr ra,replace_free_safestack - - /* set new pv */ - ldq pv,(offes_pv)(sp) - - /* copy registers from execution state */ - ldq $0 ,( 0*8+offes_intregs)(sp) - ldq $1 ,( 1*8+offes_intregs)(sp) - ldq $2 ,( 2*8+offes_intregs)(sp) - ldq $3 ,( 3*8+offes_intregs)(sp) - ldq $4 ,( 4*8+offes_intregs)(sp) - ldq $5 ,( 5*8+offes_intregs)(sp) - ldq $6 ,( 6*8+offes_intregs)(sp) - ldq $7 ,( 7*8+offes_intregs)(sp) - ldq $8 ,( 8*8+offes_intregs)(sp) - ldq $9 ,( 9*8+offes_intregs)(sp) - ldq $10,(10*8+offes_intregs)(sp) - ldq $11,(11*8+offes_intregs)(sp) - ldq $12,(12*8+offes_intregs)(sp) - ldq $13,(13*8+offes_intregs)(sp) - ldq $14,(14*8+offes_intregs)(sp) - ldq $15,(15*8+offes_intregs)(sp) - ldq a0, (16*8+offes_intregs)(sp) - ldq $17,(17*8+offes_intregs)(sp) - ldq $18,(18*8+offes_intregs)(sp) - ldq $19,(19*8+offes_intregs)(sp) - ldq $20,(20*8+offes_intregs)(sp) - ldq $21,(21*8+offes_intregs)(sp) - ldq $22,(22*8+offes_intregs)(sp) - ldq $23,(23*8+offes_intregs)(sp) - ldq $24,(24*8+offes_intregs)(sp) - ldq $25,(25*8+offes_intregs)(sp) - ldq $26,(26*8+offes_intregs)(sp) - /* $27 is pv */ - ldq $28,(28*8+offes_intregs)(sp) - ldq $29,(29*8+offes_intregs)(sp) - /* $30 is sp */ - /* $31 is zero */ - - ldt $f0 ,( 0*8+offes_fltregs)(sp) - ldt $f1 ,( 1*8+offes_fltregs)(sp) - ldt $f2 ,( 2*8+offes_fltregs)(sp) - ldt $f3 ,( 3*8+offes_fltregs)(sp) - ldt $f4 ,( 4*8+offes_fltregs)(sp) - ldt $f5 ,( 5*8+offes_fltregs)(sp) - ldt $f6 ,( 6*8+offes_fltregs)(sp) - ldt $f7 ,( 7*8+offes_fltregs)(sp) - ldt $f8 ,( 8*8+offes_fltregs)(sp) - ldt $f9 ,( 9*8+offes_fltregs)(sp) - ldt $f10,(10*8+offes_fltregs)(sp) - ldt $f11,(11*8+offes_fltregs)(sp) - ldt $f12,(12*8+offes_fltregs)(sp) - ldt $f13,(13*8+offes_fltregs)(sp) - ldt $f14,(14*8+offes_fltregs)(sp) - ldt $f15,(15*8+offes_fltregs)(sp) - ldt $f16,(16*8+offes_fltregs)(sp) - ldt $f17,(17*8+offes_fltregs)(sp) - ldt $f18,(18*8+offes_fltregs)(sp) - ldt $f19,(19*8+offes_fltregs)(sp) - ldt $f20,(20*8+offes_fltregs)(sp) - ldt $f21,(21*8+offes_fltregs)(sp) - ldt $f22,(22*8+offes_fltregs)(sp) - ldt $f23,(23*8+offes_fltregs)(sp) - ldt $f24,(24*8+offes_fltregs)(sp) - ldt $f25,(25*8+offes_fltregs)(sp) - ldt $f26,(26*8+offes_fltregs)(sp) - ldt $f27,(27*8+offes_fltregs)(sp) - ldt $f28,(28*8+offes_fltregs)(sp) - ldt $f29,(29*8+offes_fltregs)(sp) - ldt $f30,(30*8+offes_fltregs)(sp) - ldt $f31,(31*8+offes_fltregs)(sp) - - /* load new pc */ - - ldq itmp3,offes_pc(sp) - - /* remove stack frame */ - - lda sp,(sizeexecutionstate)(sp) - - /* jump to new code */ - - jmp zero,(itmp3) - - .end asm_replacement_in - -#endif /* defined(ENABLE_REPLACEMENT) */ - - /* asm_compare_and_swap ******************************************************** Does an atomic compare and swap. Required for the lock @@ -701,34 +447,6 @@ asm_memory_barrier: .end asm_memory_barrier - .ent asm_getclassvalues_atomic - -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: - ldl t0,offbaseval(a0) - ldl t1,offdiffval(a0) - ldl t2,offbaseval(a1) -_crit_end: - stl t0,offcast_super_baseval(a2) - stl t1,offcast_super_diffval(a2) - stl t2,offcast_sub_baseval(a2) - jmp zero,(ra) - - .end asm_getclassvalues_atomic - - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .quad _crit_begin - .quad _crit_end - .quad _crit_restart -#endif - .quad 0 - - /* asm_md_init ***************************************************************** Initialize machine dependent stuff. diff --git a/src/vm/jit/alpha/codegen.c b/src/vm/jit/alpha/codegen.c index f0c42559a..fa54d8e8f 100644 --- a/src/vm/jit/alpha/codegen.c +++ b/src/vm/jit/alpha/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $ + $Id: codegen.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -43,6 +43,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -1800,7 +1801,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class, @@ -1845,7 +1846,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class, @@ -1891,7 +1892,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class, @@ -2654,7 +2655,7 @@ gen_method: sizeof(methodptr) * lm->vftblindex; /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); /* generate the actual call */ @@ -2680,7 +2681,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV, REG_METHODPTR, s2); @@ -2763,7 +2764,7 @@ gen_method: else emit_label_beqz(cd, BRANCH_LABEL_3, s1); - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_LDA(REG_ITMP3, REG_ITMP3, -superindex); @@ -2799,7 +2800,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_5, s1); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; @@ -2936,7 +2937,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_3, s1); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); M_LDA(REG_ITMP3, REG_ITMP3, -superindex); M_BLEZ(REG_ITMP3, 2); @@ -2970,7 +2971,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_5, s1); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; diff --git a/src/vm/jit/alpha/emit.c b/src/vm/jit/alpha/emit.c index 6a9dabd3d..044a01bd1 100644 --- a/src/vm/jit/alpha/emit.c +++ b/src/vm/jit/alpha/emit.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 8211 2007-07-18 19:52:23Z michi $ + $Id: emit.c 8260 2007-08-06 12:19:01Z michi $ */ @@ -31,6 +31,7 @@ #include "vm/types.h" #include +#include #include "md-abi.h" @@ -408,45 +409,26 @@ void emit_exception_check(codegendata *cd, instruction *iptr) } -/* emit_patcher_traps ********************************************************** +/* emit_trap ******************************************************************* - Generates the code for the patcher traps. + Emit a trap instruction and return the original machine code. *******************************************************************************/ -void emit_patcher_traps(jitdata *jd) +uint32_t emit_trap(codegendata *cd) { - codegendata *cd; - codeinfo *code; - patchref_t *pr; - u1 *savedmcodeptr; - u1 *tmpmcodeptr; - - /* get required compiler data */ - - cd = jd->cd; - code = jd->code; - - /* generate patcher traps code */ + uint32_t mcode; - for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) { + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ - /* Get machine code which is patched back in later. The - trap is 1 instruction word long. */ + mcode = *((u4 *) cd->mcodeptr); - tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc); - pr->mcode = *((u4 *) tmpmcodeptr); + /* Destination register must not be REG_ZERO, because then no + SIGSEGV is thrown. */ + M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); - /* Patch in the trap to call the signal handler (done at - compile time). */ - - savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ - cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ - - M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); - - cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ - } + return mcode; } diff --git a/src/vm/jit/alpha/linux/md-os.c b/src/vm/jit/alpha/linux/md-os.c index f26293d2f..807843b8e 100644 --- a/src/vm/jit/alpha/linux/md-os.c +++ b/src/vm/jit/alpha/linux/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $ + $Id: md-os.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -41,7 +42,6 @@ # include "threads/native/threads.h" #endif -#include "vm/exceptions.h" #include "vm/signallocal.h" #include "vm/jit/asmpart.h" @@ -57,21 +57,21 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 d; - s4 s1; - s4 disp; - ptrint val; - ptrint addr; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + s4 d; + s4 s1; + s4 disp; + intptr_t val; + intptr_t addr; + int type; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -89,7 +89,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) s1 = M_MEM_GET_B(mcode); disp = M_MEM_GET_DISP(mcode); - val = _mc->sc_regs[d]; + val = _mc->sc_regs[d]; /* check for special-load */ @@ -103,16 +103,16 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) define is 0. */ addr = _mc->sc_regs[s1]; - type = (s4) addr; + type = (int) addr; } /* create stackframeinfo */ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -120,10 +120,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - if (e != NULL) { - _mc->sc_regs[REG_ITMP1_XPTR] = (ptrint) e; - _mc->sc_regs[REG_ITMP2_XPC] = (ptrint) xpc; - _mc->sc_pc = (ptrint) asm_handle_exception; + if (p != NULL) { + _mc->sc_regs[REG_ITMP1_XPTR] = (intptr_t) p; + _mc->sc_regs[REG_ITMP2_XPC] = (intptr_t) xpc; + _mc->sc_pc = (intptr_t) asm_handle_exception; } } @@ -181,6 +181,70 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) #endif +/* md_replace_executionstate_read ********************************************** + + Read the given context into an executionstate for Replacement. + +*******************************************************************************/ + +#if defined(ENABLE_REPLACEMENT) +void md_replace_executionstate_read(executionstate_t *es, void *context) +{ + ucontext_t *_uc; + mcontext_t *_mc; + s4 i; + + _uc = (ucontext_t *) context; + _mc = &_uc->uc_mcontext; + + /* read special registers */ + es->pc = (u1 *) _mc->sc_pc; + es->sp = (u1 *) _mc->sc_regs[REG_SP]; + es->pv = (u1 *) _mc->sc_regs[REG_PV]; + + /* read integer registers */ + for (i = 0; i < INT_REG_CNT; i++) + es->intregs[i] = _mc->sc_regs[i]; + + /* read float registers */ + for (i = 0; i < FLT_REG_CNT; i++) + es->fltregs[i] = _mc->sc_fpregs[i]; +} +#endif + + +/* md_replace_executionstate_write ********************************************* + + Write the given executionstate back to the context for Replacement. + +*******************************************************************************/ + +#if defined(ENABLE_REPLACEMENT) +void md_replace_executionstate_write(executionstate_t *es, void *context) +{ + ucontext_t *_uc; + mcontext_t *_mc; + s4 i; + + _uc = (ucontext_t *) context; + _mc = &_uc->uc_mcontext; + + /* write integer registers */ + for (i = 0; i < INT_REG_CNT; i++) + _mc->sc_regs[i] = es->intregs[i]; + + /* write float registers */ + for (i = 0; i < FLT_REG_CNT; i++) + _mc->sc_fpregs[i] = es->fltregs[i]; + + /* write special registers */ + _mc->sc_pc = es->pc; + _mc->sc_regs[REG_SP] = (ptrint) es->sp; + _mc->sc_regs[REG_PV] = (ptrint) es->pv; +} +#endif + + /* md_critical_section_restart ************************************************* Search the critical sections tree for a matching section and set diff --git a/src/vm/jit/alpha/md.c b/src/vm/jit/alpha/md.c index 1aef1bad1..5de83eecf 100644 --- a/src/vm/jit/alpha/md.c +++ b/src/vm/jit/alpha/md.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md.c 7596 2007-03-28 21:05:53Z twisti $ + $Id: md.c 8247 2007-07-31 12:06:44Z michi $ */ @@ -288,7 +288,6 @@ void md_icacheflush(u1 *addr, s4 nbytes) #if defined(ENABLE_REPLACEMENT) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; u4 mcode; if (index < 0) { @@ -300,12 +299,7 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save *(u4*)(savedmcode) = *(u4*)(rp->pc); /* build the machine code for the patch */ - disp = ((u4*)code->replacementstubs - (u4*)rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 1; - - /* BR */ - mcode = (((s4) (0x30)) << 26) | ((REG_ZERO) << 21) | ((disp) & 0x1fffff); + mcode = (0xa41f0000 | (EXCEPTION_HARDWARE_PATCHER)); /* write the new machine code */ *(u4*)(rp->pc) = mcode; diff --git a/src/vm/jit/alpha/patcher.c b/src/vm/jit/alpha/patcher.c index bf35d8cb3..e9280929e 100644 --- a/src/vm/jit/alpha/patcher.c +++ b/src/vm/jit/alpha/patcher.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 8186 2007-07-05 23:48:16Z michi $ + $Id: patcher.c 8268 2007-08-07 13:24:43Z twisti $ */ @@ -304,7 +304,7 @@ bool patcher_get_putstatic(patchref_t *pr) /* patch the field value's address */ - *((ptrint *) datap) = (ptrint) &(fi->value); + *((intptr_t *) datap) = (intptr_t) fi->value; return true; } diff --git a/src/vm/jit/arm/Makefile.am b/src/vm/jit/arm/Makefile.am index 9a1cfb496..f5fc9a53d 100644 --- a/src/vm/jit/arm/Makefile.am +++ b/src/vm/jit/arm/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/arm/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: Michael Starzinger -## -## $Id: Makefile.am 6527 2006-05-09 17:55:18Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -40,10 +34,6 @@ SUBDIRS = $(OS_DIR) AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir) -I$(top_builddir)/src AM_CCASFLAGS = $(AM_CPPFLAGS) -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h \ @@ -70,10 +60,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/arm/arch.h b/src/vm/jit/arm/arch.h index 8e1d70d1f..5b0485006 100644 --- a/src/vm/jit/arm/arch.h +++ b/src/vm/jit/arm/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 8127 2007-06-21 11:55:56Z michi $ + $Id: arch.h 8247 2007-07-31 12:06:44Z michi $ */ @@ -118,7 +118,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 4 /* bytes */ -#define REPLACEMENT_STUB_SIZE 5 /* words */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/arm/asmpart.S b/src/vm/jit/arm/asmpart.S index 68c77517d..3e7bacb24 100644 --- a/src/vm/jit/arm/asmpart.S +++ b/src/vm/jit/arm/asmpart.S @@ -22,14 +22,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8160 2007-06-28 01:52:19Z michi $ + $Id: asmpart.S 8276 2007-08-08 16:09:14Z twisti $ */ #include "config.h" -#include "vm/jit/arm/offsets.h" #include "vm/jit/arm/md-asm.h" #include "vm/jit/methodheader.h" @@ -59,23 +58,11 @@ .globl asm_cacheflush - .globl asm_getclassvalues_atomic - .globl asm_criticalsections - - #if !defined(ENABLE_THREADS) asm_exceptionptr: .word _no_threads_exceptionptr #endif -asm_criticalsections: -#if defined(ENABLE_THREADS) - .word _crit_begin - .word _crit_end - .word _crit_restart -#endif - .word 0 - /* asm_vm_call_method ********************************************************** @@ -347,23 +334,6 @@ asm_cacheflush: #endif -/********************* function asm_getclassvalues_atomic *********************/ - -asm_getclassvalues_atomic: - stmfd sp!, {r4, r5, r6} -_crit_restart: -_crit_begin: - ldr r4,[a0,#offbaseval] - ldr r5,[a0,#offdiffval] - ldr r6,[a1,#offbaseval] -_crit_end: - str r4,[a2,#offcast_super_baseval] - str r5,[a2,#offcast_super_diffval] - str r6,[a2,#offcast_sub_baseval] - ldmfd sp!, {r4, r5, r6} - mov pc, lr - - /* disable exec-stacks ********************************************************/ #if defined(__linux__) && defined(__ELF__) diff --git a/src/vm/jit/arm/codegen.c b/src/vm/jit/arm/codegen.c index 9b9125a87..3c4130da1 100644 --- a/src/vm/jit/arm/codegen.c +++ b/src/vm/jit/arm/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $ + $Id: codegen.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -41,6 +41,7 @@ #include "mm/memory.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -89,8 +90,6 @@ bool codegen_emit(jitdata *jd) basicblock *bptr; instruction *iptr; exception_entry *ex; - s4 fieldtype; - s4 varindex; s4 spilledregs_num; s4 savedregs_num; @@ -101,6 +100,10 @@ bool codegen_emit(jitdata *jd) unresolved_method *um; builtintable_entry *bte; methoddesc *md; + fieldinfo *fi; + unresolved_field *uf; + int fieldtype; + int varindex; /* get required compiler data */ @@ -1374,11 +1377,9 @@ bool codegen_emit(jitdata *jd) case ICMD_GETSTATIC: /* ... ==> ..., value */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; - - disp = dseg_add_unique_address(cd, NULL); + disp = dseg_add_unique_address(cd, NULL); patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); @@ -1386,9 +1387,9 @@ bool codegen_emit(jitdata *jd) M_NOP; } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { patcher_add_patch_ref(jd, PATCHER_initialize_class, @@ -1397,8 +1398,6 @@ bool codegen_emit(jitdata *jd) if (opt_showdisassemble) M_NOP; } - - disp = dseg_add_address(cd, &(fi->value)); } M_DSEG_LOAD(REG_ITMP3, disp); @@ -1437,11 +1436,9 @@ bool codegen_emit(jitdata *jd) case ICMD_PUTSTATIC: /* ..., value ==> ... */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; - - disp = dseg_add_unique_address(cd, NULL); + disp = dseg_add_unique_address(cd, NULL); patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); @@ -1449,9 +1446,9 @@ bool codegen_emit(jitdata *jd) M_NOP; } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { patcher_add_patch_ref(jd, PATCHER_initialize_class, @@ -1460,8 +1457,6 @@ bool codegen_emit(jitdata *jd) if (opt_showdisassemble) M_NOP; } - - disp = dseg_add_address(cd, &(fi->value)); } M_DSEG_LOAD(REG_ITMP3, disp); @@ -1503,13 +1498,12 @@ bool codegen_emit(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; + disp = 0; } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; disp = fi->offset; } @@ -1521,14 +1515,13 @@ bool codegen_emit(jitdata *jd) #endif if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; + /* XXX REMOVE ME */ + uf = iptr->sx.s23.s3.uf; patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); if (opt_showdisassemble) M_NOP; - - disp = 0; } switch (fieldtype) { @@ -1569,13 +1562,12 @@ bool codegen_emit(jitdata *jd) emit_nullpointer_check(cd, iptr, s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; + disp = 0; } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; disp = fi->offset; } @@ -1611,14 +1603,13 @@ bool codegen_emit(jitdata *jd) } if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; + /* XXX REMOVE ME */ + uf = iptr->sx.s23.s3.uf; patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); if (opt_showdisassemble) M_NOP; - - disp = 0; } switch (fieldtype) { @@ -2334,7 +2325,7 @@ bool codegen_emit(jitdata *jd) /* implicit null-pointer check */ M_LDR_INTERN(REG_METHODPTR, REG_A0, - OFFSET(java_objectheader, vftbl)); + OFFSET(java_object_t, vftbl)); M_LDR_INTERN(REG_PV, REG_METHODPTR, s1); /* generate the actual call */ @@ -2363,7 +2354,7 @@ bool codegen_emit(jitdata *jd) /* implicit null-pointer check */ M_LDR_INTERN(REG_METHODPTR, REG_A0, - OFFSET(java_objectheader, vftbl)); + OFFSET(java_object_t, vftbl)); M_LDR_INTERN(REG_METHODPTR, REG_METHODPTR, s1); M_LDR_INTERN(REG_PV, REG_METHODPTR, s2); @@ -2488,7 +2479,7 @@ bool codegen_emit(jitdata *jd) emit_label_beq(cd, BRANCH_LABEL_3); } - M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_LDR_INTERN(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); /* we put unresolved or non-immediate superindices onto dseg */ @@ -2507,7 +2498,7 @@ bool codegen_emit(jitdata *jd) things differently here! */ if ((super == NULL) || !IS_IMM(superindex)) { - M_LDR_INTERN(REG_ITMP3, s1, OFFSET(java_objectheader, vftbl)); + M_LDR_INTERN(REG_ITMP3, s1, OFFSET(java_object_t, vftbl)); /* this assumes something */ assert(OFFSET(vftbl_t, interfacetable[0]) == 0); @@ -2557,7 +2548,7 @@ bool codegen_emit(jitdata *jd) emit_label_beq(cd, BRANCH_LABEL_5); } - M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_DSEG_LOAD(REG_ITMP3, disp); CODEGEN_CRITICAL_SECTION_START; @@ -2694,7 +2685,7 @@ bool codegen_emit(jitdata *jd) emit_label_beq(cd, BRANCH_LABEL_3); } - M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_LDR_INTERN(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); @@ -2768,7 +2759,7 @@ bool codegen_emit(jitdata *jd) emit_label_beq(cd, BRANCH_LABEL_5); } - M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_DSEG_LOAD(REG_ITMP2, disp); CODEGEN_CRITICAL_SECTION_START; diff --git a/src/vm/jit/arm/emit.c b/src/vm/jit/arm/emit.c index 2967a7872..ccd5e7402 100644 --- a/src/vm/jit/arm/emit.c +++ b/src/vm/jit/arm/emit.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -561,46 +562,24 @@ void emit_exception_check(codegendata *cd, instruction *iptr) } -/* emit_patcher_traps ********************************************************** +/* emit_trap ******************************************************************* - Generates the code for the patcher traps. + Emit a trap instruction and return the original machine code. *******************************************************************************/ -void emit_patcher_traps(jitdata *jd) +uint32_t emit_trap(codegendata *cd) { - codegendata *cd; - codeinfo *code; - patchref_t *pr; - u1 *savedmcodeptr; - u1 *tmpmcodeptr; - - /* get required compiler data */ - - cd = jd->cd; - code = jd->code; - - /* generate patcher traps code */ + uint32_t mcode; - for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) { + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ - /* Get machine code which is patched back in later. The - trap is 1 instruction word long. */ + mcode = *((u4 *) cd->mcodeptr); - tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc); + M_TRAP(0, EXCEPTION_HARDWARE_PATCHER); - pr->mcode = *((u4 *) tmpmcodeptr); - - /* Patch in the trap to call the signal handler (done at - compile time). */ - - savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ - cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ - - M_TRAP(0, EXCEPTION_HARDWARE_PATCHER); - - cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ - } + return mcode; } diff --git a/src/vm/jit/arm/linux/md-os.c b/src/vm/jit/arm/linux/md-os.c index 4c593bba1..38209100d 100644 --- a/src/vm/jit/arm/linux/md-os.c +++ b/src/vm/jit/arm/linux/md-os.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -71,18 +72,18 @@ typedef struct ucontext { void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - scontext_t *_sc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - ptrint addr; - s4 type; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + scontext_t *_sc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + intptr_t addr; + int type; + intptr_t val; + void *p; _uc = (ucontext_t*) _p; _sc = &_uc->uc_mcontext; @@ -115,9 +116,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -125,9 +126,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _sc->arm_r10 = (ptrint) e; - _sc->arm_fp = (ptrint) xpc; - _sc->arm_pc = (ptrint) asm_handle_exception; + _sc->arm_r10 = (intptr_t) p; + _sc->arm_fp = (intptr_t) xpc; + _sc->arm_pc = (intptr_t) asm_handle_exception; } @@ -139,17 +140,17 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - scontext_t *_sc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 type; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + scontext_t *_sc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + int type; + intptr_t val; + void *p; _uc = (ucontext_t*) _p; _sc = &_uc->uc_mcontext; @@ -178,9 +179,9 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -189,10 +190,10 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) /* set registers if we have an exception, return continue execution otherwise (this is needed for patchers to work) */ - if (e != NULL) { - _sc->arm_r10 = (ptrint) e; - _sc->arm_fp = (ptrint) xpc; - _sc->arm_pc = (ptrint) asm_handle_exception; + if (p != NULL) { + _sc->arm_r10 = (intptr_t) p; + _sc->arm_fp = (intptr_t) xpc; + _sc->arm_pc = (intptr_t) asm_handle_exception; } } diff --git a/src/vm/jit/arm/patcher.c b/src/vm/jit/arm/patcher.c index 600a553e0..cc12574b9 100644 --- a/src/vm/jit/arm/patcher.c +++ b/src/vm/jit/arm/patcher.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 8160 2007-06-28 01:52:19Z michi $ + $Id: patcher.c 8268 2007-08-07 13:24:43Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -102,7 +103,7 @@ bool patcher_get_putstatic(patchref_t *pr) /* patch the field value's address */ - *((ptrint *) datap) = (ptrint) &(fi->value); + *((intptr_t *) datap) = (intptr_t) fi->value; return true; } diff --git a/src/vm/jit/asmpart.h b/src/vm/jit/asmpart.h index 1cf98d671..a6bd7ad34 100644 --- a/src/vm/jit/asmpart.h +++ b/src/vm/jit/asmpart.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.h 8210 2007-07-18 12:51:00Z twisti $ + $Id: asmpart.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -43,39 +43,9 @@ #include "vm/global.h" #include "vm/vm.h" -#include "vm/jit/replace.h" - #include "vmcore/linker.h" -/* some macros ****************************************************************/ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - -# define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \ - do { \ - if (opt_intrp) \ - intrp_asm_getclassvalues_atomic((super), (sub), (out)); \ - else \ - asm_getclassvalues_atomic((super), (sub), (out)); \ - } while (0) - -# else /* defined(ENABLE_INTRP) */ - -# define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \ - asm_getclassvalues_atomic((super), (sub), (out)) - -# endif /* defined(ENABLE_INTRP) */ - -#else /* defined(ENABLE_JIT) */ - -# define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \ - intrp_asm_getclassvalues_atomic((super), (sub), (out)) - -#endif /* defined(ENABLE_JIT) */ - - /* function prototypes ********************************************************/ /* machine dependent initialization */ @@ -89,31 +59,17 @@ 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__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -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); -s8 asm_vm_call_method_long(methodinfo *m, s4 vmargscount, vm_arg *vmargs); -float asm_vm_call_method_float(methodinfo *m, s4 vmargscount, vm_arg *vmargs); -double asm_vm_call_method_double(methodinfo *m, s4 vmargscount, vm_arg *vmargs); - -void asm_vm_call_method_exception_handler(void); +java_object_t *asm_vm_call_method(void *pv, uint64_t *array, int32_t stackargs); +int32_t asm_vm_call_method_int(void *pv, uint64_t *array, int32_t stackargs); -void asm_vm_call_method_end(void); -#else -java_objectheader *asm_vm_call_method(void *pv, uint64_t *array, int32_t stackargs); -int32_t asm_vm_call_method_int(void *pv, uint64_t *array, int32_t stackargs); - -int64_t asm_vm_call_method_long(void *pv, uint64_t *array, int32_t stackargs); -float asm_vm_call_method_float(void *pv, uint64_t *array, int32_t stackargs); -double asm_vm_call_method_double(void *pv, uint64_t *array, int32_t stackargs); +int64_t asm_vm_call_method_long(void *pv, uint64_t *array, int32_t stackargs); +float asm_vm_call_method_float(void *pv, uint64_t *array, int32_t stackargs); +double asm_vm_call_method_double(void *pv, uint64_t *array, int32_t stackargs); void asm_vm_call_method_exception_handler(void); void asm_vm_call_method_end(void); #endif -#endif - #if defined(ENABLE_INTRP) java_objectheader *intrp_asm_vm_call_method(methodinfo *m, s4 vmargscount, vm_arg *vmargs); @@ -147,27 +103,9 @@ void intrp_asm_abstractmethoderror(void); /* wrapper for code patching functions */ void asm_patcher_wrapper(void); -/* functions for on-stack replacement */ -#if defined(ENABLE_REPLACEMENT) -void asm_replacement_out(void); -void asm_replacement_in(executionstate_t *es, replace_safestack_t *st); -#endif - long asm_compare_and_swap(volatile long *p, long oldval, long newval); void asm_memory_barrier(void); -#if defined(ENABLE_THREADS) -extern critical_section_node_t asm_criticalsections; -#endif - -#if defined(ENABLE_JIT) -void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out); -#endif - -#if defined(ENABLE_INTRP) -void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out); -#endif - /* cache flush function */ void asm_cacheflush(u1 *addr, s4 nbytes); diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c index c495c959c..adc2d1c5e 100644 --- a/src/vm/jit/codegen-common.c +++ b/src/vm/jit/codegen-common.c @@ -39,7 +39,7 @@ memory. All functions writing values into the data area return the offset relative the begin of the code area (start of procedure). - $Id: codegen-common.c 8245 2007-07-31 09:55:04Z michi $ + $Id: codegen-common.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -265,6 +265,11 @@ static void codegen_reset(jitdata *jd) bptr->branchrefs = NULL; } + /* We need to clear all the patcher references from the codeinfo + since they all will be regenerated */ + + patcher_list_reset(code); + #if defined(ENABLE_REPLACEMENT) code->rplpoints = NULL; code->rplpointcount = 0; @@ -547,14 +552,6 @@ void codegen_add_patch_ref(codegendata *cd, functionptr patcher, voidptr ref, if (opt_shownops) PATCHER_NOPS; - /* If the codegen provides a PACHER_LONGBRANCHES_NOPS macro, honour it. */ - -#if defined(PATCHER_LONGBRANCHES_NOPS) - if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) { - PATCHER_LONGBRANCHES_NOPS; - } -#endif - #if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__MIPS__) \ || defined(__SPARC_64__) || defined(__X86_64__)) @@ -1536,16 +1533,7 @@ void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra) #if defined(ENABLE_JNI) /* add current JNI local references table to this thread */ - lrt->capacity = LOCALREFTABLE_CAPACITY; - lrt->used = 0; - lrt->localframes = 1; - lrt->prev = LOCALREFTABLE; - - /* clear the references array (memset is faster the a for-loop) */ - - MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY); - - LOCALREFTABLE = lrt; + localref_table_add(lrt); #endif #if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) @@ -1564,16 +1552,11 @@ void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra) *******************************************************************************/ -java_objectheader *codegen_finish_native_call(u1 *datasp) +java_object_t *codegen_finish_native_call(u1 *datasp) { - stackframeinfo *sfi; - stackframeinfo **psfi; -#if defined(ENABLE_JNI) - localref_table *lrt; - localref_table *plrt; - s4 localframes; -#endif - java_objectheader *e; + stackframeinfo *sfi; + stackframeinfo **psfi; + java_handle_t *e; /* get data structures from stack */ @@ -1592,33 +1575,10 @@ java_objectheader *codegen_finish_native_call(u1 *datasp) *psfi = sfi->prev; #if defined(ENABLE_JNI) - /* release JNI local references tables for this thread */ - - lrt = LOCALREFTABLE; - - /* release all current local frames */ - - for (localframes = lrt->localframes; localframes >= 1; localframes--) { - /* get previous frame */ - - plrt = lrt->prev; - - /* Clear all reference entries (only for tables allocated on - the Java heap). */ - - if (localframes > 1) - MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity); - - lrt->prev = NULL; - - /* set new local references table */ - - lrt = plrt; - } - - /* now store the previous local frames in the thread structure */ + /* release JNI local references table for this thread */ - LOCALREFTABLE = lrt; + localref_frame_pop_all(); + localref_table_remove(); #endif /* get the exception and return it */ diff --git a/src/vm/jit/codegen-common.h b/src/vm/jit/codegen-common.h index 327bb5111..94792a8d9 100644 --- a/src/vm/jit/codegen-common.h +++ b/src/vm/jit/codegen-common.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen-common.h 7918 2007-05-20 20:42:18Z michi $ + $Id: codegen-common.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -331,7 +331,7 @@ void codegen_stub_builtin_enter(u1 *datasp, u1 *pv, u1 *sp, u1 *ra); void codegen_stub_builtin_exit(u1 *datasp); void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra); -java_objectheader *codegen_finish_native_call(u1 *datasp); +java_object_t *codegen_finish_native_call(u1 *datasp); s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum); s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum); diff --git a/src/vm/jit/dseg.c b/src/vm/jit/dseg.c index 02400e62c..558241b71 100644 --- a/src/vm/jit/dseg.c +++ b/src/vm/jit/dseg.c @@ -30,7 +30,7 @@ Joseph Wenninger Edwin Steiner - $Id: dseg.c 7596 2007-03-28 21:05:53Z twisti $ + $Id: dseg.c 8298 2007-08-12 18:49:16Z pm $ */ @@ -830,6 +830,10 @@ s4 dseg_get_linenumber_from_pc(methodinfo **pm, u1 *pv, u1 *pc) linenumbertable_entry *lntentry; /* points to last entry in the table */ s4 linenumber; +#if defined(__S390__) + pc = (u1 *)((intptr_t)pc & 0x7FFFFFFF); +#endif + /* get size of line number table */ lntsize = *((ptrint *) (pv + LineNumberTableSize)); diff --git a/src/vm/jit/emit-common.c b/src/vm/jit/emit-common.c index c02566c53..5639853ef 100644 --- a/src/vm/jit/emit-common.c +++ b/src/vm/jit/emit-common.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emitfuncs.c 4398 2006-01-31 23:43:08Z twisti $ + $Id: emit-common.c 8265 2007-08-06 16:10:42Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -38,6 +39,7 @@ #include "vm/jit/emit-common.h" #include "vm/jit/jit.h" +#include "vm/jit/patcher-common.h" #include "vmcore/options.h" #include "vmcore/statistics.h" @@ -247,6 +249,53 @@ void emit_store_dst(jitdata *jd, instruction *iptr, s4 d) } +/* emit_patcher_traps ********************************************************** + + Generates the code for the patcher traps. + +*******************************************************************************/ + +void emit_patcher_traps(jitdata *jd) +{ + codegendata *cd; + codeinfo *code; + patchref_t *pr; + u1 *savedmcodeptr; + u1 *tmpmcodeptr; + uint32_t mcode; + + /* get required compiler data */ + + cd = jd->cd; + code = jd->code; + + /* generate patcher traps code */ + + for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) { + + /* Calculate the patch position where the original machine + code is located and the trap should be placed. */ + + tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc); + + /* Patch in the trap to call the signal handler (done at + compile time). */ + + savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ + cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ + + mcode = emit_trap(cd); + + cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ + + /* Remember the original machine code which is patched + back in later (done at runtime). */ + + pr->mcode = mcode; + } +} + + /* emit_bccz ******************************************************************* Emit conditional and unconditional branch instructions on integer diff --git a/src/vm/jit/emit-common.h b/src/vm/jit/emit-common.h index 99c4b7216..0f4880ccf 100644 --- a/src/vm/jit/emit-common.h +++ b/src/vm/jit/emit-common.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emitfuncs.c 4398 2006-01-31 23:43:08Z twisti $ + $Id: emit-common.h 8265 2007-08-06 16:10:42Z twisti $ */ @@ -178,6 +178,8 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg); void emit_exception_check(codegendata *cd, instruction *iptr); +uint32_t emit_trap(codegendata *cd); + void emit_patcher_stubs(jitdata *jd); void emit_patcher_traps(jitdata *jd); diff --git a/src/vm/jit/i386/Makefile.am b/src/vm/jit/i386/Makefile.am index eac8d32c0..7fdbb7126 100644 --- a/src/vm/jit/i386/Makefile.am +++ b/src/vm/jit/i386/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/i386/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: -## -## $Id: Makefile.am 5794 2006-10-18 15:09:56Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -45,10 +39,6 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h @@ -77,10 +67,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/i386/arch.h b/src/vm/jit/i386/arch.h index 812b0c171..0c589f4d4 100644 --- a/src/vm/jit/i386/arch.h +++ b/src/vm/jit/i386/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 8210 2007-07-18 12:51:00Z twisti $ + $Id: arch.h 8247 2007-07-31 12:06:44Z michi $ */ @@ -123,7 +123,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 5 /* bytes */ -#define REPLACEMENT_STUB_SIZE (5+5+1) /* bytes */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/i386/asmpart.S b/src/vm/jit/i386/asmpart.S index f344e1aff..522a39c2a 100644 --- a/src/vm/jit/i386/asmpart.S +++ b/src/vm/jit/i386/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8210 2007-07-18 12:51:00Z twisti $ + $Id: asmpart.S 8274 2007-08-08 15:58:17Z twisti $ */ @@ -33,7 +33,6 @@ #include "vm/jit/i386/arch.h" #include "vm/jit/i386/md-abi.h" -#include "vm/jit/i386/offsets.h" #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" @@ -75,9 +74,6 @@ .globl asm_compare_and_swap .globl asm_memory_barrier - .globl asm_criticalsections - .globl asm_getclassvalues_atomic - .globl asm_get_cycle_count @@ -646,39 +642,6 @@ asm_memory_barrier: ret -asm_getclassvalues_atomic: -_crit_restart2: - mov 4(%esp),%ecx /* super */ - mov 8(%esp),%edx /* sub */ -_crit_begin2: - mov offbaseval(%ecx),%eax - mov offdiffval(%ecx),%ecx - mov offbaseval(%edx),%edx -_crit_end2: - push %ebx - mov 16(%esp),%ebx /* out */ - mov %eax,offcast_super_baseval(%ebx) - mov %ecx,offcast_super_diffval(%ebx) - mov %edx,offcast_sub_baseval(%ebx) - pop %ebx - ret - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) -#if 0 - .long _crit_begin1 - .long _crit_end1 - .long _crit_restart1 -#endif - .long _crit_begin2 - .long _crit_end2 - .long _crit_restart2 -#endif - .long 0 - - /* asm_get_cycle_count ********************************************************* Get the current time-stamp counter from the CPU. diff --git a/src/vm/jit/i386/codegen.c b/src/vm/jit/i386/codegen.c index 05438e2b1..f8b72e3a0 100644 --- a/src/vm/jit/i386/codegen.c +++ b/src/vm/jit/i386/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $ + $Id: codegen.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -41,6 +42,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -2199,7 +2201,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = (ptrint) &(fi->value); + disp = (intptr_t) fi->value; if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); @@ -2240,7 +2242,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = (ptrint) &(fi->value); + disp = (intptr_t) fi->value; if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); @@ -2282,7 +2284,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = (ptrint) &(fi->value); + disp = (intptr_t) fi->value; if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); @@ -2309,21 +2311,17 @@ bool codegen_emit(jitdata *jd) emit_nullpointer_check(cd, iptr, s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; + disp = 0; codegen_addpatchref(cd, PATCHER_getfield, iptr->sx.s23.s3.uf, 0); - - disp = 0; - } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = fi->offset; + disp = fi->offset; } switch (fieldtype) { @@ -2356,13 +2354,11 @@ bool codegen_emit(jitdata *jd) /* must be done here because of code patching */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; } @@ -2376,16 +2372,15 @@ bool codegen_emit(jitdata *jd) s2 = emit_load_s2(jd, iptr, REG_FTMP2); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - - codegen_addpatchref(cd, PATCHER_putfield, uf, 0); - + /* XXX */ + uf = iptr->sx.s23.s3.uf; disp = 0; + codegen_addpatchref(cd, PATCHER_putfield, uf, 0); } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + /* XXX */ + fi = iptr->sx.s23.s3.fmiref->p.field; disp = fi->offset; } @@ -2414,25 +2409,19 @@ bool codegen_emit(jitdata *jd) emit_nullpointer_check(cd, iptr, s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; + disp = 0; codegen_addpatchref(cd, PATCHER_putfieldconst, uf, 0); - - disp = 0; - } - else - { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; - + else { + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = fi->offset; + disp = fi->offset; } - switch (fieldtype) { case TYPE_INT: case TYPE_ADR: @@ -3024,7 +3013,7 @@ gen_method: } M_ALD(REG_METHODPTR, REG_ITMP1, - OFFSET(java_objectheader, vftbl)); + OFFSET(java_object_t, vftbl)); M_ALD32(REG_ITMP3, REG_METHODPTR, s1); M_CALL(REG_ITMP3); break; @@ -3052,7 +3041,7 @@ gen_method: } M_ALD(REG_METHODPTR, REG_ITMP1, - OFFSET(java_objectheader, vftbl)); + OFFSET(java_object_t, vftbl)); M_ALD32(REG_METHODPTR, REG_METHODPTR, s1); M_ALD32(REG_ITMP3, REG_METHODPTR, s2); M_CALL(REG_ITMP3); @@ -3139,7 +3128,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_addpatchref(cd, PATCHER_checkcast_interface, @@ -3177,7 +3166,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_addpatchref(cd, PATCHER_checkcast_class, @@ -3302,7 +3291,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_addpatchref(cd, PATCHER_instanceof_interface, @@ -3344,7 +3333,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_addpatchref(cd, PATCHER_instanceof_class, diff --git a/src/vm/jit/i386/darwin/md-os.c b/src/vm/jit/i386/darwin/md-os.c index d04a842bc..b26d04d42 100644 --- a/src/vm/jit/i386/darwin/md-os.c +++ b/src/vm/jit/i386/darwin/md-os.c @@ -1,6 +1,6 @@ /* src/vm/jit/i386/darwin/md-os.c - machine dependent i386 Darwin functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, + Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,12 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - $Id: md-os.c 5074 2006-07-04 16:05:35Z twisti $ */ @@ -37,6 +31,7 @@ #include #include +#include #include #include "vm/types.h" @@ -74,11 +69,11 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) u1 opc; u1 mod; u1 rm; - s4 d; - s4 disp; - ptrint val; - s4 type; - java_objectheader *e; + int d; + int32_t disp; + intptr_t val; + int type; + void *p; _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; @@ -125,9 +120,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -135,9 +130,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _ss->eax = (ptrint) e; - _ss->ecx = (ptrint) xpc; - _ss->eip = (ptrint) asm_handle_exception; + _ss->eax = (intptr_t) p; + _ss->ecx = (intptr_t) xpc; + _ss->eip = (intptr_t) asm_handle_exception; } @@ -158,9 +153,9 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) u1 *sp; u1 *ra; u1 *xpc; - s4 type; - ptrint val; - java_objectheader *e; + int type; + intptr_t val; + void *p; _uc = (ucontext_t *) _p; @@ -181,17 +176,17 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _ss->eax = (ptrint) e; - _ss->ecx = (ptrint) xpc; - _ss->eip = (ptrint) asm_handle_exception; + _ss->eax = (intptr_t) p; + _ss->ecx = (intptr_t) xpc; + _ss->eip = (intptr_t) asm_handle_exception; } @@ -221,6 +216,13 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) } +/* md_critical_section_restart ************************************************* + + Search the critical sections tree for a matching section and set + the PC to the restart point, if necessary. + +*******************************************************************************/ + #if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *_uc) { diff --git a/src/vm/jit/i386/emit.c b/src/vm/jit/i386/emit.c index 9c4d2d6e1..9460875e4 100644 --- a/src/vm/jit/i386/emit.c +++ b/src/vm/jit/i386/emit.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 8211 2007-07-18 19:52:23Z michi $ + $Id: emit.c 8267 2007-08-07 11:07:48Z twisti $ */ @@ -576,6 +576,27 @@ void emit_patcher_stubs(jitdata *jd) } +/* emit_trap ******************************************************************* + + Emit a trap instruction and return the original machine code. + +*******************************************************************************/ + +uint32_t emit_trap(codegendata *cd) +{ + uint32_t mcode; + + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ + + mcode = *((uint32_t *) cd->mcodeptr); + + M_NOP; + + return mcode; +} + + /* emit_verbosecall_enter ****************************************************** Generates the code for the call trace. diff --git a/src/vm/jit/i386/linux/md-os.c b/src/vm/jit/i386/linux/md-os.c index 53376f0b3..031c6774a 100644 --- a/src/vm/jit/i386/linux/md-os.c +++ b/src/vm/jit/i386/linux/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $ + $Id: md-os.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -31,6 +31,7 @@ #include "config.h" +#include #include #include "vm/types.h" @@ -55,21 +56,21 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u1 opc; - u1 mod; - u1 rm; - s4 d; - s4 disp; - ptrint val; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u1 opc; + u1 mod; + u1 rm; + s4 d; + s4 disp; + ptrint val; + s4 type; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -115,9 +116,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -125,9 +126,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _mc->gregs[REG_EAX] = (ptrint) e; - _mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */ - _mc->gregs[REG_EIP] = (ptrint) asm_handle_exception; + _mc->gregs[REG_EAX] = (intptr_t) p; + _mc->gregs[REG_ECX] = (intptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_EIP] = (intptr_t) asm_handle_exception; } @@ -140,16 +141,16 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - s4 type; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + s4 type; + ptrint val; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -168,17 +169,17 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gregs[REG_EAX] = (ptrint) e; - _mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */ - _mc->gregs[REG_EIP] = (ptrint) asm_handle_exception; + _mc->gregs[REG_EAX] = (intptr_t) p; + _mc->gregs[REG_ECX] = (intptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_EIP] = (intptr_t) asm_handle_exception; } diff --git a/src/vm/jit/i386/md.c b/src/vm/jit/i386/md.c index 06f036cd3..7051bb72c 100644 --- a/src/vm/jit/i386/md.c +++ b/src/vm/jit/i386/md.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md.c 7596 2007-03-28 21:05:53Z twisti $ + $Id: md.c 8247 2007-07-31 12:06:44Z michi $ */ @@ -220,7 +220,6 @@ void md_dcacheflush(u1 *addr, s4 nbytes) #if defined(ENABLE_REPLACEMENT) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; u8 mcode; /* XXX this is probably unsafe! */ @@ -241,11 +240,8 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save savedmcode[4] = rp->pc[4]; /* build the machine code for the patch */ - disp = (code->replacementstubs - rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 5; - - mcode = 0xe9 | ((u8) disp << 8); + assert(0); /* XXX build trap instruction below */ + mcode = 0; /* write spinning instruction */ *(u2*)(rp->pc) = 0xebfe; diff --git a/src/vm/jit/i386/patcher.c b/src/vm/jit/i386/patcher.c index bf8a6fdd6..709cc5a03 100644 --- a/src/vm/jit/i386/patcher.c +++ b/src/vm/jit/i386/patcher.c @@ -22,12 +22,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 8143 2007-06-26 15:47:43Z twisti $ + $Id: patcher.c 8295 2007-08-11 17:57:24Z michi $ */ #include "config.h" + +#include + #include "vm/types.h" #include "vm/jit/i386/codegen.h" @@ -61,14 +64,14 @@ *******************************************************************************/ -java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) +java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) { stackframeinfo sfi; u1 *xpc; - java_objectheader *o; + java_object_t *o; functionptr f; bool result; - java_objectheader *e; + java_handle_t *e; /* define the patcher function */ @@ -77,7 +80,7 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) /* get stuff from the stack */ xpc = (u1 *) *((ptrint *) (sp + 6 * 4)); - o = (java_objectheader *) *((ptrint *) (sp + 4 * 4)); + o = (java_object_t *) *((ptrint *) (sp + 4 * 4)); f = (functionptr) *((ptrint *) (sp + 0 * 4)); /* calculate and set the new return address */ @@ -171,7 +174,7 @@ bool patcher_get_putstatic(u1 *sp) /* patch the field value's address */ - *((ptrint *) (ra + 1)) = (ptrint) &(fi->value); + *((intptr_t *) (ra + 1)) = (intptr_t) fi->value; return true; } diff --git a/src/vm/jit/jit.h b/src/vm/jit/jit.h index 95015104d..a9dff9f33 100644 --- a/src/vm/jit/jit.h +++ b/src/vm/jit/jit.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: jit.h 8123 2007-06-20 23:50:55Z michi $ + $Id: jit.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -333,7 +333,7 @@ typedef union { float f; double d; void *anyptr; - java_objectheader *stringconst; /* for ACONST with string */ + java_handle_t *stringconst; /* for ACONST with string */ classref_or_classinfo c; /* for ACONST with class */ } val_operand_t; diff --git a/src/vm/jit/m68k/Makefile.am b/src/vm/jit/m68k/Makefile.am index c761839cf..983a7a2b0 100644 --- a/src/vm/jit/m68k/Makefile.am +++ b/src/vm/jit/m68k/Makefile.am @@ -1,4 +1,33 @@ -DIST_SUBDIRS = linux +## src/vm/jit/m68k/Makefile.am +## +## Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, +## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, +## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, +## J. Wenninger, Institut f. Computersprachen - TU Wien +## +## This file is part of CACAO. +## +## This program is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. +## +## $Id: Makefile.am 5794 2006-10-18 15:09:56Z twisti $ + +## Process this file with automake to produce Makefile.in + +DIST_SUBDIRS = \ + linux SUBDIRS = $(OS_DIR) @@ -7,15 +36,12 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -#BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h -noinst_LTLIBRARIES = libarch.la +noinst_LTLIBRARIES = \ + libarch.la if ENABLE_DISASSEMBLER DISASS_SOURCES = \ @@ -30,11 +56,17 @@ libarch_la_SOURCES = \ emit.c \ md.c \ patcher.c - + libarch_la_LIBADD = \ $(OS_DIR)/libmd.la - $(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h -#offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h -# $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h + +## Local variables: +## mode: Makefile +## indent-tabs-mode: t +## c-basic-offset: 4 +## tab-width: 8 +## compile-command: "automake --add-missing" +## End: diff --git a/src/vm/jit/m68k/asmpart.S b/src/vm/jit/m68k/asmpart.S index 3fcecee82..3bac55626 100644 --- a/src/vm/jit/m68k/asmpart.S +++ b/src/vm/jit/m68k/asmpart.S @@ -1,14 +1,39 @@ -/* src/vm/jit/m68k/asmpart.S - * for cacao - * Roland Lezuo - */ +/* src/vm/jit/m68k/asmpart.S - Java-C interface functions for m68k + + Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, + C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, + E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, + J. Wenninger, Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + $Id: asmpart.S 8210 2007-07-18 12:51:00Z twisti $ + +*/ + #include "config.h" -#include "vm/jit/m68k/offsets.h" #include "md-abi.h" + #include "vm/jit/methodheader.h" + .text .globl asm_vm_call_method @@ -23,9 +48,7 @@ .globl asm_patcher_wrapper -.globl asm_getclassvalues_atomic .globl asm_abstractmethoderror -.globl asm_criticalsections .globl asm_handle_exception .globl asm_handle_nat_exception @@ -274,40 +297,6 @@ L_asm_patcher_wrapper_exception: jmp asm_handle_exception /* handle exception */ illegal /* XXX: we never come back */ -/******************************************************************************** - Reads a few values atomically. - C signature: - void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out); - - super ... sp@(4) - sub ... sp@(8) - out ... sp@(12) -********************************************************************************/ -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: - moveal %sp@(4), %a0 - movel %a0@(offbaseval), %d0 - movel %a0@(offdiffval), %d1 - - moveal %sp@(8), %a0 - moveal %a0@(offbaseval), %a0 -_crit_end: - moveal %sp@(12), %a1 - movel %d0, %a1@(offcast_super_baseval) - movel %d1, %a1@(offcast_super_diffval) - movel %a0, %a1@(offcast_sub_baseval) - - rts -.data -asm_criticalsections: -#if defined(ENABLE_THREADS) - .long _crit_begin - .long _crit_end - .long _crit_restart -#endif - .long 0 -.text asm_abstractmethoderror: diff --git a/src/vm/jit/m68k/codegen.c b/src/vm/jit/m68k/codegen.c index 402304182..d97fde5c8 100644 --- a/src/vm/jit/m68k/codegen.c +++ b/src/vm/jit/m68k/codegen.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "md-abi.h" #include "md-os.h" @@ -40,6 +41,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -1116,21 +1118,27 @@ bool codegen_emit(jitdata *jd) /* MEMORY *************************************************************/ - case ICMD_GETSTATIC: - if (INSTRUCTION_IS_UNRESOLVED(iptr)) { + + case ICMD_GETSTATIC: /* ... ==> ..., value */ + + if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; - codegen_addpatchref(cd, PATCHER_get_putstatic, uf, 0); - } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; + disp = 0; + codegen_addpatchref(cd, PATCHER_get_putstatic, uf, 0); + } + else { + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; + disp = (intptr_t) fi->value; + if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, PATCHER_initialize_class, fi->class, 0); + codegen_addpatchref(cd, PATCHER_initialize_class, fi->class, + 0); } - - disp = (ptrint) &(fi->value); } + M_AMOV_IMM(disp, REG_ATMP1); switch (fieldtype) { #if defined(ENABLE_SOFTFLOAT) @@ -1170,15 +1178,18 @@ bool codegen_emit(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; + disp = 0; codegen_addpatchref(cd, PATCHER_get_putstatic, uf, 0); - } else { + } + else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = &(fi->value); + disp = (intptr_t) fi->value; if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) - codegen_addpatchref(cd, PATCHER_initialize_class, fi->class, 0); + codegen_addpatchref(cd, PATCHER_initialize_class, fi->class, + 0); } M_AMOV_IMM(disp, REG_ATMP1); @@ -1723,7 +1734,7 @@ bool codegen_emit(jitdata *jd) /* load object pointer (==argument 0) */ M_ALD(REG_ATMP1, REG_SP, 0); /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_ATMP1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_ATMP1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ATMP3, REG_METHODPTR, s1); /* generate the actual call */ M_JSR(REG_ATMP3); @@ -1742,7 +1753,7 @@ bool codegen_emit(jitdata *jd) M_ALD(REG_ATMP1, REG_SP, 0); /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_ATMP1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_ATMP1, OFFSET(java_object_t, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_ATMP3, REG_METHODPTR, s2); @@ -2031,7 +2042,7 @@ nowperformreturn: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ATMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ATMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ATMP1, OFFSET(vftbl_t, interfacetablelength)); M_IADD_IMM(-superindex, REG_ITMP3); /* -superindex may be patched patched */ M_ITST(REG_ITMP3); @@ -2061,7 +2072,7 @@ nowperformreturn: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ATMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ATMP1, s1, OFFSET(java_object_t, vftbl)); CODEGEN_CRITICAL_SECTION_START; @@ -2151,7 +2162,7 @@ nowperformreturn: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ATMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ATMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, interfacetablelength)); M_IADD_IMM(-superindex, REG_ITMP3); /* superindex patched */ @@ -2182,7 +2193,7 @@ nowperformreturn: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ATMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ATMP2, s1, OFFSET(java_object_t, vftbl)); CODEGEN_CRITICAL_SECTION_START; diff --git a/src/vm/jit/m68k/linux/md-os.c b/src/vm/jit/m68k/linux/md-os.c index 1055a7885..1cdab5f81 100644 --- a/src/vm/jit/m68k/linux/md-os.c +++ b/src/vm/jit/m68k/linux/md-os.c @@ -95,7 +95,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_ uint16_t opc; uint32_t val, regval, off; bool adrreg; - java_objectheader *e; + void *p; mcontext_t *_mc; _mc = &_uc->uc_mcontext; @@ -146,17 +146,17 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_ stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, xpc, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, EXCEPTION_HARDWARE_NULLPOINTER, regval); + p = signal_handle(xpc, EXCEPTION_HARDWARE_NULLPOINTER, regval); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (ptrint) e; - _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc; - _mc->gregs[R_PC] = (ptrint) asm_handle_exception; + _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (intptr_t) p; + _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (intptr_t) xpc; + _mc->gregs[R_PC] = (intptr_t) asm_handle_exception; } /* md_signal_handler_sigill ******************************************* @@ -174,7 +174,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_u uint16_t opc; uint32_t type; uint32_t val, regval; - java_objectheader *e; + void *p; mcontext_t *_mc; xpc = siginfo->si_addr; @@ -227,17 +227,17 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_u stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, xpc, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, regval); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (ptrint) e; - _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc; - _mc->gregs[R_PC] = (ptrint) asm_handle_exception; + _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (intptr_t) p; + _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (intptr_t) xpc; + _mc->gregs[R_PC] = (intptr_t) asm_handle_exception; } /* md_signal_handler_sigusr1 *************************************************** diff --git a/src/vm/jit/m68k/md.c b/src/vm/jit/m68k/md.c index c9759b52c..2d28f43d6 100644 --- a/src/vm/jit/m68k/md.c +++ b/src/vm/jit/m68k/md.c @@ -52,11 +52,8 @@ */ void md_init(void) { - assert(sizeof(vm_arg) == sizevmarg); assert(OFFSET(vftbl_t, baseval) == offbaseval); assert(OFFSET(vftbl_t, diffval) == offdiffval); - assert(OFFSET(vm_arg, type) == offvmargtype); - assert(OFFSET(vm_arg, data) == offvmargdata); assert(OFFSET(castinfo, super_baseval) == offcast_super_baseval); assert(OFFSET(castinfo, super_diffval) == offcast_super_diffval); assert(OFFSET(castinfo, sub_baseval) == offcast_sub_baseval); diff --git a/src/vm/jit/m68k/patcher.c b/src/vm/jit/m68k/patcher.c index f7923e3fa..0774f4e41 100644 --- a/src/vm/jit/m68k/patcher.c +++ b/src/vm/jit/m68k/patcher.c @@ -29,6 +29,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -348,7 +349,7 @@ bool patcher_get_putstatic(u1 *sp) /* patch the field value's address */ if (opt_shownops) disp += PATCHER_CALL_SIZE; assert(*((uint16_t*)(disp)) == 0x247c); - *((ptrint *) (disp+2)) = (ptrint) &(fi->value); + *((intptr_t *) (disp+2)) = (intptr_t) fi->value; /* synchronize inst cache */ md_icacheflush(disp+2, SIZEOF_VOID_P); diff --git a/src/vm/jit/mips/Makefile.am b/src/vm/jit/mips/Makefile.am index 5faa716fe..709c9b84d 100644 --- a/src/vm/jit/mips/Makefile.am +++ b/src/vm/jit/mips/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 7957 2007-05-23 18:28:01Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -38,12 +38,6 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -BUILT_SOURCES = \ - offsets.h - -CLEANFILES = \ - offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h \ @@ -73,10 +67,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/mips/arch.h b/src/vm/jit/mips/arch.h index 002d468a0..0514af1c9 100644 --- a/src/vm/jit/mips/arch.h +++ b/src/vm/jit/mips/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $ + $Id: arch.h 8263 2007-08-06 14:41:05Z twisti $ */ @@ -151,7 +151,6 @@ #define SUPPORT_COMBINE_INTEGER_REGISTERS -#define SUPPORT_PASS_FLOATARGS_IN_INTREGS #if defined(ENABLE_SOFT_FLOAT) # define SUPPORT_PASS_FLOATARGS_IN_INTREGS @@ -175,7 +174,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE (2*4) /* bytes */ -#define REPLACEMENT_STUB_SIZE 6 /* words */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/mips/asmpart.S b/src/vm/jit/mips/asmpart.S index e717082f3..5f3be73be 100644 --- a/src/vm/jit/mips/asmpart.S +++ b/src/vm/jit/mips/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8123 2007-06-20 23:50:55Z michi $ + $Id: asmpart.S 8274 2007-08-08 15:58:17Z twisti $ */ @@ -31,7 +31,6 @@ #include "vm/jit/mips/md-abi.h" #include "vm/jit/mips/md-asm.h" -#include "vm/jit/mips/offsets.h" #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" @@ -58,16 +57,11 @@ .globl asm_abstractmethoderror - .globl asm_patcher_wrapper - #if defined(ENABLE_REPLACEMENT) .globl asm_replacement_out .globl asm_replacement_in #endif - .globl asm_getclassvalues_atomic - .globl asm_criticalsections - .globl compare_and_swap @@ -590,112 +584,6 @@ asm_abstractmethoderror: .end asm_abstractmethoderror -/* asm_patcher_wrapper ********************************************************* - - XXX - - Stack layout: - 56 return address into JIT code (patch position) - 48 pointer to virtual java_objectheader - 40 machine code (which is patched back later) - 32 machine code (which is patched back later) - 24 machine code (which is patched back later) - 16 unresolved class/method/field reference - 8 data segment displacement from load instructions - 0 patcher function pointer to call - -*******************************************************************************/ - - .ent asm_patcher_wrapper - -asm_patcher_wrapper: -#if SIZEOF_VOID_P == 8 - - aaddiu sp,sp,-((2+16+22+4)*8)/* create stack frame */ - - SAVE_RETURN_REGISTERS(0) /* save 1 int/1 float return registers */ - SAVE_ARGUMENT_REGISTERS(2) /* save 8 int/8 float argument registers */ - SAVE_TEMPORARY_REGISTERS(18) /* save 5 int/16 float temporary registers */ - - ast itmp1,(2+16+22+0)*8(sp) /* save itmp1 */ - ast itmp2,(2+16+22+1)*8(sp) /* save itmp2 */ - ast ra,(2+16+22+2)*8(sp) /* save method return address (for leafs) */ - ast pv,(2+16+22+3)*8(sp) /* save pv of calling java function */ - - aaddiu a0,sp,(2+16+22+4)*8 /* pass SP of patcher stub */ - move a1,pv /* pass PV */ - move a2,ra /* pass RA (correct for leafs) */ - jal patcher_wrapper - move itmp3,v0 - - RESTORE_RETURN_REGISTERS(0) /* restore 1 int/1 float return registers */ - RESTORE_ARGUMENT_REGISTERS(2) /* restore 8 int/8 float argument registers */ - RESTORE_TEMPORARY_REGISTERS(18) /* restore 5 int/16 float temporary reg. */ - - ald itmp1,(2+16+22+0)*8(sp) /* restore itmp1 */ - ald itmp2,(2+16+22+1)*8(sp) /* restore itmp2 */ - ald ra,(2+16+22+2)*8(sp) /* restore method return address (for leafs)*/ - ald pv,(2+16+22+3)*8(sp) /* restore pv of calling java function */ - - bnez itmp3,L_asm_patcher_wrapper_exception - - ald itmp3,(7+2+16+22+4)*8(sp) /* load RA */ - aaddiu sp,sp,(8+2+16+22+4)*8 /* remove stack frame */ - - jr itmp3 /* jump to new patched code */ - -L_asm_patcher_wrapper_exception: - move xptr,itmp3 /* get exception */ - ald xpc,(7+2+16+22+4)*8(sp) /* xpc is RA */ - aaddiu sp,sp,(8+2+16+22+4)*8 /* remove stack frame */ - -#else /* SIZEOF_VOID_P == 8 */ - - aaddiu sp,sp,-((6+4+8+16+7)*4) /* create stack frame */ - /* +7 keeps the SP 16-bytes aligned */ - - SAVE_RETURN_REGISTERS(6) /* save 2 int / 1 float return registers */ - SAVE_ARGUMENT_REGISTERS(10) /* save 4 int / 2 float argument registers */ - SAVE_TEMPORARY_REGISTERS(18) /* save 8 int / 4 float temporary registers */ - - ast itmp1,(6+4+8+16+0)*4(sp) /* save itmp1 */ - ast itmp2,(6+4+8+16+1)*4(sp) /* save itmp2 */ - ast ra,(6+4+8+16+2)*4(sp) /* save method return address (for leafs) */ - ast pv,(6+4+8+16+3)*4(sp) /* save pv of calling java function */ - - aaddiu a0,sp,(6+4+8+16+7)*4 /* pass SP of patcher stub */ - move a1,pv /* pass PV */ - move a2,ra /* pass RA (correct for leafs) */ - jal patcher_wrapper - move itmp3,v0 - - RESTORE_RETURN_REGISTERS(6) /* restore 2 int / 2 float return registers */ - RESTORE_ARGUMENT_REGISTERS(10) /* restore 4 int / 2 float argument regs */ - RESTORE_TEMPORARY_REGISTERS(18) /* restore 8 int / 4 float temporary regs */ - - ald itmp1,(6+4+8+16+0)*4(sp) /* restore itmp1 */ - ald itmp2,(6+4+8+16+1)*4(sp) /* restore itmp2 */ - ald ra,(6+4+8+16+2)*4(sp) /* restore method return address (for leafs)*/ - ald pv,(6+4+8+16+3)*4(sp) /* restore pv of calling java function */ - - bnez itmp3,L_asm_wrapper_patcher_exception - - ald itmp3,7*8+(6+4+8+16+7)*4(sp) /* load RA */ - aaddiu sp,sp,8*8+(6+4+8+16+7)*4 /* remove stack frame */ - - jr itmp3 /* jump to new patched code */ - -L_asm_wrapper_patcher_exception: - move xptr,itmp3 /* get exception */ - ald xpc,7*8+(6+4+8+16+7)*4(sp) /* xpc is RA */ - aaddiu sp,sp,8*8+(6+4+8+16+7)*4 /* remove stack frame */ - -#endif /* SIZEOF_VOID_P == 8 */ - - b asm_handle_exception - - .end asm_patcher_wrapper - #if defined(ENABLE_REPLACEMENT) /* asm_replacement_out ********************************************************* @@ -962,35 +850,6 @@ asm_replacement_in: #endif /* defined(ENABLE_REPLACEMENT) */ - .ent asm_getclassvalues_atomic - -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: - lw t0,offbaseval(a0) - lw t1,offdiffval(a0) - lw t2,offbaseval(a1) -_crit_end: - sw t0,offcast_super_baseval(a2) - sw t1,offcast_super_diffval(a2) - sw t2,offcast_sub_baseval(a2) - j ra - - .end asm_getclassvalues_atomic - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .dword _crit_begin - .dword _crit_end - .dword _crit_restart -#endif - .dword 0 - - - .text - .ent compare_and_swap compare_and_swap: diff --git a/src/vm/jit/mips/codegen.c b/src/vm/jit/mips/codegen.c index 4e3a515c2..c2e253122 100644 --- a/src/vm/jit/mips/codegen.c +++ b/src/vm/jit/mips/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8211 2007-07-18 19:52:23Z michi $ + $Id: codegen.c 8297 2007-08-12 00:02:48Z michi $ */ @@ -41,6 +41,7 @@ #include "mm/memory.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -56,7 +57,7 @@ #include "vm/jit/emit-common.h" #include "vm/jit/jit.h" #include "vm/jit/md.h" -#include "vm/jit/patcher.h" +#include "vm/jit/patcher-common.h" #include "vm/jit/reg.h" #include "vm/jit/replace.h" @@ -490,7 +491,8 @@ bool codegen_emit(jitdata *jd) cr = iptr->sx.val.c.ref; disp = dseg_add_unique_address(cd, cr); - codegen_add_patch_ref(cd, PATCHER_aconst, cr, disp); + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo, + cr, disp); M_ALD(d, REG_PV, disp); } @@ -1987,15 +1989,16 @@ bool codegen_emit(jitdata *jd) fieldtype = uf->fieldref->parseddesc.fd->type; disp = dseg_add_unique_address(cd, uf); - codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); + patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); } else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) - codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, disp); + patcher_add_patch_ref(jd, PATCHER_initialize_class, + fi->class, disp); } M_ALD(REG_ITMP1, REG_PV, disp); @@ -2036,15 +2039,16 @@ bool codegen_emit(jitdata *jd) fieldtype = uf->fieldref->parseddesc.fd->type; disp = dseg_add_unique_address(cd, uf); - codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); + patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); } else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) - codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, disp); + patcher_add_patch_ref(jd, PATCHER_initialize_class, + fi->class, disp); } M_ALD(REG_ITMP1, REG_PV, disp); @@ -2078,23 +2082,22 @@ bool codegen_emit(jitdata *jd) break; case ICMD_PUTSTATICCONST: /* ... ==> ... */ - /* val = value (in current instruction) */ - /* following NOP) */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; disp = dseg_add_unique_address(cd, uf); - codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); + patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); } else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) - codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, disp); + patcher_add_patch_ref(jd, PATCHER_initialize_class, + fi->class, disp); } M_ALD(REG_ITMP1, REG_PV, disp); @@ -2129,7 +2132,7 @@ bool codegen_emit(jitdata *jd) fieldtype = uf->fieldref->parseddesc.fd->type; disp = 0; - codegen_add_patch_ref(cd, PATCHER_get_putfield, uf, 0); + patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); } else { fi = iptr->sx.s23.s3.fmiref->p.field; @@ -2200,7 +2203,7 @@ bool codegen_emit(jitdata *jd) #endif if (INSTRUCTION_IS_UNRESOLVED(iptr)) - codegen_add_patch_ref(cd, PATCHER_get_putfield, uf, 0); + patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); switch (fieldtype) { case TYPE_INT: @@ -2227,15 +2230,14 @@ bool codegen_emit(jitdata *jd) emit_nullpointer_check(cd, iptr, s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - unresolved_field *uf = iptr->sx.s23.s3.uf; - + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; disp = 0; - codegen_add_patch_ref(cd, PATCHER_get_putfield, uf, 0); + patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); } else { - fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field; + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; disp = fi->offset; } @@ -2271,7 +2273,7 @@ bool codegen_emit(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uc = iptr->sx.s23.s2.uc; - codegen_add_patch_ref(cd, PATCHER_athrow_areturn, uc, 0); + patcher_add_patch_ref(jd, PATCHER_resolve_class, uc, 0); } #endif /* ENABLE_VERIFIER */ @@ -2790,7 +2792,7 @@ bool codegen_emit(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uc = iptr->sx.s23.s2.uc; - codegen_add_patch_ref(cd, PATCHER_athrow_areturn, uc, 0); + patcher_add_patch_ref(jd, PATCHER_resolve_class, uc, 0); } #endif /* ENABLE_VERIFIER */ goto nowperformreturn; @@ -3125,7 +3127,7 @@ gen_method: if (lm == NULL) { disp = dseg_add_unique_address(cd, um); - codegen_add_patch_ref(cd, PATCHER_invokestatic_special, um, + patcher_add_patch_ref(jd, PATCHER_invokestatic_special, um, disp); } else @@ -3146,7 +3148,7 @@ gen_method: emit_nullpointer_check(cd, iptr, REG_A0); if (lm == NULL) { - codegen_add_patch_ref(cd, PATCHER_invokevirtual, um, 0); + patcher_add_patch_ref(jd, PATCHER_invokevirtual, um, 0); s1 = 0; } @@ -3155,7 +3157,7 @@ gen_method: sizeof(methodptr) * lm->vftblindex; /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); /* generate the actual call */ @@ -3171,7 +3173,7 @@ gen_method: emit_nullpointer_check(cd, iptr, REG_A0); if (lm == NULL) { - codegen_add_patch_ref(cd, PATCHER_invokeinterface, um, 0); + patcher_add_patch_ref(jd, PATCHER_invokeinterface, um, 0); s1 = 0; s2 = 0; @@ -3184,7 +3186,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV, REG_METHODPTR, s2); @@ -3258,7 +3260,7 @@ gen_method: cr = iptr->sx.s23.s3.c.ref; disp = dseg_add_unique_s4(cd, 0); /* super->flags */ - codegen_add_patch_ref(cd, PATCHER_checkcast_instanceof_flags, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags, cr, disp); M_ILD(REG_ITMP2, REG_PV, disp); @@ -3272,14 +3274,14 @@ gen_method: if (super == NULL) { cr = iptr->sx.s23.s3.c.ref; - codegen_add_patch_ref(cd, PATCHER_checkcast_interface, + patcher_add_patch_ref(jd, PATCHER_checkcast_interface, cr, 0); } else { emit_label_beqz(cd, BRANCH_LABEL_3, s1); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_IADD_IMM(REG_ITMP3, -superindex, REG_ITMP3); @@ -3305,8 +3307,8 @@ gen_method: cr = iptr->sx.s23.s3.c.ref; disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, - PATCHER_checkcast_instanceof_class, + patcher_add_patch_ref(jd, + PATCHER_resolve_classref_to_vftbl, cr, disp); } else { @@ -3315,7 +3317,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_5, s1); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; @@ -3359,11 +3361,13 @@ gen_method: cr = iptr->sx.s23.s3.c.ref; disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, PATCHER_builtin_arraycheckcast, + patcher_add_patch_ref(jd, + PATCHER_resolve_classref_to_classinfo, cr, disp); } - else + else { disp = dseg_add_address(cd, iptr->sx.s23.s3.c.cls); + } M_ALD(REG_A1, REG_PV, disp); disp = dseg_add_functionptr(cd, BUILTIN_arraycheckcast); @@ -3419,7 +3423,7 @@ gen_method: cr = iptr->sx.s23.s3.c.ref; disp = dseg_add_unique_s4(cd, 0); /* super->flags */ - codegen_add_patch_ref(cd, PATCHER_checkcast_instanceof_flags, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags, cr, disp); M_ILD(REG_ITMP3, REG_PV, disp); @@ -3433,14 +3437,14 @@ gen_method: if (super == NULL) { cr = iptr->sx.s23.s3.c.ref; - codegen_add_patch_ref(cd, PATCHER_instanceof_interface, + patcher_add_patch_ref(jd, PATCHER_instanceof_interface, cr, 0); } else { emit_label_beqz(cd, BRANCH_LABEL_3, s1); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); M_IADD_IMM(REG_ITMP3, -superindex, REG_ITMP3); @@ -3466,7 +3470,7 @@ gen_method: cr = iptr->sx.s23.s3.c.ref; disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, PATCHER_checkcast_instanceof_class, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl, cr, disp); } else { @@ -3475,7 +3479,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_5, s1); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; @@ -3535,11 +3539,12 @@ gen_method: cr = iptr->sx.s23.s3.c.ref; disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, PATCHER_builtin_multianewarray, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo, cr, disp); } - else + else { disp = dseg_add_address(cd, iptr->sx.s23.s3.c.cls); + } /* a1 = arraydescriptor */ @@ -3592,9 +3597,9 @@ gen_method: dseg_createlinenumbertable(cd); - /* generate stubs */ + /* generate traps */ - emit_patcher_stubs(jd); + emit_patcher_traps(jd); /* everything's ok */ @@ -3701,7 +3706,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) - codegen_add_patch_ref(cd, PATCHER_resolve_native, m, funcdisp); + patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp); #endif /* save integer and float argument registers */ @@ -4028,9 +4033,9 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) M_JMP(REG_ITMP3); /* jump to asm exception handler */ M_ASUB_IMM(REG_RA, 4, REG_ITMP2_XPC); /* get exception address (DELAY) */ - /* generate patcher stubs */ + /* Generate patcher traps. */ - emit_patcher_stubs(jd); + emit_patcher_traps(jd); } diff --git a/src/vm/jit/mips/codegen.h b/src/vm/jit/mips/codegen.h index b30554280..6619a4ebd 100644 --- a/src/vm/jit/mips/codegen.h +++ b/src/vm/jit/mips/codegen.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.h 7691 2007-04-12 12:45:10Z twisti $ + $Id: codegen.h 8264 2007-08-06 16:02:28Z twisti $ */ @@ -115,16 +115,12 @@ /* patcher defines ************************************************************/ -#define PATCHER_CALL_INSTRUCTIONS 5 /* number of instructions */ -#define PATCHER_CALL_SIZE 5 * 4 /* size in bytes of a patcher call */ +#define PATCHER_CALL_INSTRUCTIONS 1 /* number of instructions */ +#define PATCHER_CALL_SIZE 1 * 4 /* size in bytes of a patcher call */ #define PATCHER_NOPS \ do { \ M_NOP; \ - M_NOP; \ - M_NOP; \ - M_NOP; \ - M_NOP; \ } while (0) diff --git a/src/vm/jit/mips/emit.c b/src/vm/jit/mips/emit.c index 094350a33..e1c3b3d80 100644 --- a/src/vm/jit/mips/emit.c +++ b/src/vm/jit/mips/emit.c @@ -50,6 +50,7 @@ #include "vm/jit/dseg.h" #include "vm/jit/emit-common.h" #include "vm/jit/jit.h" +#include "vm/jit/patcher-common.h" #include "vm/jit/replace.h" #include "vmcore/options.h" @@ -584,162 +585,24 @@ void emit_exception_check(codegendata *cd, instruction *iptr) } -/* emit_patcher_stubs ********************************************************** +/* emit_trap ******************************************************************* - Generates the code for the patcher stubs. + Emit a trap instruction and return the original machine code. *******************************************************************************/ -void emit_patcher_stubs(jitdata *jd) +uint32_t emit_trap(codegendata *cd) { - codegendata *cd; - patchref *pr; - u4 mcode[5]; - u1 *savedmcodeptr; - u1 *tmpmcodeptr; - s4 targetdisp; - s4 disp; - - /* get required compiler data */ - - cd = jd->cd; - - /* generate code patching stub call code */ - - targetdisp = 0; - -/* for (pr = list_first_unsynced(cd->patchrefs); pr != NULL; */ -/* pr = list_next_unsynced(cd->patchrefs, pr)) { */ - for (pr = cd->patchrefs; pr != NULL; pr = pr->next) { - /* check code segment size */ - - MCODECHECK(100); - - /* Get machine code which is patched back in later. The - call is 2 instruction words long. */ - - tmpmcodeptr = (u1 *) (cd->mcodebase + pr->branchpos); - - /* We use 2 loads here as an unaligned 8-byte read on 64-bit - MIPS causes a SIGSEGV and using the same code for both - architectures is much better. */ - - mcode[0] = ((u4 *) tmpmcodeptr)[0]; - mcode[1] = ((u4 *) tmpmcodeptr)[1]; - - mcode[2] = ((u4 *) tmpmcodeptr)[2]; - mcode[3] = ((u4 *) tmpmcodeptr)[3]; - mcode[4] = ((u4 *) tmpmcodeptr)[4]; - - /* Patch in the call to call the following code (done at - compile time). */ - - savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ - cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ - - disp = ((u4 *) savedmcodeptr) - (((u4 *) tmpmcodeptr) + 1); - -/* if ((disp < (s4) 0xffff8000) || (disp > (s4) 0x00007fff)) { */ - /* Recalculate the displacement to be relative to PV. */ - - disp = savedmcodeptr - cd->mcodebase; - - M_LUI(REG_ITMP3, disp >> 16); - M_OR_IMM(REG_ITMP3, disp, REG_ITMP3); - M_AADD(REG_PV, REG_ITMP3, REG_ITMP3); - M_JMP(REG_ITMP3); - M_NOP; -/* } */ -/* else { */ -/* M_BR(disp); */ -/* M_NOP; */ -/* M_NOP; */ -/* M_NOP; */ -/* M_NOP; */ -/* } */ - - cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ - - /* create stack frame */ - - M_ASUB_IMM(REG_SP, 8 * 8, REG_SP); + uint32_t mcode; - /* calculate return address and move it onto the stack */ + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ - M_LDA(REG_ITMP3, REG_PV, pr->branchpos); - M_AST(REG_ITMP3, REG_SP, 7 * 8); + mcode = *((u4 *) cd->mcodeptr); - /* move pointer to java_objectheader onto stack */ + M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); -#if defined(ENABLE_THREADS) - /* create a virtual java_objectheader */ - - (void) dseg_add_unique_address(cd, NULL); /* flcword */ - (void) dseg_add_unique_address(cd, lock_get_initial_lock_word()); - disp = dseg_add_unique_address(cd, NULL); /* vftbl */ - - M_LDA(REG_ITMP3, REG_PV, disp); - M_AST(REG_ITMP3, REG_SP, 6 * 8); -#else - /* do nothing */ -#endif - - /* move machine code onto stack */ - - disp = dseg_add_s4(cd, mcode[0]); - M_ILD(REG_ITMP3, REG_PV, disp); - M_IST(REG_ITMP3, REG_SP, 3 * 8 + 0); - - disp = dseg_add_s4(cd, mcode[1]); - M_ILD(REG_ITMP3, REG_PV, disp); - M_IST(REG_ITMP3, REG_SP, 3 * 8 + 4); - - disp = dseg_add_s4(cd, mcode[2]); - M_ILD(REG_ITMP3, REG_PV, disp); - M_IST(REG_ITMP3, REG_SP, 4 * 8 + 0); - - disp = dseg_add_s4(cd, mcode[3]); - M_ILD(REG_ITMP3, REG_PV, disp); - M_IST(REG_ITMP3, REG_SP, 4 * 8 + 4); - - disp = dseg_add_s4(cd, mcode[4]); - M_ILD(REG_ITMP3, REG_PV, disp); - M_IST(REG_ITMP3, REG_SP, 5 * 8 + 0); - - /* move class/method/field reference onto stack */ - - disp = dseg_add_address(cd, pr->ref); - M_ALD(REG_ITMP3, REG_PV, disp); - M_AST(REG_ITMP3, REG_SP, 2 * 8); - - /* move data segment displacement onto stack */ - - disp = dseg_add_s4(cd, pr->disp); - M_ILD(REG_ITMP3, REG_PV, disp); - M_IST(REG_ITMP3, REG_SP, 1 * 8); - - /* move patcher function pointer onto stack */ - - disp = dseg_add_functionptr(cd, pr->patcher); - M_ALD(REG_ITMP3, REG_PV, disp); - M_AST(REG_ITMP3, REG_SP, 0 * 8); - - if (targetdisp == 0) { - targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase); - - disp = dseg_add_functionptr(cd, asm_patcher_wrapper); - M_ALD(REG_ITMP3, REG_PV, disp); - M_JMP(REG_ITMP3); - M_NOP; - } - else { - disp = (((u4 *) cd->mcodebase) + targetdisp) - - (((u4 *) cd->mcodeptr) + 1); - - M_BR(disp); - M_NOP; - } - } + return mcode; } diff --git a/src/vm/jit/mips/irix/md-os.c b/src/vm/jit/mips/irix/md-os.c index 620177dd1..530e08398 100644 --- a/src/vm/jit/mips/irix/md-os.c +++ b/src/vm/jit/mips/irix/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $ + $Id: md-os.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -31,6 +31,7 @@ #include #include +#include #include #include "vm/types.h" @@ -40,7 +41,6 @@ #include "mm/gc-common.h" -#include "vm/exceptions.h" #include "vm/global.h" #include "vm/signallocal.h" #include "vm/stringlocal.h" @@ -85,21 +85,21 @@ void md_init(void) void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 d; - s4 s1; - s4 disp; - ptrint val; - ptrint addr; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + int d; + int s1; + int16_t disp; + intptr_t val; + intptr_t addr; + int type; + void *p; _uc = (struct ucontext *) _p; _mc = &_uc->uc_mcontext; @@ -130,7 +130,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) define is 0. */ addr = _mc->gregs[s1]; - type = (s4) addr; + type = (int) addr; val = 0; } @@ -138,19 +138,21 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - /* set registers */ + /* set registers (only if exception object ready) */ - _mc->gregs[REG_ITMP1_XPTR] = (ptrint) e; - _mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc; - _mc->gregs[CTX_EPC] = (ptrint) asm_handle_exception; + if (p != NULL) { + _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc; + _mc->gregs[CTX_EPC] = (intptr_t) asm_handle_exception; + } } diff --git a/src/vm/jit/mips/linux/md-os.c b/src/vm/jit/mips/linux/md-os.c index 1f05e83d7..0f403a69a 100644 --- a/src/vm/jit/mips/linux/md-os.c +++ b/src/vm/jit/mips/linux/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $ + $Id: md-os.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -32,6 +32,7 @@ #include #include /* required for _MIPS_SIM_ABI* defines (before signal.h) */ #include +#include #include #include "vm/types.h" @@ -41,8 +42,7 @@ #include "mm/gc-common.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" +#include "vm/signallocal.h" #include "vm/jit/asmpart.h" #include "vm/jit/stacktrace.h" @@ -85,23 +85,23 @@ void md_init(void) void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - greg_t *_gregs; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - unsigned int cause; - u4 mcode; - s4 d; - s4 s1; - s4 disp; - ptrint val; - ptrint addr; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + greg_t *_gregs; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + unsigned int cause; + u4 mcode; + int d; + int s1; + int16_t disp; + intptr_t val; + intptr_t addr; + int type; + void *p; _uc = (struct ucontext *) _p; _mc = &_uc->uc_mcontext; @@ -176,24 +176,33 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - /* set registers */ + /* set registers (only if exception object ready) */ - _gregs[REG_ITMP1_XPTR] = (ptrint) e; - _gregs[REG_ITMP2_XPC] = (ptrint) xpc; + if (p != NULL) { + _gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _gregs[REG_ITMP2_XPC] = (intptr_t) xpc; #if defined(__UCLIBC__) - _gregs[CTX_EPC] = (ptrint) asm_handle_exception; + _gregs[CTX_EPC] = (intptr_t) asm_handle_exception; #else - _mc->pc = (ptrint) asm_handle_exception; + _mc->pc = (intptr_t) asm_handle_exception; #endif + } + else { +#if defined(__UCLIBC__) + _gregs[CTX_EPC] = (intptr_t) xpc; +#else + _mc->pc = (intptr_t) xpc; +#endif + } } diff --git a/src/vm/jit/mips/md.c b/src/vm/jit/mips/md.c index 55e48dd47..03c50c82d 100644 --- a/src/vm/jit/mips/md.c +++ b/src/vm/jit/mips/md.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md.c 7596 2007-03-28 21:05:53Z twisti $ + $Id: md.c 8247 2007-07-31 12:06:44Z michi $ */ @@ -287,7 +287,6 @@ void md_dcacheflush(u1 *addr, s4 nbytes) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; union { u8 both; u4 words[2]; @@ -301,19 +300,9 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, /* save the current machine code */ *(u8*)(savedmcode) = *(u8*)(rp->pc); - /* make machine code for patching */ - - disp = ((u4*)code->replacementstubs - (u4*)rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 1; - - if ((disp < (s4) 0xffff8000) || (disp > (s4) 0x00007fff)) - vm_abort("Jump offset is out of range: %d > +/-%d", - disp, 0x00007fff); - - /* BR */ - mcode.words[0] = (((0x04) << 26) | ((0) << 21) | ((0) << 16) | ((disp) & 0xffff)); - mcode.words[1] = 0; /* NOP in delay slot */ + /* build the machine code for the patch */ + assert(0); /* XXX build trap instruction below */ + mcode.both = 0; /* write the new machine code */ *(u8*)(rp->pc) = mcode.both; diff --git a/src/vm/jit/mips/patcher.c b/src/vm/jit/mips/patcher.c index dfe1cc225..8ad124171 100644 --- a/src/vm/jit/mips/patcher.c +++ b/src/vm/jit/mips/patcher.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 7596 2007-03-28 21:05:53Z twisti $ + $Id: patcher.c 8268 2007-08-07 13:24:43Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -45,7 +46,7 @@ #include "vm/jit/asmpart.h" #include "vm/jit/md.h" -#include "vm/jit/patcher.h" +#include "vm/jit/patcher-common.h" #include "vmcore/class.h" #include "vmcore/field.h" @@ -54,97 +55,64 @@ #include "vmcore/references.h" -/* patcher_wrapper ************************************************************* +#define PATCH_BACK_ORIGINAL_MCODE \ + *((u4 *) pr->mpc) = (u4) pr->mcode; \ + md_icacheflush((u1 *) pr->mpc, PATCHER_CALL_SIZE); - Wrapper for all patchers. It also creates the stackframe info - structure. - If the return value of the patcher function is false, it gets the - exception object, clears the exception pointer and returns the - exception. +/* patcher_initialize_class **************************************************** + + Initalizes a given classinfo pointer. This function does not patch + any data. *******************************************************************************/ -java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) +bool patcher_initialize_class(patchref_t *pr) { - stackframeinfo sfi; - u1 *xpc; - java_objectheader *o; - u4 mcode[5]; - functionptr f; - bool result; - java_objectheader *e; - - /* define the patcher function */ - - bool (*patcher_function)(u1 *); - - assert(pv != NULL); + classinfo *c; /* get stuff from the stack */ - xpc = (u1 *) *((ptrint *) (sp + 7 * 8)); - o = (java_objectheader *) *((ptrint *) (sp + 6 * 8)); - f = (functionptr) *((ptrint *) (sp + 0 * 8)); - - /* store PV into the patcher function position */ - - *((ptrint *) (sp + 0 * 8)) = (ptrint) pv; - - /* cast the passed function to a patcher function */ - - patcher_function = (bool (*)(u1 *)) (ptrint) f; + c = (classinfo *) pr->ref; - /* enter a monitor on the patching position */ - - PATCHER_MONITORENTER; - - /* create the stackframeinfo */ - - stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 8 * 8, ra, xpc); - - /* call the proper patcher function */ - - result = (patcher_function)(sp); - - /* remove the stackframeinfo */ + /* check if the class is initialized */ - stacktrace_remove_stackframeinfo(&sfi); + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return false; - /* check for return value and exit accordingly */ + PATCH_BACK_ORIGINAL_MCODE; - if (result == false) { - e = exceptions_get_and_clear_exception(); + return true; +} - PATCHER_MONITOREXIT; - return e; - } +/* patcher_resolve_class ***************************************************** - /* patch back original code */ + Initalizes a given classinfo pointer. This function does not patch + any data. - mcode[0] = *((u4 *) (sp + 3 * 8 + 0)); - mcode[1] = *((u4 *) (sp + 3 * 8 + 4)); +*******************************************************************************/ - mcode[2] = *((u4 *) (sp + 4 * 8 + 0)); - mcode[3] = *((u4 *) (sp + 4 * 8 + 4)); - mcode[4] = *((u4 *) (sp + 5 * 8 + 0)); +#ifdef ENABLE_VERIFIER +bool patcher_resolve_class(patchref_t *pr) +{ + unresolved_class *uc; - *((u4 *) (xpc + 0 * 4)) = mcode[0]; - *((u4 *) (xpc + 1 * 4)) = mcode[1]; + /* get stuff from the stack */ - *((u4 *) (xpc + 2 * 4)) = mcode[2]; - *((u4 *) (xpc + 3 * 4)) = mcode[3]; - *((u4 *) (xpc + 4 * 4)) = mcode[4]; + uc = (unresolved_class *) pr->ref; - /* synchronize instruction cache */ + /* resolve the class and check subtype constraints */ - md_icacheflush(xpc, PATCHER_CALL_SIZE); + if (!resolve_class_eager_no_access_check(uc)) + return false; - PATCHER_MARK_PATCHED_MONITOREXIT; + PATCH_BACK_ORIGINAL_MCODE; - return NULL; + return true; } +#endif /* ENABLE_VERIFIER */ /* patcher_get_putstatic ******************************************************* @@ -157,18 +125,16 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) *******************************************************************************/ -bool patcher_get_putstatic(u1 *sp) +bool patcher_get_putstatic(patchref_t *pr) { unresolved_field *uf; - s4 disp; - u1 *pv; + u1 *datap; fieldinfo *fi; /* get stuff from the stack */ - uf = (unresolved_field *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); + uf = (unresolved_field *) pr->ref; + datap = (u1 *) pr->datap; /* get the fieldinfo */ @@ -181,13 +147,15 @@ bool patcher_get_putstatic(u1 *sp) if (!initialize_class(fi->class)) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* patch the field value's address */ - *((ptrint *) (pv + disp)) = (ptrint) &(fi->value); + *((intptr_t *) datap) = (intptr_t) fi->value; /* synchronize data cache */ - md_dcacheflush(pv + disp, SIZEOF_VOID_P); + md_dcacheflush(datap, SIZEOF_VOID_P); return true; } @@ -202,7 +170,7 @@ bool patcher_get_putstatic(u1 *sp) *******************************************************************************/ -bool patcher_get_putfield(u1 *sp) +bool patcher_get_putfield(patchref_t *pr) { u1 *ra; unresolved_field *uf; @@ -210,183 +178,220 @@ bool patcher_get_putfield(u1 *sp) /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 7 * 8)); - uf = (unresolved_field *) *((ptrint *) (sp + 2 * 8)); + ra = (u1 *) pr->mpc; + uf = (unresolved_field *) pr->ref; /* get the fieldinfo */ if (!(fi = resolve_field_eager(uf))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* if we show disassembly, we have to skip the nop's */ - if (opt_shownops) { + if (opt_shownops) ra = ra + PATCHER_CALL_SIZE; #if SIZEOF_VOID_P == 4 - if (IS_LNG_TYPE(fi->type)) { + if (IS_LNG_TYPE(fi->type)) { # if WORDS_BIGENDIAN == 1 - /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ - *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); - *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); + /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ + *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); + *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); # else - /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ - *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); - *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); + /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ + *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); + *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); # endif - } - else + } + else #endif - *((u4 *) (ra + 0 * 4)) |= (s2) (fi->offset & 0x0000ffff); + *((u4 *) (ra + 0 * 4)) |= (s2) (fi->offset & 0x0000ffff); - /* synchronize instruction cache */ + /* synchronize instruction cache */ - md_icacheflush(ra, 2 * 4); - } - else { -#if SIZEOF_VOID_P == 4 - if (IS_LNG_TYPE(fi->type)) { -# if WORDS_BIGENDIAN == 1 - /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ - *((u4 *) (sp + 3 * 8 + 0)) |= (s2) ((fi->offset + 0) & 0x0000ffff); - *((u4 *) (sp + 3 * 8 + 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); -# else - /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ - *((u4 *) (sp + 3 * 8 + 0)) |= (s2) ((fi->offset + 4) & 0x0000ffff); - *((u4 *) (sp + 3 * 8 + 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); -# endif - } - else -#endif - *((u4 *) (sp + 3 * 8 + 0)) |= (s2) (fi->offset & 0x0000ffff); - } + md_icacheflush(ra, 2 * 4); return true; } -/* patcher_aconst ************************************************************** +/* patcher_resolve_classref_to_classinfo *************************************** - Machine code: + ACONST: dfc4ff98 ld a0,-104(s8) + MULTIANEWARRAY: + + + dfc5ff90 ld a1,-112(s8) + 03a03025 move a2,sp + dfd9ff88 ld t9,-120(s8) + 0320f809 jalr t9 + 00000000 nop + + ARRAYCHECKCAST: + + + dfc5ffc0 ld a1,-64(s8) + dfd9ffb8 ld t9,-72(s8) + 0320f809 jalr t9 + 00000000 nop + *******************************************************************************/ -bool patcher_aconst(u1 *sp) +bool patcher_resolve_classref_to_classinfo(patchref_t *pr) { constant_classref *cr; - s4 disp; - u1 *pv; + u1 *datap; classinfo *c; /* get stuff from the stack */ - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); + cr = (constant_classref *) pr->ref; + datap = (u1 *) pr->datap; /* get the classinfo */ if (!(c = resolve_classref_eager(cr))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* patch the classinfo pointer */ - *((ptrint *) (pv + disp)) = (ptrint) c; + *((intptr_t *) datap) = (intptr_t) c; /* synchronize data cache */ - md_dcacheflush(pv + disp, SIZEOF_VOID_P); + md_dcacheflush(datap, SIZEOF_VOID_P); return true; } -/* patcher_builtin_multianewarray ********************************************** +/* patcher_resolve_classref_to_vftbl ******************************************* - Machine code: + CHECKCAST (class): + INSTANCEOF (class): - dfc5ff90 ld a1,-112(s8) - 03a03025 move a2,sp - dfd9ff88 ld t9,-120(s8) - 0320f809 jalr t9 - 00000000 nop + dd030000 ld v1,0(a4) + dfd9ff18 ld t9,-232(s8) *******************************************************************************/ -bool patcher_builtin_multianewarray(u1 *sp) +bool patcher_resolve_classref_to_vftbl(patchref_t *pr) { constant_classref *cr; - s4 disp; - u1 *pv; + u1 *datap; classinfo *c; /* get stuff from the stack */ - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); + cr = (constant_classref *) pr->ref; + datap = (u1 *) pr->datap; - /* get the classinfo */ + /* get the fieldinfo */ if (!(c = resolve_classref_eager(cr))) return false; - /* patch the classinfo pointer */ + PATCH_BACK_ORIGINAL_MCODE; + + /* patch super class' vftbl */ - *((ptrint *) (pv + disp)) = (ptrint) c; + *((intptr_t *) datap) = (intptr_t) c->vftbl; /* synchronize data cache */ - md_dcacheflush(pv + disp, SIZEOF_VOID_P); + md_dcacheflush(datap, SIZEOF_VOID_P); return true; } -/* patcher_builtin_arraycheckcast ********************************************** +/* patcher_resolve_classref_to_flags ******************************************* - Machine code: + CHECKCAST/INSTANCEOF: - dfc5ffc0 ld a1,-64(s8) - dfd9ffb8 ld t9,-72(s8) - 0320f809 jalr t9 + 8fc3ff24 lw v1,-220(s8) + 30630200 andi v1,v1,512 + 1060000d beq v1,zero,0x000000001051824c 00000000 nop *******************************************************************************/ -bool patcher_builtin_arraycheckcast(u1 *sp) +bool patcher_resolve_classref_to_flags(patchref_t *pr) { constant_classref *cr; - s4 disp; - u1 *pv; + u1 *datap; classinfo *c; /* get stuff from the stack */ - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); + cr = (constant_classref *) pr->ref; + datap = (u1 *) pr->datap; - /* get the classinfo */ + /* get the fieldinfo */ if (!(c = resolve_classref_eager(cr))) return false; - /* patch the classinfo pointer */ + PATCH_BACK_ORIGINAL_MCODE; + + /* patch class flags */ + + *((int32_t *) datap) = (int32_t) c->flags; + + /* synchronize data cache */ + + md_dcacheflush(datap, sizeof(int32_t)); + + return true; +} + + +/* patcher_resolve_native ****************************************************** + + XXX + +*******************************************************************************/ + +#if !defined(WITH_STATIC_CLASSPATH) +bool patcher_resolve_native_function(patchref_t *pr) +{ + methodinfo *m; + u1 *datap; + functionptr f; + + /* get stuff from the stack */ + + m = (methodinfo *) pr->ref; + datap = (u1 *) pr->datap; + + /* resolve native function */ + + if (!(f = native_resolve_function(m))) + return false; + + PATCH_BACK_ORIGINAL_MCODE; + + /* patch native function pointer */ - *((ptrint *) (pv + disp)) = (ptrint) c; + *((ptrint *) datap) = (ptrint) f; /* synchronize data cache */ - md_dcacheflush(pv + disp, SIZEOF_VOID_P); + md_dcacheflush(datap, SIZEOF_VOID_P); return true; } +#endif /* !defined(WITH_STATIC_CLASSPATH) */ /* patcher_invokestatic_special ************************************************ @@ -400,31 +405,31 @@ bool patcher_builtin_arraycheckcast(u1 *sp) ******************************************************************************/ -bool patcher_invokestatic_special(u1 *sp) +bool patcher_invokestatic_special(patchref_t *pr) { unresolved_method *um; - s4 disp; - u1 *pv; + u1 *datap; methodinfo *m; /* get stuff from the stack */ - um = (unresolved_method *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); + um = (unresolved_method *) pr->ref; + datap = (u1 *) pr->datap; /* get the fieldinfo */ if (!(m = resolve_method_eager(um))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* patch stubroutine */ - *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine; + *((ptrint *) datap) = (ptrint) m->stubroutine; /* synchronize data cache */ - md_dcacheflush(pv + disp, SIZEOF_VOID_P); + md_dcacheflush(datap, SIZEOF_VOID_P); return true; } @@ -442,7 +447,7 @@ bool patcher_invokestatic_special(u1 *sp) *******************************************************************************/ -bool patcher_invokevirtual(u1 *sp) +bool patcher_invokevirtual(patchref_t *pr) { u1 *ra; unresolved_method *um; @@ -450,36 +455,30 @@ bool patcher_invokevirtual(u1 *sp) /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 7 * 8)); - um = (unresolved_method *) *((ptrint *) (sp + 2 * 8)); + ra = (u1 *) pr->mpc; + um = (unresolved_method *) pr->ref; /* get the fieldinfo */ if (!(m = resolve_method_eager(um))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* if we show disassembly, we have to skip the nop's */ - if (opt_shownops) { + if (opt_shownops) ra = ra + PATCHER_CALL_SIZE; - /* patch vftbl index */ - - *((s4 *) (ra + 1 * 4)) |= - (s4) ((OFFSET(vftbl_t, table[0]) + - sizeof(methodptr) * m->vftblindex) & 0x0000ffff); + /* patch vftbl index */ - /* synchronize instruction cache */ + *((s4 *) (ra + 1 * 4)) |= + (s4) ((OFFSET(vftbl_t, table[0]) + + sizeof(methodptr) * m->vftblindex) & 0x0000ffff); - md_icacheflush(ra + 1 * 4, 1 * 4); - } - else { - /* patch vftbl index */ + /* synchronize instruction cache */ - *((s4 *) (sp + 3 * 8 + 4)) |= - (s4) ((OFFSET(vftbl_t, table[0]) + - sizeof(methodptr) * m->vftblindex) & 0x0000ffff); - } + md_icacheflush(ra + 1 * 4, 1 * 4); return true; } @@ -498,7 +497,7 @@ bool patcher_invokevirtual(u1 *sp) *******************************************************************************/ -bool patcher_invokeinterface(u1 *sp) +bool patcher_invokeinterface(patchref_t *pr) { u1 *ra; unresolved_method *um; @@ -506,88 +505,35 @@ bool patcher_invokeinterface(u1 *sp) /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 7 * 8)); - um = (unresolved_method *) *((ptrint *) (sp + 2 * 8)); + ra = (u1 *) pr->mpc; + um = (unresolved_method *) pr->ref; /* get the fieldinfo */ if (!(m = resolve_method_eager(um))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* if we show disassembly, we have to skip the nop's */ - if (opt_shownops) { + if (opt_shownops) ra = ra + PATCHER_CALL_SIZE; - /* patch interfacetable index */ - - *((s4 *) (ra + 1 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - sizeof(methodptr*) * m->class->index) & 0x0000ffff); - - /* patch method offset */ - - *((s4 *) (ra + 2 * 4)) |= - (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 2 * 4); - } - else { - /* patch interfacetable index */ - - *((s4 *) (sp + 3 * 8 + 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - sizeof(methodptr*) * m->class->index) & 0x0000ffff); - - /* patch method offset */ - - *((s4 *) (sp + 4 * 8 + 0)) |= - (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff); - } - - return true; -} - - -/* patcher_checkcast_instanceof_flags ****************************************** - - Machine code: - - - 8fc3ff24 lw v1,-220(s8) - 30630200 andi v1,v1,512 - 1060000d beq v1,zero,0x000000001051824c - 00000000 nop - -*******************************************************************************/ - -bool patcher_checkcast_instanceof_flags(u1 *sp) -{ - constant_classref *cr; - s4 disp; - u1 *pv; - classinfo *c; - - /* get stuff from the stack */ + /* patch interfacetable index */ - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); - - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) - return false; + *((s4 *) (ra + 1 * 4)) |= + (s4) ((OFFSET(vftbl_t, interfacetable[0]) - + sizeof(methodptr*) * m->class->index) & 0x0000ffff); - /* patch class flags */ + /* patch method offset */ - *((s4 *) (pv + disp)) = (s4) c->flags; + *((s4 *) (ra + 2 * 4)) |= + (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff); - /* synchronize data cache */ + /* synchronize instruction cache */ - md_dcacheflush(pv + disp, sizeof(s4)); + md_icacheflush(ra + 1 * 4, 2 * 4); return true; } @@ -607,7 +553,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp) *******************************************************************************/ -bool patcher_checkcast_interface(u1 *sp) +bool patcher_checkcast_interface(patchref_t *pr) { u1 *ra; constant_classref *cr; @@ -615,46 +561,33 @@ bool patcher_checkcast_interface(u1 *sp) /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 7 * 8)); - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); + ra = (u1 *) pr->mpc; + cr = (constant_classref *) pr->ref; /* get the fieldinfo */ if (!(c = resolve_classref_eager(cr))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* if we show disassembly, we have to skip the nop's */ - if (opt_shownops) { + if (opt_shownops) ra = ra + PATCHER_CALL_SIZE; - /* patch super class index */ - - *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); - /* *((s4 *) (ra + 5 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) - */ - /* c->index * sizeof(methodptr*)) & 0x0000ffff); */ - *((s4 *) (ra + 6 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)) & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 2 * 4, 5 * 4); - } - else { - /* patch super class index */ + /* patch super class index */ - *((s4 *) (sp + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); - /* *((s4 *) (ra + 5 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) - */ - /* c->index * sizeof(methodptr*)) & 0x0000ffff); */ - *((s4 *) (ra + 6 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)) & 0x0000ffff); + *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); + /* *((s4 *) (ra + 5 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) - */ + /* c->index * sizeof(methodptr*)) & 0x0000ffff); */ + *((s4 *) (ra + 6 * 4)) |= + (s4) ((OFFSET(vftbl_t, interfacetable[0]) - + c->index * sizeof(methodptr*)) & 0x0000ffff); - /* synchronize instruction cache */ + /* synchronize instruction cache */ - md_icacheflush(ra + 6 * 4, 1 * 4); - } + md_icacheflush(ra + 2 * 4, 5 * 4); return true; } @@ -674,7 +607,7 @@ bool patcher_checkcast_interface(u1 *sp) *******************************************************************************/ -bool patcher_instanceof_interface(u1 *sp) +bool patcher_instanceof_interface(patchref_t *pr) { u1 *ra; constant_classref *cr; @@ -682,174 +615,34 @@ bool patcher_instanceof_interface(u1 *sp) /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 7 * 8)); - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); + ra = (u1 *) pr->mpc; + cr = (constant_classref *) pr->ref; /* get the fieldinfo */ if (!(c = resolve_classref_eager(cr))) return false; + PATCH_BACK_ORIGINAL_MCODE; + /* if we show disassembly, we have to skip the nop's */ - if (opt_shownops) { + if (opt_shownops) ra = ra + PATCHER_CALL_SIZE; - /* patch super class index */ - - *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); - *((s4 *) (ra + 5 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)) & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 2 * 4, 4 * 4); - } - else { - /* patch super class index */ - - *((s4 *) (sp + 4 * 8 + 0)) |= (s4) (-(c->index) & 0x0000ffff); - *((s4 *) (ra + 5 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)) & 0x0000ffff); - - /* synchronize instruction cache */ + /* patch super class index */ - md_icacheflush(ra + 5 * 4, 1 * 4); - } - - return true; -} - - -/* patcher_checkcast_instanceof_class ****************************************** - - Machine code: - - - dd030000 ld v1,0(a4) - dfd9ff18 ld t9,-232(s8) - -*******************************************************************************/ - -bool patcher_checkcast_instanceof_class(u1 *sp) -{ - constant_classref *cr; - s4 disp; - u1 *pv; - classinfo *c; - - /* get stuff from the stack */ - - cr = (constant_classref *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); - - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) - return false; - - /* patch super class' vftbl */ - - *((ptrint *) (pv + disp)) = (ptrint) c->vftbl; - - /* synchronize data cache */ - - md_dcacheflush(pv + disp, SIZEOF_VOID_P); - - return true; -} + *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); + *((s4 *) (ra + 5 * 4)) |= + (s4) ((OFFSET(vftbl_t, interfacetable[0]) - + c->index * sizeof(methodptr*)) & 0x0000ffff); + /* synchronize instruction cache */ -/* patcher_clinit ************************************************************** - - No special machine code. - -*******************************************************************************/ - -bool patcher_clinit(u1 *sp) -{ - classinfo *c; - - /* get stuff from the stack */ - - c = (classinfo *) *((ptrint *) (sp + 2 * 8)); - - /* check if the class is initialized */ - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return false; - - return true; -} - - -/* patcher_athrow_areturn ****************************************************** - - Machine code: - - - -*******************************************************************************/ - -#ifdef ENABLE_VERIFIER -bool patcher_athrow_areturn(u1 *sp) -{ - unresolved_class *uc; - - /* get stuff from the stack */ - - uc = (unresolved_class *) *((ptrint *) (sp + 2 * 8)); - - /* resolve the class and check subtype constraints */ - - if (!resolve_class_eager_no_access_check(uc)) - return false; - - return true; -} -#endif /* ENABLE_VERIFIER */ - - -/* patcher_resolve_native ****************************************************** - - XXX - -*******************************************************************************/ - -#if !defined(WITH_STATIC_CLASSPATH) -bool patcher_resolve_native(u1 *sp) -{ - methodinfo *m; - s4 disp; - u1 *pv; - functionptr f; - - /* get stuff from the stack */ - - m = (methodinfo *) *((ptrint *) (sp + 2 * 8)); - disp = *((s4 *) (sp + 1 * 8)); - pv = (u1 *) *((ptrint *) (sp + 0 * 8)); - - /* resolve native function */ - - if (!(f = native_resolve_function(m))) - return false; - - /* patch native function pointer */ - - *((ptrint *) (pv + disp)) = (ptrint) f; - - /* synchronize data cache */ - - md_dcacheflush(pv + disp, SIZEOF_VOID_P); + md_icacheflush(ra + 2 * 4, 4 * 4); return true; } -#endif /* !defined(WITH_STATIC_CLASSPATH) */ /* diff --git a/src/vm/jit/optimizing/recompile.c b/src/vm/jit/optimizing/recompile.c index bca3ef36c..558236c20 100644 --- a/src/vm/jit/optimizing/recompile.c +++ b/src/vm/jit/optimizing/recompile.c @@ -55,8 +55,8 @@ /* global variables ***********************************************************/ -static java_objectheader *lock_thread_recompile; -static list_t *list_recompile_methods; +static java_object_t *lock_thread_recompile; +static list_t *list_recompile_methods; /* recompile_init ************************************************************** @@ -69,7 +69,7 @@ bool recompile_init(void) { /* initialize the recompile lock object */ - lock_thread_recompile = NEW(java_objectheader); + lock_thread_recompile = NEW(java_object_t); lock_init_object_lock(lock_thread_recompile); diff --git a/src/vm/jit/patcher.h b/src/vm/jit/patcher.h index b95db2f56..53181485e 100644 --- a/src/vm/jit/patcher.h +++ b/src/vm/jit/patcher.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.h 8216 2007-07-19 13:51:21Z michi $ + $Id: patcher.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -41,7 +41,7 @@ #include "vm/global.h" -#if defined(__ALPHA__) || defined(__ARM__) || defined(__POWERPC__) +#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__) # error "you should no longer include this file" #else @@ -93,7 +93,7 @@ /* function prototypes ********************************************************/ -java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra); +java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra); #define PATCHER_wrapper (functionptr) patcher_wrapper bool patcher_resolve_class(u1 *sp); diff --git a/src/vm/jit/powerpc/Makefile.am b/src/vm/jit/powerpc/Makefile.am index a24a5539f..0c3ae2687 100644 --- a/src/vm/jit/powerpc/Makefile.am +++ b/src/vm/jit/powerpc/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/powerpc/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: -## -## $Id: Makefile.am 5342 2006-09-05 21:17:54Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -44,15 +38,12 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h -noinst_LTLIBRARIES = libarch.la +noinst_LTLIBRARIES = \ + libarch.la if ENABLE_DISASSEMBLER DISASS_SOURCES = \ @@ -71,10 +62,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/powerpc/arch.h b/src/vm/jit/powerpc/arch.h index 8ff6cd1c4..77408218a 100644 --- a/src/vm/jit/powerpc/arch.h +++ b/src/vm/jit/powerpc/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $ + $Id: arch.h 8270 2007-08-08 13:57:12Z twisti $ */ @@ -92,9 +92,7 @@ #define SPECIALMEMUSE -#define HAS_4BYTE_STACKSLOT -#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 dbl*/ @@ -116,7 +114,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 4 /* bytes */ -#define REPLACEMENT_STUB_SIZE 6 /* words */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/powerpc/asmpart.S b/src/vm/jit/powerpc/asmpart.S index 2f2cdf49f..4a4cb27f1 100644 --- a/src/vm/jit/powerpc/asmpart.S +++ b/src/vm/jit/powerpc/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8216 2007-07-19 13:51:21Z michi $ + $Id: asmpart.S 8274 2007-08-08 15:58:17Z twisti $ */ @@ -34,7 +34,6 @@ #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" -#include "vm/jit/powerpc/offsets.h" .text @@ -70,9 +69,6 @@ .globl asm_compare_and_swap .globl asm_memory_barrier - .globl asm_criticalsections - .globl asm_getclassvalues_atomic - /* asm_vm_call_method ********************************************************** * * @@ -114,7 +110,7 @@ asm_vm_call_method_double: stwu sp,-40*4(sp) /* keep stack 16-byte aligned */ stw s0,8*4(sp) /* save used callee saved registers */ - stw a0,9*4(sp) /* save method pointer for compiler */ + stw a0,9*4(sp) /* save method PV */ #if defined(__DARWIN__) stw itmp1,10*4(sp) /* register r11 is callee saved */ @@ -141,248 +137,68 @@ asm_vm_call_method_double: stfd ft4,34*4(sp) stfd ft5,36*4(sp) #else - SAVE_TEMPORARY_REGISTERS(18) /* the offset has to be even */ -#endif - - mr itmp2,a1 /* arg count */ - mr itmp1,a2 /* pointer to arg block */ - - mr t4,itmp2 /* save argument count */ - mr t5,itmp1 /* save argument block pointer */ - - mr s0,sp /* save current sp to s0 */ - - addi itmp1,itmp1,-sizevmarg /* initialize pointer (smaller code) */ - addi itmp2,itmp2,1 /* initialize argument count */ - li t0,0 /* initialize integer argument counter */ - li t1,0 /* initialize float argument counter */ - li t6,0 /* initialize integer register counter */ -#if defined(__DARWIN__) - li t7,0 /* initialize stack slot counter */ -#endif - - mflr r0 /* save link register (PIC code) */ - bl L_asm_vm_call_method_get_pc -L_asm_vm_call_method_get_pc: - mflr t3 /* t3 contains the current pc */ - mtlr r0 - -L_register_copy: - addi itmp1,itmp1,sizevmarg /* goto next argument block */ - addi itmp2,itmp2,-1 /* argument count - 1 */ - mr. itmp2,itmp2 - beq L_register_copy_done - - lwz itmp3,offvmargtype+4(itmp1) - andi. r0,itmp3,0x0002 /* is this a float/double type? */ - bne L_register_handle_float - -L_register_handle_int: - cmpwi t6,INT_ARG_CNT /* are we out of integer argument */ - beq L_register_copy /* registers? yes, next loop */ - - andi. r0,itmp3,0x0001 /* is this a 2-word type? */ - bne L_register_handle_long - -#if defined(__DARWIN__) - addis itmp3,t3,ha16(L_jumptable_int - L_asm_vm_call_method_get_pc) - la itmp3,lo16(L_jumptable_int - L_asm_vm_call_method_get_pc)(itmp3) -#else - lis itmp3,L_jumptable_int@ha - addi itmp3,itmp3,L_jumptable_int@l + SAVE_TEMPORARY_REGISTERS(18) /* the offset has to be even */ #endif - slwi t2,t6,2 /* multiple of 4-bytes */ - add itmp3,itmp3,t2 /* calculate address of jumptable */ - lwz itmp3,0(itmp3) /* load function address */ - mtctr itmp3 - addi t0,t0,1 /* integer argument counter */ - addi t6,t6,1 /* integer argument register counter */ -#if defined(__DARWIN__) - addi t7,t7,1 /* stack slot counter */ -#endif - bctr + mr t0,a1 /* address of data structure */ + mr t1,a2 /* stack argument count */ + + mr s0,sp /* save SP */ + + lwz a0,0*8+4(t0) /* we are on big-endian */ + lwz a1,1*8+4(t0) + lwz a2,2*8+4(t0) + lwz a3,3*8+4(t0) + lwz a4,4*8+4(t0) + lwz a5,5*8+4(t0) + lwz a6,6*8+4(t0) + lwz a7,7*8+4(t0) + + lfd fa0,8*8(t0) + lfd fa1,9*8(t0) + lfd fa2,10*8(t0) + lfd fa3,11*8(t0) + lfd fa4,12*8(t0) + lfd fa5,13*8(t0) + lfd fa6,14*8(t0) + lfd fa7,15*8(t0) -L_register_handle_long: #if defined(__DARWIN__) - addis itmp3,t3,ha16(L_jumptable_long - L_asm_vm_call_method_get_pc) - la itmp3,lo16(L_jumptable_long - L_asm_vm_call_method_get_pc)(itmp3) -#else - lis itmp3,L_jumptable_long@ha - addi itmp3,itmp3,L_jumptable_long@l -#endif -#if !defined(__DARWIN__) - addi t6,t6,1 /* align to even numbers */ - andi. t6,t6,0xfffe + lfd fa8,16*8(t0) + lfd fa9,17*8(t0) + lfd fa10,18*8(t0) + lfd fa11,19*8(t0) + lfd fa12,20*8(t0) #endif - cmpwi t6,(INT_ARG_CNT - 1) /* are we out of integer argument */ - blt L_register_handle_long_continue /* registers? */ - - li t6,INT_ARG_CNT /* yes, set integer argument register */ - b L_register_copy /* count to max and next loop */ - -L_register_handle_long_continue: - slwi t2,t6,2 /* multiple of 4-bytes */ - add itmp3,itmp3,t2 /* calculate address of jumptable */ - lwz itmp3,0(itmp3) /* load function address */ - mtctr itmp3 - addi t0,t0,1 /* integer argument counter */ - addi t6,t6,2 /* integer argument register counter */ -#if defined(__DARWIN__) - addi t7,t7,2 /* stack slot counter */ -#endif - bctr - -L_register_handle_float: - cmpwi t1,FLT_ARG_CNT /* are we out of float argument */ - beq L_register_copy /* registers? yes, next loop */ + mr. t1,t1 + beq L_asm_vm_call_method_stack_copy_done - andi. r0,itmp3,0x0001 /* is this a 2-word type? */ - bne L_register_handle_double + slwi t2,t1,3 /* calculate stackframe size (* 8) */ -#if defined(__DARWIN__) - addis itmp3,t3,ha16(L_jumptable_float - L_asm_vm_call_method_get_pc) - la itmp3,lo16(L_jumptable_float - L_asm_vm_call_method_get_pc)(itmp3) -#else - lis itmp3,L_jumptable_float@ha - addi itmp3,itmp3,L_jumptable_float@l -#endif + sub sp,sp,t2 /* create stackframe */ + mr t2,sp /* temporary stack pointer */ - slwi t2,t1,2 /* multiple of 4-bytes */ - add itmp3,itmp3,t2 /* calculate address of jumptable */ - lwz itmp3,0(itmp3) /* load function address */ - mtctr itmp3 - addi t1,t1,1 /* float argument counter */ +L_asm_vm_call_method_stack_copy_loop: #if defined(__DARWIN__) - addi t7,t7,1 /* stack slot counter */ - addi t6,t6,1 /* skip 1 integer argument register */ -#endif - bctr - -L_register_handle_double: -#if defined(__DARWIN__) - addis itmp3,t3,ha16(L_jumptable_double - L_asm_vm_call_method_get_pc) - la itmp3,lo16(L_jumptable_double - L_asm_vm_call_method_get_pc)(itmp3) + lwz t3,21*8+0(t0) /* load argument */ + lwz t4,21*8+4(t0) #else - lis itmp3,L_jumptable_double@ha - addi itmp3,itmp3,L_jumptable_double@l -#endif - - slwi t2,t1,2 /* multiple of 4-bytes */ - add itmp3,itmp3,t2 /* calculate address of jumptable */ - lwz itmp3,0(itmp3) /* load function address */ - mtctr itmp3 - addi t1,t1,1 /* float argument counter */ -#if defined(__DARWIN__) - addi t7,t7,2 /* stack slot counter */ - addi t6,t6,2 /* skip 2 integer argument registers */ -#endif - bctr - -L_register_copy_done: - /* calculate remaining arguments */ - sub itmp3,t4,t0 /* - integer arguments in registers */ - sub itmp3,itmp3,t1 /* - float arguments in registers */ - mr. itmp3,itmp3 - beq L_stack_copy_done - - mr itmp2,t4 /* restore argument count */ - mr itmp1,t5 /* restore argument block pointer */ - - slwi t4,itmp3,3 /* XXX use 8-bytes slots for now */ - addi t4,t4,LA_SIZE /* add size of linkage area */ - -#if defined(__DARWIN__) - slwi t5,t7,2 /* add stack space for arguments */ - add t4,t4,t5 -#endif - - sub sp,sp,t4 - - mr t6,sp /* use t6 as temporary sp */ - addi t6,t6,LA_SIZE /* skip linkage area */ -#if defined(__DARWIN__) - add t6,t6,t5 /* skip stack space for arguments */ -#endif - - addi itmp1,itmp1,-sizevmarg /* initialize pointer (smaller code) */ - addi itmp2,itmp2,1 /* initialize argument count */ - -L_stack_copy_loop: - addi itmp1,itmp1,sizevmarg /* goto next argument block */ - addi itmp2,itmp2,-1 /* argument count - 1 */ - mr. itmp2,itmp2 - beq L_stack_copy_done - - lwz itmp3,offvmargtype+4(itmp1) - andi. r0,itmp3,0x0002 /* is this a float/double type? */ - bne L_stack_handle_float - -L_stack_handle_int: - addi t0,t0,-1 /* arguments assigned to registers */ - mr. t0,t0 - bge L_stack_copy_loop - - andi. r0,itmp3,0x0001 /* is this a 2-word type? */ - bne L_stack_handle_long - - lwz itmp3,offvmargdata+4(itmp1) /* get integer argument */ - stw itmp3,0(t6) /* and store it on the stack */ - addi t6,t6,4 /* increase temporary sp by 1 slot */ - b L_stack_copy_loop - -L_stack_handle_long: -#if !defined(__DARWIN__) - addi t6,t6,4 /* align stack to 8-bytes */ - rlwinm t6,t6,0,30,28 /* clear lower 4-bits */ + lwz t3,16*8+0(t0) /* load argument */ + lwz t4,16*8+4(t0) #endif + stw t3,0(t2) /* store argument on stack */ + stw t4,4(t2) - lwz itmp3,offvmargdata+0(itmp1) /* get long argument */ - stw itmp3,0(t6) /* and store it on the stack */ - lwz itmp3,offvmargdata+4(itmp1) - stw itmp3,4(t6) - addi t6,t6,8 /* increase temporary sp by 2 slots */ - b L_stack_copy_loop - -L_stack_handle_float: - addi t1,t1,-1 /* arguments assigned to registers */ + addi t0,t0,8 /* load address of next argument */ + addi t2,t2,8 /* increase stack pointer */ + addi t1,t1,-1 /* subtract 1 argument */ mr. t1,t1 - bge L_stack_copy_loop - - andi. r0,itmp3,0x0001 /* is this a 2-word type? */ - bne L_stack_handle_double - - lfs ftmp3,offvmargdata(itmp1) /* get float argument */ - stfs ftmp3,0(t6) /* and store it on the stack */ - addi t6,t6,4 /* increase temporary sp by 1 slot */ - b L_stack_copy_loop - -L_stack_handle_double: -#if !defined(__DARWIN__) - addi t6,t6,4 /* align stack to 8-bytes */ - rlwinm t6,t6,0,30,28 /* clear lower 4-bits */ -#endif + bgt L_asm_vm_call_method_stack_copy_loop - lfd ftmp3,offvmargdata(itmp1) /* get double argument */ - stfd ftmp3,0(t6) /* and store it on the stack */ - addi t6,t6,8 /* increase temporary sp by 2 slots */ - b L_stack_copy_loop - -L_stack_copy_done: - lwz itmp1,9*4(s0) /* pass method pointer via tmp1 */ - -#if defined(__DARWIN__) - addis mptr,t3,ha16(L_asm_call_jit_compiler - L_asm_vm_call_method_get_pc) - la mptr,lo16(L_asm_call_jit_compiler - L_asm_vm_call_method_get_pc)(mptr) -#else - lis mptr,L_asm_call_jit_compiler@ha - addi mptr,mptr,L_asm_call_jit_compiler@l -#endif - stw mptr,7*4(s0) - addi mptr,s0,7*4 - - lwz pv,0*4(mptr) +L_asm_vm_call_method_stack_copy_done: + addi mptr,s0,9*4 /* get address of PV */ + lwz pv,0*4(mptr) /* load PV */ mtctr pv bctrl 1: @@ -394,17 +210,17 @@ L_stack_copy_done: #endif L_asm_vm_call_method_return: - mr sp,s0 /* restore the function's sp */ + mr sp,s0 /* restore the SP */ - lwz s0,8*4(sp) /* restore used callee saved registers */ + lwz s0,8*4(sp) /* restore used callee saved registers*/ #if defined(__DARWIN__) - lwz itmp1,10*4(sp) /* register r11 is callee saved */ + lwz itmp1,10*4(sp) /* register r11 is callee saved */ #endif - lwz pv,11*4(sp) /* save PV register */ + lwz pv,11*4(sp) /* save PV register */ lwz itmp3,12*4(sp) - lfd ftmp1,14*4(sp) /* registers f14-f31 are callee saved */ + lfd ftmp1,14*4(sp) /* registers f14-f31 are callee saved */ lfd ftmp2,16*4(sp) #if defined(__DARWIN__) @@ -436,251 +252,10 @@ asm_vm_call_method_exception_handler: bl builtin_throw_exception b L_asm_vm_call_method_return - - .data - .align 2 - -L_jumptable_int: - .long L_handle_a0 - .long L_handle_a1 - .long L_handle_a2 - .long L_handle_a3 - .long L_handle_a4 - .long L_handle_a5 - .long L_handle_a6 - .long L_handle_a7 - - .text - .align 2 - -L_handle_a0: - lwz a0,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a1: - lwz a1,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a2: - lwz a2,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a3: - lwz a3,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a4: - lwz a4,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a5: - lwz a5,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a6: - lwz a6,offvmargdata+4(itmp1) - b L_register_copy -L_handle_a7: - lwz a7,offvmargdata+4(itmp1) - b L_register_copy - - - .data - .align 2 - -L_jumptable_long: -#if defined(__DARWIN__) - .long L_handle_a0_a1 - .long L_handle_a1_a2 - .long L_handle_a2_a3 - .long L_handle_a3_a4 - .long L_handle_a4_a5 - .long L_handle_a5_a6 - .long L_handle_a6_a7 -#else - /* we have two entries here, so we get the even argument register - alignment for linux */ - - .long L_handle_a0_a1 - .long 0 - .long L_handle_a2_a3 - .long 0 - .long L_handle_a4_a5 - .long 0 - .long L_handle_a6_a7 -#endif - - .text - .align 2 - -L_handle_a0_a1: - lwz a0,offvmargdata+0(itmp1) - lwz a1,offvmargdata+4(itmp1) - b L_register_copy -#if defined(__DARWIN__) -L_handle_a1_a2: - lwz a1,offvmargdata+0(itmp1) - lwz a2,offvmargdata+4(itmp1) - b L_register_copy -#endif -L_handle_a2_a3: - lwz a2,offvmargdata+0(itmp1) - lwz a3,offvmargdata+4(itmp1) - b L_register_copy -#if defined(__DARWIN__) -L_handle_a3_a4: - lwz a3,offvmargdata+0(itmp1) - lwz a4,offvmargdata+4(itmp1) - b L_register_copy -#endif -L_handle_a4_a5: - lwz a4,offvmargdata+0(itmp1) - lwz a5,offvmargdata+4(itmp1) - b L_register_copy -#if defined(__DARWIN__) -L_handle_a5_a6: - lwz a5,offvmargdata+0(itmp1) - lwz a6,offvmargdata+4(itmp1) - b L_register_copy -#endif -L_handle_a6_a7: - lwz a6,offvmargdata+0(itmp1) - lwz a7,offvmargdata+4(itmp1) - b L_register_copy - - - .data - .align 2 - -L_jumptable_float: - .long L_handle_fa0 - .long L_handle_fa1 - .long L_handle_fa2 - .long L_handle_fa3 - .long L_handle_fa4 - .long L_handle_fa5 - .long L_handle_fa6 - .long L_handle_fa7 - -#if defined(__DARWIN__) - .long L_handle_fa8 - .long L_handle_fa9 - .long L_handle_fa10 - .long L_handle_fa11 - .long L_handle_fa12 -#endif - - .text - .align 2 - -L_handle_fa0: - lfs fa0,offvmargdata(itmp1) - b L_register_copy -L_handle_fa1: - lfs fa1,offvmargdata(itmp1) - b L_register_copy -L_handle_fa2: - lfs fa2,offvmargdata(itmp1) - b L_register_copy -L_handle_fa3: - lfs fa3,offvmargdata(itmp1) - b L_register_copy -L_handle_fa4: - lfs fa4,offvmargdata(itmp1) - b L_register_copy -L_handle_fa5: - lfs fa5,offvmargdata(itmp1) - b L_register_copy -L_handle_fa6: - lfs fa6,offvmargdata(itmp1) - b L_register_copy -L_handle_fa7: - lfs fa7,offvmargdata(itmp1) - b L_register_copy - -#if defined(__DARWIN__) -L_handle_fa8: - lfs fa8,offvmargdata(itmp1) - b L_register_copy -L_handle_fa9: - lfs fa9,offvmargdata(itmp1) - b L_register_copy -L_handle_fa10: - lfs fa10,offvmargdata(itmp1) - b L_register_copy -L_handle_fa11: - lfs fa11,offvmargdata(itmp1) - b L_register_copy -L_handle_fa12: - lfs fa12,offvmargdata(itmp1) - b L_register_copy -#endif - - - .data - .align 2 - -L_jumptable_double: - .long L_handle_fda0 - .long L_handle_fda1 - .long L_handle_fda2 - .long L_handle_fda3 - .long L_handle_fda4 - .long L_handle_fda5 - .long L_handle_fda6 - .long L_handle_fda7 - -#if defined(__DARWIN__) - .long L_handle_fda8 - .long L_handle_fda9 - .long L_handle_fda10 - .long L_handle_fda11 - .long L_handle_fda12 -#endif - - .text - .align 2 - -L_handle_fda0: - lfd fa0,offvmargdata(itmp1) - b L_register_copy -L_handle_fda1: - lfd fa1,offvmargdata(itmp1) - b L_register_copy -L_handle_fda2: - lfd fa2,offvmargdata(itmp1) - b L_register_copy -L_handle_fda3: - lfd fa3,offvmargdata(itmp1) - b L_register_copy -L_handle_fda4: - lfd fa4,offvmargdata(itmp1) - b L_register_copy -L_handle_fda5: - lfd fa5,offvmargdata(itmp1) - b L_register_copy -L_handle_fda6: - lfd fa6,offvmargdata(itmp1) - b L_register_copy -L_handle_fda7: - lfd fa7,offvmargdata(itmp1) - b L_register_copy - -#if defined(__DARWIN__) -L_handle_fda8: - lfd fa8,offvmargdata(itmp1) - b L_register_copy -L_handle_fda9: - lfd fa9,offvmargdata(itmp1) - b L_register_copy -L_handle_fda10: - lfd fa10,offvmargdata(itmp1) - b L_register_copy -L_handle_fda11: - lfd fa11,offvmargdata(itmp1) - b L_register_copy -L_handle_fda12: - lfd fa12,offvmargdata(itmp1) - b L_register_copy -#endif - asm_vm_call_method_end: nop + /* asm_call_jit_compiler ******************************************************* Invokes the compiler for untranslated JavaVM methods. @@ -907,16 +482,16 @@ ex_int1: mtctr t3 bctr - lwz s0,-10*4(t1) - lwz s1,-9*4(t1) - lwz s2,-8*4(t1) - lwz s3,-7*4(t1) - lwz s4,-6*4(t1) - lwz s5,-5*4(t1) - lwz s6,-4*4(t1) - lwz s7,-3*4(t1) - lwz s8,-2*4(t1) - lwz s9,-1*4(t1) + lwz s0,-10*8(t1) + lwz s1,-9*8(t1) + lwz s2,-8*8(t1) + lwz s3,-7*8(t1) + lwz s4,-6*8(t1) + lwz s5,-5*8(t1) + lwz s6,-4*8(t1) + lwz s7,-3*8(t1) + lwz s8,-2*8(t1) + lwz s9,-1*8(t1) ex_int2: subf t1,t2,t1 /* t1 = t1 - register count * 4 */ @@ -1280,29 +855,6 @@ asm_memory_barrier: blr -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: - lwz a3,offbaseval(a0) - lwz a4,offdiffval(a0) - lwz a5,offbaseval(a1) -_crit_end: - stw a3,offcast_super_baseval(a2) - stw a4,offcast_super_diffval(a2) - stw a5,offcast_sub_baseval(a2) - blr - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .long _crit_begin - .long _crit_end - .long _crit_restart -#endif - .long 0 - - #if defined(__DARWIN__) .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 diff --git a/src/vm/jit/powerpc/codegen.c b/src/vm/jit/powerpc/codegen.c index 8602d35db..fda9c1bd3 100644 --- a/src/vm/jit/powerpc/codegen.c +++ b/src/vm/jit/powerpc/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $ + $Id: codegen.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -42,6 +42,7 @@ #include "mm/memory.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -128,7 +129,7 @@ bool codegen_emit(jitdata *jd) /* space to save used callee saved registers */ savedregs_num += (INT_SAV_CNT - rd->savintreguse); - savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2; + savedregs_num += (FLT_SAV_CNT - rd->savfltreguse); cd->stackframesize = rd->memuse + savedregs_num; @@ -138,15 +139,8 @@ bool codegen_emit(jitdata *jd) not be shared with place to save the return register on PPC, since both values reside in R3. */ - if (checksync && (m->flags & ACC_SYNCHRONIZED)) { - /* reserve 2 slots for long/double return values for monitorexit */ - - if (IS_2_WORD_TYPE(m->parseddesc->returntype.type)) - cd->stackframesize += 3; - else - cd->stackframesize += 2; - } - + if (checksync && (m->flags & ACC_SYNCHRONIZED)) + cd->stackframesize += 2; #endif /* create method header */ @@ -154,13 +148,13 @@ bool codegen_emit(jitdata *jd) /* align stack to 16-bytes */ if (!jd->isleafmethod || JITDATA_HAS_FLAG_VERBOSECALL(jd)) - cd->stackframesize = (cd->stackframesize + 3) & ~3; + ALIGN_2(cd->stackframesize); else if (jd->isleafmethod && (cd->stackframesize == LA_SIZE_IN_POINTERS)) cd->stackframesize = 0; (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 * 8); /* FrameSize */ #if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the @@ -170,7 +164,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 + 1) * 8);/* IsSync */ else #endif (void) dseg_add_unique_s4(cd, 0); /* IsSync */ @@ -215,16 +209,16 @@ bool codegen_emit(jitdata *jd) } if (cd->stackframesize) - M_STWU(REG_SP, REG_SP, -(cd->stackframesize * 4)); + M_STWU(REG_SP, REG_SP, -(cd->stackframesize * 8)); /* save return address and 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--; M_IST(rd->savintregs[i], REG_SP, p * 8); } for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) { - p -= 2; M_DST(rd->savfltregs[i], REG_SP, p * 4); + p--; M_DST(rd->savfltregs[i], REG_SP, p * 8); } /* take arguments out of register or stack frame */ @@ -263,21 +257,21 @@ bool codegen_emit(jitdata *jd) else { if (!IS_INMEMORY(var->flags)) { if (IS_2_WORD_TYPE(t)) - M_LLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1); + M_LLD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); else - M_ILD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1); + M_ILD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); } else { #if 1 - M_ILD(REG_ITMP1, REG_SP, cd->stackframesize * 4 + s1); + M_ILD(REG_ITMP1, REG_SP, cd->stackframesize * 8 + s1); 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); + M_ILD(REG_ITMP1, REG_SP, cd->stackframesize * 8 + s1 + 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; + var->vv.regoff = cd->stackframesize * 8 + s1; #endif } } @@ -286,33 +280,19 @@ bool codegen_emit(jitdata *jd) if (!md->params[p].inmemory) { if (!IS_INMEMORY(var->flags)) M_FLTMOVE(s1, var->vv.regoff); - else { - if (IS_2_WORD_TYPE(t)) - M_DST(s1, REG_SP, var->vv.regoff); - else - M_FST(s1, REG_SP, var->vv.regoff); - } + else + M_DST(s1, REG_SP, var->vv.regoff); } else { - if (!IS_INMEMORY(var->flags)) { - if (IS_2_WORD_TYPE(t)) - M_DLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1); - else - M_FLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1); - } + if (!IS_INMEMORY(var->flags)) + M_DLD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); else { #if 1 - if (IS_2_WORD_TYPE(t)) { - M_DLD(REG_FTMP1, REG_SP, cd->stackframesize * 4 + s1); - M_DST(REG_FTMP1, REG_SP, var->vv.regoff); - } - else { - M_FLD(REG_FTMP1, REG_SP, cd->stackframesize * 4 + s1); - M_FST(REG_FTMP1, REG_SP, var->vv.regoff); - } + M_DLD(REG_FTMP1, REG_SP, cd->stackframesize * 8 + s1); + M_DST(REG_FTMP1, REG_SP, var->vv.regoff); #else /* Reuse Memory Position on Caller Stack */ - var->vv.regoff = cd->stackframesize * 4 + s1; + var->vv.regoff = cd->stackframesize * 8 + s1; #endif } } @@ -337,10 +317,7 @@ bool codegen_emit(jitdata *jd) for (p = 0; p < FLT_ARG_CNT; p++) M_DST(abi_registers_float_argument[p], REG_SP, LA_SIZE + (INT_ARG_CNT + p) * 8); - /* ATTENTION: We multiply here with 2, because we use * 8 - above for simplicity and below * 4! */ - - s1 += (LA_SIZE_IN_POINTERS + ARG_CNT) * 2; + s1 += LA_SIZE_IN_POINTERS + ARG_CNT; } # endif @@ -360,7 +337,7 @@ bool codegen_emit(jitdata *jd) M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER); } - M_AST(REG_A0, REG_SP, s1 * 4); + M_AST(REG_A0, REG_SP, s1 * 8); M_JSR; # if !defined(NDEBUG) @@ -1644,7 +1621,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) patcher_add_patch_ref(jd, PATCHER_initialize_class, @@ -1690,7 +1667,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) patcher_add_patch_ref(jd, PATCHER_initialize_class, @@ -2213,38 +2190,34 @@ nowperformreturn: switch (iptr->opc) { case ICMD_LRETURN: - M_IST(REG_RESULT2, REG_SP, rd->memuse * 4 + 8); + M_IST(REG_RESULT2, REG_SP, rd->memuse * 8 + 8); /* fall through */ 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 + 4); break; case ICMD_FRETURN: - M_FST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); - break; case ICMD_DRETURN: - M_DST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); + M_DST(REG_FRESULT, REG_SP, rd->memuse * 8 + 4); break; } - M_ALD(REG_A0, REG_SP, rd->memuse * 4); + M_ALD(REG_A0, REG_SP, rd->memuse * 8); M_JSR; /* and now restore the proper return value */ switch (iptr->opc) { case ICMD_LRETURN: - M_ILD(REG_RESULT2, REG_SP, rd->memuse * 4 + 8); + M_ILD(REG_RESULT2, REG_SP, rd->memuse * 8 + 8); /* fall through */ 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 + 4); break; case ICMD_FRETURN: - M_FLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); - break; case ICMD_DRETURN: - M_DLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); + M_DLD(REG_FRESULT, REG_SP, rd->memuse * 8 + 4); break; } } @@ -2256,23 +2229,23 @@ nowperformreturn: /* ATTENTION: Don't use REG_ZERO (r0) here, as M_ALD may have a displacement overflow. */ - M_ALD(REG_ITMP1, REG_SP, p * 4 + LA_LR_OFFSET); + M_ALD(REG_ITMP1, REG_SP, p * 8 + LA_LR_OFFSET); M_MTLR(REG_ITMP1); } /* restore saved registers */ for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) { - p--; M_ILD(rd->savintregs[i], REG_SP, p * 4); + p--; M_ILD(rd->savintregs[i], REG_SP, p * 8); } for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) { - p -= 2; M_DLD(rd->savfltregs[i], REG_SP, p * 4); + p--; M_DLD(rd->savfltregs[i], REG_SP, p * 8); } /* deallocate stack */ if (cd->stackframesize) - M_LDA(REG_SP, REG_SP, cd->stackframesize * 4); + M_LDA(REG_SP, REG_SP, cd->stackframesize * 8); M_RET; ALIGNCODENOP; @@ -2428,10 +2401,7 @@ gen_method: } else { s1 = emit_load(jd, iptr, var, REG_FTMP1); - if (IS_2_WORD_TYPE(var->type)) - M_DST(s1, REG_SP, d); - else - M_FST(s1, REG_SP, d); + M_DST(s1, REG_SP, d); } } } @@ -2492,7 +2462,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); /* generate the actual call */ @@ -2520,7 +2490,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV, REG_METHODPTR, s2); @@ -2613,7 +2583,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_LDATST(REG_ITMP3, REG_ITMP3, -superindex); emit_classcast_check(cd, iptr, BRANCH_LE, REG_ITMP3, s1); @@ -2649,7 +2619,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); CODEGEN_CRITICAL_SECTION_START; @@ -2773,7 +2743,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); M_LDATST(REG_ITMP3, REG_ITMP3, -superindex); M_BLE(4); @@ -2809,7 +2779,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; @@ -2995,7 +2965,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* 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 * 8); /* FrameSize */ (void) dseg_add_unique_s4(cd, 0); /* IsSync */ (void) dseg_add_unique_s4(cd, 0); /* IsLeaf */ (void) dseg_add_unique_s4(cd, 0); /* IntSave */ @@ -3007,7 +2977,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) M_MFLR(REG_ZERO); M_AST_INTERN(REG_ZERO, REG_SP, LA_LR_OFFSET); - M_STWU(REG_SP, REG_SP, -(cd->stackframesize * 4)); + M_STWU(REG_SP, REG_SP, -(cd->stackframesize * 8)); /* get function address (this must happen before the stackframeinfo) */ @@ -3057,10 +3027,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* create native stack info */ - M_AADD_IMM(REG_SP, cd->stackframesize * 4, REG_A0); + M_AADD_IMM(REG_SP, cd->stackframesize * 8, REG_A0); M_MOV(REG_PV, REG_A1); - M_AADD_IMM(REG_SP, cd->stackframesize * 4, REG_A2); - M_ALD(REG_A3, REG_SP, cd->stackframesize * 4 + LA_LR_OFFSET); + M_AADD_IMM(REG_SP, cd->stackframesize * 8, REG_A2); + M_ALD(REG_A3, REG_SP, cd->stackframesize * 8 + LA_LR_OFFSET); disp = dseg_add_functionptr(cd, codegen_start_native_call); M_ALD(REG_ITMP1, REG_PV, disp); M_MTCTR(REG_ITMP1); @@ -3112,7 +3082,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) } } else { - s1 = md->params[i].regoff + cd->stackframesize * 4; + s1 = md->params[i].regoff + cd->stackframesize * 8; s2 = nmd->params[j].regoff; M_ILD(REG_ITMP1, REG_SP, s1); @@ -3129,17 +3099,15 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) argument registers keep unchanged. */ if (md->params[i].inmemory) { - s1 = md->params[i].regoff + cd->stackframesize * 4; + s1 = md->params[i].regoff + cd->stackframesize * 8; s2 = nmd->params[j].regoff; - if (IS_2_WORD_TYPE(t)) { - M_DLD(REG_FTMP1, REG_SP, s1); + M_DLD(REG_FTMP1, REG_SP, s1); + + if (IS_2_WORD_TYPE(t)) M_DST(REG_FTMP1, REG_SP, s2); - } - else { - M_FLD(REG_FTMP1, REG_SP, s1); + else M_FST(REG_FTMP1, REG_SP, s2); - } } } } @@ -3171,16 +3139,14 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) switch (md->returntype.type) { case TYPE_INT: case TYPE_ADR: - M_IST(REG_RESULT, REG_SP, LA_SIZE + 1 * 4); + M_IST(REG_RESULT, REG_SP, LA_SIZE + 1 * 8); break; case TYPE_LNG: - M_LST(REG_RESULT_PACKED, REG_SP, LA_SIZE + 1 * 4); + M_LST(REG_RESULT_PACKED, REG_SP, LA_SIZE + 1 * 8); break; case TYPE_FLT: - M_FST(REG_FRESULT, REG_SP, LA_SIZE + 1 * 4); - break; case TYPE_DBL: - M_DST(REG_FRESULT, REG_SP, LA_SIZE + 1 * 4); + M_DST(REG_FRESULT, REG_SP, LA_SIZE + 1 * 8); break; case TYPE_VOID: break; @@ -3188,7 +3154,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* remove native stackframe info */ - M_AADD_IMM(REG_SP, cd->stackframesize * 4, REG_A0); + M_AADD_IMM(REG_SP, cd->stackframesize * 8, REG_A0); disp = dseg_add_functionptr(cd, codegen_finish_native_call); M_ALD(REG_ITMP1, REG_PV, disp); M_MTCTR(REG_ITMP1); @@ -3200,16 +3166,14 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) switch (md->returntype.type) { case TYPE_INT: case TYPE_ADR: - M_ILD(REG_RESULT, REG_SP, LA_SIZE + 1 * 4); + M_ILD(REG_RESULT, REG_SP, LA_SIZE + 1 * 8); break; case TYPE_LNG: - M_LLD(REG_RESULT_PACKED, REG_SP, LA_SIZE + 1 * 4); + M_LLD(REG_RESULT_PACKED, REG_SP, LA_SIZE + 1 * 8); break; case TYPE_FLT: - M_FLD(REG_FRESULT, REG_SP, LA_SIZE + 1 * 4); - break; case TYPE_DBL: - M_DLD(REG_FRESULT, REG_SP, LA_SIZE + 1 * 4); + M_DLD(REG_FRESULT, REG_SP, LA_SIZE + 1 * 8); break; case TYPE_VOID: break; @@ -3226,9 +3190,9 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) M_ALD(abi_registers_integer_saved[i], REG_SP, disp + i * 4); #endif - M_ALD(REG_ITMP2_XPC, REG_SP, cd->stackframesize * 4 + LA_LR_OFFSET); + M_ALD(REG_ITMP2_XPC, REG_SP, cd->stackframesize * 8 + LA_LR_OFFSET); M_MTLR(REG_ITMP2_XPC); - M_LDA(REG_SP, REG_SP, cd->stackframesize * 4); /* remove stackframe */ + M_LDA(REG_SP, REG_SP, cd->stackframesize * 8); /* remove stackframe */ /* check for exception */ diff --git a/src/vm/jit/powerpc/darwin/md-abi.c b/src/vm/jit/powerpc/darwin/md-abi.c index 548622a67..74a3ea914 100644 --- a/src/vm/jit/powerpc/darwin/md-abi.c +++ b/src/vm/jit/powerpc/darwin/md-abi.c @@ -22,13 +22,14 @@ 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 8270 2007-08-08 13:57:12Z twisti $ */ #include "config.h" -#include "vm/types.h" + +#include #include "vm/jit/powerpc/darwin/md-abi.h" @@ -41,7 +42,7 @@ /* register descripton arrays *************************************************/ -s4 nregdescint[] = { +int nregdescint[] = { /* zero, sp, t0, a0/v0, a0/v1, a2, a3, a4, */ REG_RES, REG_RES, REG_TMP, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, @@ -64,7 +65,7 @@ const char *abi_registers_integer_name[] = { "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", }; -const s4 abi_registers_integer_argument[] = { +const int abi_registers_integer_argument[] = { 3, /* a0 */ 4, /* a1 */ 5, /* a2 */ @@ -75,7 +76,7 @@ const s4 abi_registers_integer_argument[] = { 10, /* a7 */ }; -const s4 abi_registers_integer_saved[] = { +const int abi_registers_integer_saved[] = { 14, /* s0 */ 15, /* s1 */ 24, /* s2 */ @@ -88,7 +89,7 @@ const s4 abi_registers_integer_saved[] = { 31, /* s9 */ }; -const s4 abi_registers_integer_temporary[] = { +const int abi_registers_integer_temporary[] = { 2, /* t0 */ 17, /* t1 */ 18, /* t2 */ @@ -100,7 +101,7 @@ const s4 abi_registers_integer_temporary[] = { }; -s4 nregdescfloat[] = { +int nregdescfloat[] = { /*ftmp3, fa0/v0, fa1, fa2, fa3, fa4, fa5, fa6, */ REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, @@ -116,7 +117,7 @@ s4 nregdescfloat[] = { REG_END }; -const s4 abi_registers_float_argument[] = { +const int abi_registers_float_argument[] = { 1, /* fa0 */ 2, /* fa1 */ 3, /* fa2 */ @@ -132,7 +133,7 @@ const s4 abi_registers_float_argument[] = { 13, /* fa12 */ }; -const s4 abi_registers_float_saved[] = { +const int abi_registers_float_saved[] = { 14, /* fs0 */ 15, /* fs1 */ 24, /* fs2 */ @@ -145,7 +146,7 @@ const s4 abi_registers_float_saved[] = { 31, /* fs9 */ }; -const s4 abi_registers_float_temporary[] = { +const int abi_registers_float_temporary[] = { 17, /* ft5 */ 18, /* ft6 */ 19, /* ft7 */ @@ -176,10 +177,110 @@ const s4 abi_registers_float_temporary[] = { void md_param_alloc(methoddesc *md) { paramdesc *pd; - s4 i; - s4 iarg; - s4 farg; - s4 stacksize; + int i; + int iarg; + int farg; + int stacksize; + + /* set default values */ + + iarg = 0; + farg = 0; + stacksize = LA_SIZE_IN_POINTERS; + + /* get params field of methoddesc */ + + pd = md->params; + + for (i = 0; i < md->paramcount; i++, pd++) { + switch (md->paramtypes[i].type) { + case TYPE_INT: + case TYPE_ADR: + if (iarg < INT_ARG_CNT) { + pd->inmemory = false; + pd->index = iarg; + pd->regoff = abi_registers_integer_argument[iarg]; + iarg++; + } + else { + pd->inmemory = true; + pd->index = stacksize; + pd->regoff = stacksize * 8; + stacksize++; + } + break; + + case TYPE_LNG: + if (iarg < INT_ARG_CNT - 1) { + pd->inmemory = false; + pd->index = PACK_REGS(iarg + 1, iarg); + pd->regoff = + PACK_REGS(abi_registers_integer_argument[iarg + 1], + abi_registers_integer_argument[iarg]); + iarg += 2; + } + else { + pd->inmemory = true; + pd->index = stacksize; + pd->regoff = stacksize * 8; + iarg = INT_ARG_CNT; + stacksize++; + } + break; + + case TYPE_FLT: + case TYPE_DBL: + if (farg < FLT_ARG_CNT) { + pd->inmemory = false; + pd->index = farg; + pd->regoff = abi_registers_float_argument[farg]; + farg++; + } + else { + pd->inmemory = true; + pd->index = stacksize; + pd->regoff = stacksize * 8; + stacksize++; + } + break; + } + } + + + /* Since R3/R4, F1 (==A0/A1, A0) are used for passing return values, this */ + /* argument register usage has to be regarded, too */ + + if (IS_INT_LNG_TYPE(md->returntype.type)) { + if (iarg < (IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1)) + iarg = IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1; + } + else { + if (IS_FLT_DBL_TYPE(md->returntype.type)) + if (farg < 1) + farg = 1; + } + + /* fill register and stack usage */ + + md->argintreguse = iarg; + md->argfltreguse = farg; + md->memuse = stacksize; +} + + +/* md_param_alloc_native ******************************************************* + + Pre-allocate arguments according the native ABI. + +*******************************************************************************/ + +void md_param_alloc_native(methoddesc *md) +{ + paramdesc *pd; + int i; + int iarg; + int farg; + int stacksize; /* set default values */ @@ -275,21 +376,6 @@ void md_param_alloc(methoddesc *md) } -/* md_param_alloc_native ******************************************************* - - Pre-allocate arguments according the native ABI. - -*******************************************************************************/ - -void md_param_alloc_native(methoddesc *md) -{ - /* On PowerPC we use the same ABI for JIT method calls as for - native method calls. */ - - md_param_alloc(md); -} - - /* md_return_alloc ************************************************************* Precolor the Java Stackelement containing the Return Value, if diff --git a/src/vm/jit/powerpc/darwin/md-asm.h b/src/vm/jit/powerpc/darwin/md-asm.h index ea5f8b44d..3e469acac 100644 --- a/src/vm/jit/powerpc/darwin/md-asm.h +++ b/src/vm/jit/powerpc/darwin/md-asm.h @@ -28,7 +28,7 @@ Changes: - $Id: md-asm.h 7621 2007-04-01 16:18:16Z stefan $ + $Id: md-asm.h 8274 2007-08-08 15:58:17Z twisti $ */ @@ -246,9 +246,6 @@ #define asm_cacheflush _asm_cacheflush -#define asm_criticalsections _asm_criticalsections -#define asm_getclassvalues_atomic _asm_getclassvalues_atomic - /* external defines ***********************************************************/ diff --git a/src/vm/jit/powerpc/darwin/md-os.c b/src/vm/jit/powerpc/darwin/md-os.c index 258180df7..b2bc5c433 100644 --- a/src/vm/jit/powerpc/darwin/md-os.c +++ b/src/vm/jit/powerpc/darwin/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8243 2007-07-31 08:57:54Z michi $ + $Id: md-os.c 8283 2007-08-09 15:10:05Z twisti $ */ @@ -31,6 +31,7 @@ #include #include +#include #include #include "vm/types.h" @@ -70,13 +71,13 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) u1 *ra; u1 *xpc; u4 mcode; - s4 s1; - s4 disp; - s4 d; - ptrint addr; - ptrint val; - s4 type; - java_objectheader *e; + int s1; + int16_t disp; + int d; + intptr_t addr; + intptr_t val; + int type; + void *p; _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; @@ -125,9 +126,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -135,10 +136,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers (only if exception object ready) */ - if (e != NULL) { - _ss->r11 = (ptrint) e; - _ss->r12 = (ptrint) xpc; - _ss->srr0 = (ptrint) asm_handle_exception; + if (p != NULL) { + _ss->r11 = (intptr_t) p; + _ss->r12 = (intptr_t) xpc; + _ss->srr0 = (intptr_t) asm_handle_exception; } } @@ -161,10 +162,10 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p) u1 *ra; u1 *xpc; u4 mcode; - s4 s1; - ptrint val; - s4 type; - java_objectheader *e; + int s1; + intptr_t val; + int type; + void *p; _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; @@ -196,9 +197,9 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -206,9 +207,9 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _ss->r11 = (ptrint) e; - _ss->r12 = (ptrint) xpc; - _ss->srr0 = (ptrint) asm_handle_exception; + _ss->r11 = (intptr_t) p; + _ss->r12 = (intptr_t) xpc; + _ss->srr0 = (intptr_t) asm_handle_exception; } diff --git a/src/vm/jit/powerpc/emit.c b/src/vm/jit/powerpc/emit.c index 5a86e5cec..d74b1dc99 100644 --- a/src/vm/jit/powerpc/emit.c +++ b/src/vm/jit/powerpc/emit.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 8216 2007-07-19 13:51:21Z michi $ + $Id: emit.c 8270 2007-08-08 13:57:12Z twisti $ */ @@ -51,7 +51,6 @@ #include "vm/jit/dseg.h" #include "vm/jit/emit-common.h" #include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" #include "vm/jit/replace.h" #include "vmcore/options.h" @@ -87,8 +86,6 @@ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) M_LLD(tempreg, REG_SP, disp); break; case TYPE_FLT: - M_FLD(tempreg, REG_SP, disp); - break; case TYPE_DBL: M_DLD(tempreg, REG_SP, disp); break; @@ -202,8 +199,6 @@ void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d) M_LST(d, REG_SP, disp); break; case TYPE_FLT: - M_FST(d, REG_SP, disp); - break; case TYPE_DBL: M_DST(d, REG_SP, disp); break; @@ -507,46 +502,24 @@ void emit_exception_check(codegendata *cd, instruction *iptr) } -/* emit_patcher_traps ********************************************************** +/* emit_trap ******************************************************************* - Generates the code for the patcher stubs. + Emit a trap instruction and return the original machine code. *******************************************************************************/ -void emit_patcher_traps(jitdata *jd) +uint32_t emit_trap(codegendata *cd) { - codegendata *cd; - codeinfo *code; - patchref_t *pr; - u1 *savedmcodeptr; - u1 *tmpmcodeptr; - - /* get required compiler data */ - - cd = jd->cd; - code = jd->code; + uint32_t mcode; - /* generate code patching stub call code */ + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ - for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) { + mcode = *((u4 *) cd->mcodeptr); - /* Get machine code which is patched back in later. The - trap is 1 instruction word long. */ + M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); - tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc); - - pr->mcode = *((u4 *) tmpmcodeptr); - - /* Patch in the trap to call the signal handler (done at - compile time). */ - - savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ - cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ - - M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); - - cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ - } + return mcode; } diff --git a/src/vm/jit/powerpc/linux/md-abi.c b/src/vm/jit/powerpc/linux/md-abi.c index 5554fea24..bb5bb932d 100644 --- a/src/vm/jit/powerpc/linux/md-abi.c +++ b/src/vm/jit/powerpc/linux/md-abi.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-abi.c 8190 2007-07-08 13:42:06Z twisti $ + $Id: md-abi.c 8270 2007-08-08 13:57:12Z twisti $ */ @@ -43,7 +43,7 @@ /* register descripton arrays *************************************************/ -int32_t nregdescint[] = { +int nregdescint[] = { /* zero, sp, NO(sys), a0/v0, a1/v1, a2, a3, a4, */ REG_RES, REG_RES, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, @@ -66,7 +66,7 @@ const char *abi_registers_integer_name[] = { "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", }; -const int32_t abi_registers_integer_argument[] = { +const int abi_registers_integer_argument[] = { 3, /* a0 */ 4, /* a1 */ 5, /* a2 */ @@ -77,7 +77,7 @@ const int32_t abi_registers_integer_argument[] = { 10, /* a7 */ }; -const int32_t abi_registers_integer_saved[] = { +const int abi_registers_integer_saved[] = { 14, /* s0 */ 15, /* s1 */ 24, /* s2 */ @@ -90,7 +90,7 @@ const int32_t abi_registers_integer_saved[] = { 31, /* s9 */ }; -const int32_t abi_registers_integer_temporary[] = { +const int abi_registers_integer_temporary[] = { 17, /* t0 */ 18, /* t1 */ 19, /* t2 */ @@ -101,7 +101,7 @@ const int32_t abi_registers_integer_temporary[] = { }; -int32_t nregdescfloat[] = { +int nregdescfloat[] = { /*ftmp3, fa0/v0, fa1, fa2, fa3, fa4, fa5, fa6, */ REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, @@ -118,7 +118,7 @@ int32_t nregdescfloat[] = { }; -const int32_t abi_registers_float_argument[] = { +const int abi_registers_float_argument[] = { 1, /* fa0 */ 2, /* fa1 */ 3, /* fa2 */ @@ -129,7 +129,7 @@ const int32_t abi_registers_float_argument[] = { 8, /* fa7 */ }; -const int32_t abi_registers_float_saved[] = { +const int abi_registers_float_saved[] = { 14, /* fs0 */ 15, /* fs1 */ 24, /* fs2 */ @@ -142,7 +142,7 @@ const int32_t abi_registers_float_saved[] = { 31, /* fs9 */ }; -const int32_t abi_registers_float_temporary[] = { +const int abi_registers_float_temporary[] = { 9, /* ft0 */ 10, /* ft1 */ 11, /* ft2 */ @@ -177,10 +177,114 @@ const int32_t abi_registers_float_temporary[] = { void md_param_alloc(methoddesc *md) { paramdesc *pd; - int32_t i; - int32_t iarg; - int32_t farg; - int32_t stacksize; + int i; + int iarg; + int farg; + int stacksize; + + /* set default values */ + + iarg = 0; + farg = 0; + stacksize = LA_SIZE_IN_POINTERS; + + /* get params field of methoddesc */ + + pd = md->params; + + for (i = 0; i < md->paramcount; i++, pd++) { + switch (md->paramtypes[i].type) { + case TYPE_INT: + case TYPE_ADR: + if (iarg < INT_ARG_CNT) { + pd->inmemory = false; + pd->index = iarg; + pd->regoff = abi_registers_integer_argument[iarg]; + iarg++; + } + else { + pd->inmemory = true; + pd->index = stacksize; + pd->regoff = stacksize * 8; + stacksize++; + } + break; + + case TYPE_LNG: + if (iarg < INT_ARG_CNT - 1) { + ALIGN_2(iarg); + pd->inmemory = false; + pd->index = PACK_REGS(iarg + 1, iarg); + pd->regoff = + PACK_REGS(abi_registers_integer_argument[iarg + 1], + abi_registers_integer_argument[iarg]); + iarg += 2; + } + else { + pd->inmemory = true; + pd->index = stacksize; + pd->regoff = stacksize * 8; + iarg = INT_ARG_CNT; + stacksize++; + } + break; + + case TYPE_FLT: + case TYPE_DBL: + if (farg < FLT_ARG_CNT) { + pd->inmemory = false; + pd->index = farg; + pd->regoff = abi_registers_float_argument[farg]; + farg++; + } + else { + pd->inmemory = true; + pd->index = stacksize; + pd->regoff = stacksize * 8; + stacksize++; + } + break; + + default: + assert(0); + } + } + + /* Since R3/R4, F1 (==A0/A1, A0) are used for passing return + values, this argument register usage has to be regarded, + too. */ + + if (IS_INT_LNG_TYPE(md->returntype.type)) { + if (iarg < (IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1)) + iarg = IS_2_WORD_TYPE(md->returntype.type) ? 2 : 1; + } + else { + if (IS_FLT_DBL_TYPE(md->returntype.type)) + if (farg < 1) + farg = 1; + } + + /* fill register and stack usage */ + + md->argintreguse = iarg; + md->argfltreguse = farg; + md->memuse = stacksize; +} + + +/* md_param_alloc_native ******************************************************* + + Pre-allocate arguments according the native ABI. + +*******************************************************************************/ + +void md_param_alloc_native(methoddesc *md) +{ + paramdesc *pd; + int i; + int iarg; + int farg; + int stacksize; /* set default values */ @@ -280,21 +384,6 @@ void md_param_alloc(methoddesc *md) } -/* md_param_alloc_native ******************************************************* - - Pre-allocate arguments according the native ABI. - -*******************************************************************************/ - -void md_param_alloc_native(methoddesc *md) -{ - /* On PowerPC we use the same ABI for JIT method calls as for - native method calls. */ - - md_param_alloc(md); -} - - /* md_return_alloc ************************************************************* Precolor the Java Stackelement containing the Return Value, if diff --git a/src/vm/jit/powerpc/linux/md-os.c b/src/vm/jit/powerpc/linux/md-os.c index 737439741..ce41acbcf 100644 --- a/src/vm/jit/powerpc/linux/md-os.c +++ b/src/vm/jit/powerpc/linux/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8243 2007-07-31 08:57:54Z michi $ + $Id: md-os.c 8283 2007-08-09 15:10:05Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -61,22 +62,22 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - unsigned long *_gregs; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 s1; - s4 disp; - s4 d; - ptrint addr; - ptrint val; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + unsigned long *_gregs; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + int s1; + int16_t disp; + int d; + intptr_t addr; + intptr_t val; + int type; + void *p; _uc = (ucontext_t *) _p; @@ -125,9 +126,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -135,10 +136,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers (only if exception object ready) */ - if (e != NULL) { - _gregs[REG_ITMP1_XPTR] = (ptrint) e; - _gregs[REG_ITMP2_XPC] = (ptrint) xpc; - _gregs[PT_NIP] = (ptrint) asm_handle_exception; + if (p != NULL) { + _gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _gregs[REG_ITMP2_XPC] = (intptr_t) xpc; + _gregs[PT_NIP] = (intptr_t) asm_handle_exception; } } @@ -151,19 +152,19 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - unsigned long *_gregs; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 s1; - ptrint val; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + unsigned long *_gregs; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + int s1; + intptr_t val; + int type; + void *p; _uc = (ucontext_t *) _p; @@ -195,9 +196,9 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -205,9 +206,9 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _gregs[REG_ITMP1_XPTR] = (ptrint) e; - _gregs[REG_ITMP2_XPC] = (ptrint) xpc; - _gregs[PT_NIP] = (ptrint) asm_handle_exception; + _gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _gregs[REG_ITMP2_XPC] = (intptr_t) xpc; + _gregs[PT_NIP] = (intptr_t) asm_handle_exception; } diff --git a/src/vm/jit/powerpc/md.c b/src/vm/jit/powerpc/md.c index 3e0ec2e7f..c9263fe3b 100644 --- a/src/vm/jit/powerpc/md.c +++ b/src/vm/jit/powerpc/md.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md.c 7968 2007-05-25 15:05:04Z twisti $ + $Id: md.c 8247 2007-07-31 12:06:44Z michi $ */ @@ -284,7 +284,6 @@ void md_dcacheflush(u1 *addr, s4 nbytes) #if defined(ENABLE_REPLACEMENT) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; u4 mcode; if (index < 0) { @@ -296,11 +295,8 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save *(u4*)(savedmcode) = *(u4*)(rp->pc); /* build the machine code for the patch */ - disp = ((u4*)code->replacementstubs - (u4*)rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 1; - - mcode = (18 << 26) | ((((disp) * 4) + 4) & M_BMASK); + assert(0); /* XXX build trap instruction below */ + mcode = 0; /* write the new machine code */ *(u4*)(rp->pc) = (u4) mcode; diff --git a/src/vm/jit/powerpc/patcher.c b/src/vm/jit/powerpc/patcher.c index 105f7a583..2bdbf42aa 100644 --- a/src/vm/jit/powerpc/patcher.c +++ b/src/vm/jit/powerpc/patcher.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 8216 2007-07-19 13:51:21Z michi $ + $Id: patcher.c 8286 2007-08-10 10:46:17Z michi $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -337,7 +338,7 @@ bool patcher_get_putstatic(patchref_t *pr) /* patch the field value's address */ - *((ptrint *) datap) = (ptrint) &(fi->value); + *((intptr_t *) datap) = (intptr_t) fi->value; /* synchronize data cache */ @@ -389,11 +390,13 @@ bool patcher_get_putfield(patchref_t *pr) disp = *((u4 *) (ra + 0 * 4)); if (disp == 4) { + *((u4 *) (ra + 0 * 4)) &= 0xffff0000; *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); } else { *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); + *((u4 *) (ra + 1 * 4)) &= 0xffff0000; *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); } } diff --git a/src/vm/jit/powerpc64/Makefile.am b/src/vm/jit/powerpc64/Makefile.am index 42773ac3e..cb078b60f 100644 --- a/src/vm/jit/powerpc64/Makefile.am +++ b/src/vm/jit/powerpc64/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/powerpc64/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: -## -## $Id: Makefile.am 5162 2006-07-19 13:07:00Z tbfg $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -42,10 +36,6 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h @@ -69,10 +59,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/powerpc64/arch.h b/src/vm/jit/powerpc64/arch.h index a545e244b..a2ad0086b 100644 --- a/src/vm/jit/powerpc64/arch.h +++ b/src/vm/jit/powerpc64/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $ + $Id: arch.h 8247 2007-07-31 12:06:44Z michi $ */ @@ -104,7 +104,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 4 /* bytes */ -#define REPLACEMENT_STUB_SIZE 6 /* words */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/powerpc64/asmpart.S b/src/vm/jit/powerpc64/asmpart.S index 89d2606ad..919623fef 100644 --- a/src/vm/jit/powerpc64/asmpart.S +++ b/src/vm/jit/powerpc64/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8123 2007-06-20 23:50:55Z michi $ + $Id: asmpart.S 8274 2007-08-08 15:58:17Z twisti $ */ @@ -36,7 +36,7 @@ #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" -#include "vm/jit/powerpc64/offsets.h" + /* export functions ***********************************************************/ @@ -58,8 +58,7 @@ #endif .globl asm_cacheflush - .globl asm_criticalsections - .globl asm_getclassvalues_atomic + /* asm_vm_call_method ********************************************************** * * @@ -793,39 +792,6 @@ asm_cacheflush: isync blr -/* - asm_getclassvalues_atomic -*/ - .section ".opd","aw" - .align 3 -asm_getclassvalues_atomic: - .quad .asm_getclassvalues_atomic,.TOC.@tocbase,0 - .previous - .size asm_getclassvalues_atomic, 24 - .type .asm_getclassvalues_atomic,@function - .globl .asm_getclassvalues_atomic -.asm_getclassvalues_atomic: - -_crit_restart: -_crit_begin: - lwz r6,offbaseval(r3) - lwz r7,offdiffval(r3) - lwz r8,offbaseval(r4) -_crit_end: - stw r6,offcast_super_baseval(r5) - stw r7,offcast_super_diffval(r5) - stw r8,offcast_sub_baseval(r5) - blr - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .quad _crit_begin - .quad _crit_end - .quad _crit_restart -#endif - .quad 0 /* disable exec-stacks ********************************************************/ diff --git a/src/vm/jit/powerpc64/codegen.c b/src/vm/jit/powerpc64/codegen.c index 01919a281..a723753fb 100644 --- a/src/vm/jit/powerpc64/codegen.c +++ b/src/vm/jit/powerpc64/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8211 2007-07-18 19:52:23Z michi $ + $Id: codegen.c 8297 2007-08-12 00:02:48Z michi $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include @@ -42,6 +43,7 @@ #include "mm/memory.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -1574,7 +1576,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp); @@ -1621,7 +1623,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp); @@ -2229,7 +2231,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); /* generate the actual call */ @@ -2257,7 +2259,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV, REG_METHODPTR, s2); @@ -2357,7 +2359,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_LDATST(REG_ITMP3, REG_ITMP3, -superindex); emit_classcast_check(cd, iptr, BRANCH_LE, REG_ITMP3, s1); @@ -2390,7 +2392,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); CODEGEN_CRITICAL_SECTION_START; @@ -2530,7 +2532,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); M_LDATST(REG_ITMP3, REG_ITMP3, -superindex); M_BLE(4); @@ -2566,7 +2568,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; diff --git a/src/vm/jit/powerpc64/emit.c b/src/vm/jit/powerpc64/emit.c index c5c6c7ded..b18d5c521 100644 --- a/src/vm/jit/powerpc64/emit.c +++ b/src/vm/jit/powerpc64/emit.c @@ -757,16 +757,37 @@ void emit_patcher_stubs(jitdata *jd) } +/* emit_trap ******************************************************************* + + Emit a trap instruction and return the original machine code. + +*******************************************************************************/ + +uint32_t emit_trap(codegendata *cd) +{ + uint32_t mcode; + + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ + + mcode = *((uint32_t *) cd->mcodeptr); + + M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); + + return mcode; +} + + /* -* These are local overrides for various environment variables in Emacs. -* Please do not remove this and leave it at the end of the file, where -* Emacs will automagically detect them. -* --------------------------------------------------------------------- -* Local variables: -* mode: c -* indent-tabs-mode: t -* c-basic-offset: 4 -* tab-width: 4 -* End: -* vim:noexpandtab:sw=4:ts=4: -*/ + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/powerpc64/linux/md-os.c b/src/vm/jit/powerpc64/linux/md-os.c index db2a9d5a2..98c2c2bbd 100644 --- a/src/vm/jit/powerpc64/linux/md-os.c +++ b/src/vm/jit/powerpc64/linux/md-os.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md-os.c 8243 2007-07-31 08:57:54Z michi $ + $Id: md-os.c 8283 2007-08-09 15:10:05Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -61,32 +62,34 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 s1; - s4 disp; - s4 d; - s4 type; - ptrint addr; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + int s1; + int16_t disp; + int d; + int type; + intptr_t addr; + intptr_t val; + void *p; _uc = (ucontext_t *) _p; _mc = &(_uc->uc_mcontext); /* get register values */ + pv = (u1*) _mc->gp_regs[REG_PV]; sp = (u1*) _mc->gp_regs[REG_SP]; ra = (u1*) _mc->gp_regs[PT_LNK]; /* correct for leafs */ xpc =(u1*) _mc->gp_regs[PT_NIP]; /* get the throwing instruction */ + mcode = *((u4*)xpc); s1 = M_INSTR_OP2_IMM_A(mcode); @@ -95,10 +98,11 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) val = _mc->gp_regs[d]; - if (s1 == REG_ZERO) { + if (s1 == REG_ZERO) { /* we use the exception type as load displacement */ type = disp; - } else { + } + else { /* normal NPE */ addr = _mc->gp_regs[s1]; type = (s4) addr; @@ -108,17 +112,17 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gp_regs[REG_ITMP1] = (ptrint) e; - _mc->gp_regs[REG_ITMP2_XPC] = (ptrint) xpc; - _mc->gp_regs[PT_NIP] = (ptrint) asm_handle_exception; + _mc->gp_regs[REG_ITMP1] = (intptr_t) p; + _mc->gp_regs[REG_ITMP2_XPC] = (intptr_t) xpc; + _mc->gp_regs[PT_NIP] = (intptr_t) asm_handle_exception; } diff --git a/src/vm/jit/powerpc64/md.c b/src/vm/jit/powerpc64/md.c index 21bbd31da..e07b3532a 100644 --- a/src/vm/jit/powerpc64/md.c +++ b/src/vm/jit/powerpc64/md.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md.c 7980 2007-05-30 16:01:09Z twisti $ + $Id: md.c 8247 2007-07-31 12:06:44Z michi $ */ @@ -330,7 +330,6 @@ void md_dcacheflush(u1 *addr, s4 nbytes) #if defined(ENABLE_REPLACEMENT) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; u4 mcode; if (index < 0) { @@ -342,11 +341,8 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save *(u4*)(savedmcode) = *(u4*)(rp->pc); /* build the machine code for the patch */ - disp = ((u4*)code->replacementstubs - (u4*)rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 1; - - mcode = (18 << 26) | ((((disp) * 4) + 4) & M_BMASK); + assert(0); /* XXX build trap instruction below */ + mcode = 0; /* write the new machine code */ *(u4*)(rp->pc) = (u4) mcode; diff --git a/src/vm/jit/powerpc64/patcher.c b/src/vm/jit/powerpc64/patcher.c index dce048b35..aecd6bb81 100644 --- a/src/vm/jit/powerpc64/patcher.c +++ b/src/vm/jit/powerpc64/patcher.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 7909 2007-05-15 10:32:16Z tbfg $ + $Id: patcher.c 8268 2007-08-07 13:24:43Z twisti $ */ @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -174,7 +175,7 @@ bool patcher_get_putstatic(u1 *sp) /* patch the field value's address */ - *((ptrint *) (pv + disp)) = (ptrint) &(fi->value); + *((intptr_t *) (pv + disp)) = (intptr_t) fi->value; /* synchronize data cache */ diff --git a/src/vm/jit/replace.c b/src/vm/jit/replace.c index be4d2b8fd..f7b8d678d 100644 --- a/src/vm/jit/replace.c +++ b/src/vm/jit/replace.c @@ -1054,15 +1054,15 @@ static void replace_write_value(executionstate_t *es, } -/* replace_read_executionstate ************************************************* +/* replace_new_sourceframe ***************************************************** - Read the given executions state and translate it to a source frame. + Allocate a new source frame and insert it at the front of the frame list. IN: ss...............the source state OUT: - ss->frames.......set to new frame + ss->frames.......set to new frame (the new head of the frame list). RETURN VALUE: returns the new frame @@ -1085,15 +1085,20 @@ static sourceframe_t *replace_new_sourceframe(sourcestate_t *ss) /* replace_read_executionstate ************************************************* - Read the given executions state and translate it to a source frame. + Read a source frame from the given executions state. + The new source frame is pushed to the front of the frame list of the + source state. IN: rp...............replacement point at which `es` was taken es...............execution state - ss...............where to put the source state + ss...............the source state to add the source frame to + topframe.........true, if the first (top-most) source frame on the + stack is to be read OUT: - *ss..............the source state derived from the execution state + *ss..............the source state with the newly created source frame + added *******************************************************************************/ @@ -1316,13 +1321,16 @@ static void replace_read_executionstate(rplpoint *rp, /* replace_write_executionstate ************************************************ - Translate the given source state into an execution state. - + Pop a source frame from the front of the frame list of the given source state + and write its values into the execution state. + IN: rp...............replacement point for which execution state should be - creates - es...............where to put the execution state + created + es...............the execution state to modify ss...............the given source state + topframe.........true, if this is the last (top-most) source frame to be + translated OUT: *es..............the execution state derived from the source state @@ -1786,15 +1794,15 @@ void replace_patch_future_calls(u1 *ra, sourceframe_t *callerframe, sourceframe_t *calleeframe) { - u1 *patchpos; - methodptr entrypoint; - methodptr oldentrypoint; - bool atentry; - stackframeinfo sfi; - codeinfo *calleecode; - methodinfo *calleem; - java_objectheader *obj; - vftbl_t *vftbl; + u1 *patchpos; + methodptr entrypoint; + methodptr oldentrypoint; + bool atentry; + stackframeinfo sfi; + codeinfo *calleecode; + methodinfo *calleem; + java_object_t *obj; + vftbl_t *vftbl; assert(ra); assert(callerframe->down == calleeframe); @@ -3011,7 +3019,7 @@ void replace_me(rplpoint *rp, executionstate_t *es) /* call the assembler code for the last phase of replacement */ #if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__) || defined(__S390__)) && defined(ENABLE_JIT) - asm_replacement_in(&(safestack->es), safestack); + /*asm_replacement_in(&(safestack->es), safestack);*/ #endif abort(); /* NOT REACHED */ @@ -3395,8 +3403,8 @@ void replace_executionstate_println(executionstate_t *es) #if !defined(NDEBUG) static void java_value_print(s4 type, replace_val_t value) { - java_objectheader *obj; - utf *u; + java_object_t *obj; + utf *u; printf("%016llx",(unsigned long long) value.l); diff --git a/src/vm/jit/replace.h b/src/vm/jit/replace.h index 2175d6040..e3f99ecab 100644 --- a/src/vm/jit/replace.h +++ b/src/vm/jit/replace.h @@ -139,16 +139,16 @@ struct rplpoint { union replace_val_t { - s4 i; - s8 l; - ptrint p; + s4 i; + s8 l; + ptrint p; struct { u4 lo; u4 hi; - } words; - float f; - double d; - java_objectheader *a; + } words; + float f; + double d; + java_object_t *a; }; diff --git a/src/vm/jit/s390/Makefile.am b/src/vm/jit/s390/Makefile.am index 1bac4da27..246189da4 100644 --- a/src/vm/jit/s390/Makefile.am +++ b/src/vm/jit/s390/Makefile.am @@ -1,6 +1,6 @@ -## src/vm/jit/x86_64/Makefile.am +## src/vm/jit/s390/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: -## -## $Id: Makefile.am 5830 2006-10-26 11:04:31Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -37,17 +31,14 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) $(AM_LDFLAGS) LIBS = -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h \ \ md-asm.h -noinst_LTLIBRARIES = libarch.la +noinst_LTLIBRARIES = \ + libarch.la if ENABLE_DISASSEMBLER DISASS_SOURCES = \ @@ -67,10 +58,7 @@ libarch_la_SOURCES = \ md-abi.h \ md.c -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/s390/arch.h b/src/vm/jit/s390/arch.h index 908b0586d..805d8a293 100644 --- a/src/vm/jit/s390/arch.h +++ b/src/vm/jit/s390/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 8240 2007-07-29 20:36:47Z pm $ + $Id: arch.h 8296 2007-08-11 22:38:38Z pm $ */ @@ -108,11 +108,10 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 5 /* bytes */ -#define REPLACEMENT_STUB_SIZE (4+(4+4+4+4)+4+(4+4+4+4)+2) /* bytes */ /* misc ***********************************************************************/ -#define HAS_4BYTE_STACKSLOT +/* #define HAS_4BYTE_STACKSLOT */ #define SUPPORT_COMBINE_INTEGER_REGISTERS #endif /* _ARCH_H */ diff --git a/src/vm/jit/s390/asmpart.S b/src/vm/jit/s390/asmpart.S index f7950a786..6a1b03803 100644 --- a/src/vm/jit/s390/asmpart.S +++ b/src/vm/jit/s390/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8123 2007-06-20 23:50:55Z michi $ + $Id: asmpart.S 8298 2007-08-12 18:49:16Z pm $ */ @@ -32,7 +32,6 @@ #include "vm/jit/s390/arch.h" #include "vm/jit/s390/md-abi.h" #include "vm/jit/s390/md-asm.h" -#include "vm/jit/s390/offsets.h" #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" @@ -57,8 +56,6 @@ .globl asm_abstractmethoderror - .globl asm_patcher_wrapper - .globl asm_replacement_out .globl asm_replacement_in @@ -67,9 +64,6 @@ .globl asm_builtin_d2i .globl asm_builtin_d2l - .globl asm_criticalsections - .globl asm_getclassvalues_atomic - asm_abstractmethoderror: .long 0 @@ -120,256 +114,68 @@ asm_vm_call_method_long: asm_vm_call_method_float: asm_vm_call_method_double: -/* - -a0: methodinfo *m -a1: s4 vmargscount ---> v0: java_objectheader * -a2: vm_arg *vmargs -r14: return address - -96 ... on stack parameters (none) -0 - 96 register save area --------------------------------------------------- <- SP on asm_vm_... entry - local variables - saved return address (important to be at 0(sp) because of md_stacktrace_get_returnaddress) ------------------------------------------ <- SP after stack frame allocation - arguments on stack ----------------------------------------------------- <- SP on JIT code entry - saved return address (callee saved) - -*/ - - -/* - Regiser usage: - itmp1: argument block pointer - itmp2: argument counter - s0: integer argument counter - s1: float argument counter - s2: integer register counter - s3: backup argument block pointer - s4: backup argument count -*/ - - stm %r6, %r15, 24(sp) /* save callers regiters */ - stm a0, a2, 8(sp) /* save arguments */ - ahi sp, -8 /* allocate stack space for local variables */ - st %r14, 0(sp) /* store RA once more at bottom of stack frame */ - - ltr a1, a1 /* maybe we have no args... */ - je L_no_args - - lr itmp2, a1 /* load arg count */ - lr itmp1, a2 /* load arg pointer */ - - ahi itmp1, -sizevmarg /* initialize arg pointer */ - ahi itmp2, 1 /* initialize arg count */ - lhi s0, 0 /* initialize integer arg counter */ - lhi s2, 0 /* initialize integer register counter */ - lhi s1, 0 /* initialize float arg counter */ - - lr s4, a1 /* backup arg count */ - lr s3, a2 /* backup arg pointer */ - -L_register_copy: - - ahi itmp1, sizevmarg /* forward arg pointer */ - ahi itmp2, -1 /* decrement arg count */ - je L_register_copy_done /* no arguments left */ - - tm offvmargtype+7(itmp1), 0x02 /* is this a float/double type? */ - jne L_register_handle_float - -L_register_handle_int: - - chi s2, INT_ARG_CNT /* are we out of integer arg registers ? */ - je L_register_copy /* yes, next loop */ - - tm offvmargtype+7(itmp1), 0x01 /* is this a 2 word type ? */ - jne L_register_handle_long - - ahi s0, 1 /* increment integer arg counter */ - ahi s2, 1 /* increment integer register counter */ - - /* handle argument */ - - chi s2, 1 - je L_handle_i0 - chi s2, 2 - je L_handle_i1 - chi s2, 3 - je L_handle_i2 - chi s2, 4 - je L_handle_i3 - chi s2, 5 - je L_handle_i4 - -L_register_handle_long: - - chi s2, (INT_ARG_CNT - 1) /* are there 2 integer arg registers left ? */ - jl L_register_handle_long_continue /* yes */ - lhi s2, INT_ARG_CNT /* no, drop last register */ - j L_register_copy - -L_register_handle_long_continue: - - ahi s0, 1 /* increment integer arg counter */ - ahi s2, 2 /* consume 2 integer arg registers */ - - /* handle argument */ - - chi s2, 2 - je L_handle_l0 - chi s2, 3 - je L_handle_l1 - chi s2, 4 - je L_handle_l2 - chi s2, 5 - je L_handle_l3 - -L_register_handle_float: - - chi s1, FLT_ARG_CNT /* are we out of float arg registers */ - je L_register_copy /* no arg regisers left */ - - ahi s1, 1 /* increment float argument counter */ - - tm offvmargtype+7(itmp1), 0x01 /* is this a 2 word type ? */ - jne L_register_handle_double - - /* handle argument */ - - chi s1, 1 - je L_handle_f0 - chi s1, 2 - je L_handle_f1 - -L_register_handle_double: - - /* handle argument */ - - chi s1, 1 - je L_handle_d0 - chi s1, 2 - je L_handle_d1 - -L_register_copy_done: - -/* - Regiser usage: - itmp1: argument block pointer - itmp2: argument counter - s0: integer argument counter (initialized by previous code) - s1: float argument counter (initialized by previous code) - s2: pointer to current argument on stack - s3: backup argument block pointer (used to initialize itmp1) - after used as backup of original stack pointer - s4: backup argument count (used to initialize itmp2) - after used as size of parameters on stack -*/ - - lr itmp2, s4 /* restore argument counter */ - lr itmp1, s3 /* restore argument block pointer */ - - /* calculate remaining arguments */ - sr s4, s0 /* - integer arguments in registers */ - sr s4, s1 /* - float arguments in registers */ - - lr s3, sp /* backup stack pointer (does not alter CC) */ - - je L_copy_done /* no arguments left for stack */ - - sll s4, 3 /* allocate 8 bytes per parameter on stack */ - sr sp, s4 /* allocate stack space for arguments */ - - lr s2, sp /* points now to current argument on stack */ - - ahi itmp1, -sizevmarg /* initialize argument block pointer */ - ahi itmp2, 1 /* initialize argument counter */ - -L_stack_copy_loop: - - ahi itmp1, sizevmarg /* forward argument block pointer */ - ahi itmp2, -1 /* decrement argument counter */ - je L_copy_done /* all arguments done */ - - tm offvmargtype+7(itmp1), 0x02 /* is this a float/double type? */ - jne L_stack_handle_float - -L_stack_handle_int: + ahi sp, -8*4 /* allocate stack frame */ - ahi s0, -1 /* decrement number of integer arguments in regs */ - jhe L_stack_copy_loop /* argument is in register */ + /* a0: PV */ + /* a1: data structure */ + /* a2: number of stack arguments */ - tm offvmargtype+7(itmp1), 0x01 /* is this a 2 word type ? */ - jne L_stack_handle_long + st s0, 0*4(sp) /* store used calle saved registers */ + st s1, 1*4(sp) + st a0, 2*4(sp) + st mptr, 3*4(sp) /* mptr/itmp2 is callee saved in terms of C abi */ + st pv, 4*4(sp) + st a4, 5*4(sp) /* a4 is callee saved in terms of C abi */ + st ra, 6*4(sp) - mvc 0(4, s2), offvmargdata+4(itmp1)/* copy integer value */ - ahi s2, 4 - j L_stack_copy_loop + lr s0, a1 /* data structure */ + lr %r0, a2 /* number of stack arguments */ -L_stack_handle_long: + l a0, 0*8+4(s0) /* big endian */ + l a1, 1*8+4(s0) + l a2, 2*8+4(s0) + l a3, 3*8+4(s0) + l a4, 4*8+4(s0) - mvc 0(8, s2), offvmargdata(itmp1) /* copy long value */ - ahi s2, 8 - j L_stack_copy_loop + ld fa0, 5*8(s0) + ld fa1, 6*8(s0) -L_stack_handle_float: + lr s1, sp /* backup stack pointer */ - ahi s1, -1 /* decrement number of float arguments in regs */ - jhe L_stack_copy_loop /* argument is in register */ + ltr %r0, %r0 /* are there any stack arguments ? */ + je L_asm_vm_call_method_stack_copy_done + lr %r1, %r0 /* copy number of stack arguments */ + sll %r1, 3 /* calculate stackframe size */ + sr sp, %r1 /* allocate stack frame */ + lr %r1, sp /* temporary stack pointer */ - tm offvmargtype+7(itmp1), 0x01 /* is this a 2 word type ? */ - jne L_stack_handle_double +L_asm_vm_call_method_stack_copy_loop: - mvc 0(4, s2), offvmargdata(itmp1) /* copy float value */ - ahi s2, 4 - j L_stack_copy_loop + mvc 0(8, %r1), 7*8(s0) /* copy argument */ + ahi %r1, 8 /* increase sp */ + ahi s0, 8 /* set address of next argument */ + ahi %r0, -1 /* substract 1 argument */ + jh L_asm_vm_call_method_stack_copy_loop -L_stack_handle_double: +L_asm_vm_call_method_stack_copy_done: - mvc 0(8, s2), offvmargdata(itmp1) /* copy double value */ - ahi s2, 8 - j L_stack_copy_loop + la mptr, 2*4(s1) /* load method pointer */ + l pv, 0(mptr) /* load procedure vector from method pointer */ + basr ra, pv /* call method */ + lr sp, s1 /* restore stack pointer */ -L_copy_done: - - /* Now we call the compiler in a rather questionable way i needed - * some days to understand: - * - * We can't simply call asm_call_jit_compiler, but we have to call an - * address loaded from memory like it is done in JIT code. - * - * This is because the compiler will intercept the instruction before - * the call instruction, extract the address where the function pointer - * has been loaded from and overwrite it with the code entry. - * - * Arguments are passed in temporary registers. - */ - - /* load address of L_asm_call_jit_compiler into memory */ - - basr mptr, 0 /* store PC */ -L_basr: - la mptr, L_asm_call_jit_compiler-L_basr(mptr) /* add offset to PC */ - st mptr, 4(s3) /* store on stack */ - - l itmp1, 8+8(s3) /* load methodinfo for compiler */ - la mptr, 4(s3) /* store **function in mptr for compiler */ - - /* call L_asm_call_jit_compiler like JIT code would do */ - - l itmp3, 0(mptr) /* load address of target from memory */ - basr %r14, itmp3 /* jump to target */ +L_asm_vm_call_method_return: - /* todo will s4 survive the call? */ - ar sp, s4 /* remove stack space for arguments */ + l s0, 0*4(sp) /* restore used callee saved registers */ + l s1, 1*4(sp) + l mptr, 3*4(sp) + l pv, 4*4(sp) + l a4, 5*4(sp) + l ra, 6*4(sp) -L_asm_vm_call_method_return: + ahi sp, 8*4 /* remove stackframe */ + br ra /* return */ - ahi sp, 8 /* remove stack space for local variables */ - lm %r6, %r15, 24(sp) /* restore callers registers */ - br %r14 /* return */ asm_vm_call_method_exception_handler: lr a0, xptr @@ -381,59 +187,8 @@ L_avcmeh_bras: ahi sp, -96 basr %r14, %r14 ahi sp, 96 - j L_asm_vm_call_method_return -/* .... */ - -L_no_args: - lr s3, sp - lhi s4, 0 - j L_copy_done - -L_handle_i0: - l a0, offvmargdata+4(itmp1) - j L_register_copy -L_handle_i1: - l a1, offvmargdata+4(itmp1) - j L_register_copy -L_handle_i2: - l a2, offvmargdata+4(itmp1) - j L_register_copy -L_handle_i3: - l a3, offvmargdata+4(itmp1) - j L_register_copy -L_handle_i4: - l a4, offvmargdata+4(itmp1) - j L_register_copy - -L_handle_l0: - lm a0, a1, offvmargdata(itmp1) - j L_register_copy -L_handle_l1: - lm a1, a2, offvmargdata(itmp1) - j L_register_copy -L_handle_l2: - lm a2, a3, offvmargdata(itmp1) - j L_register_copy -L_handle_l3: - lm a3, a4, offvmargdata(itmp1) - j L_register_copy - -L_handle_f0: - le fa0, offvmargdata(itmp1) - j L_register_copy -L_handle_f1: - le fa1, offvmargdata(itmp1) - j L_register_copy - -L_handle_d0: - ld fa0, offvmargdata(itmp1) - j L_register_copy -L_handle_d1: - ld fa1, offvmargdata(itmp1) - j L_register_copy - asm_vm_call_method_end: brc 0,0 @@ -519,7 +274,6 @@ L_bras_acjce: j L_asm_handle_nat_exception -#if 0 /* asm_handle_exception ******************************************************** * * * This function handles an exception. It does not use the usual calling * @@ -530,164 +284,146 @@ L_bras_acjce: * * *******************************************************************************/ -#endif - asm_handle_nat_exception: L_asm_handle_nat_exception: /* TODO really nothing here ? */ asm_handle_exception: -L_asm_handle_exception: /* required for PIC code */ - - ahi sp, -(ARGUMENT_REGISTERS_SIZE + TEMPORARY_REGISTERS_SIZE) /* create maybe-leaf stackframe */ - STORE_ARGUMENT_REGISTERS(0) - STORE_TEMPORARY_REGISTERS(ARGUMENT_REGISTERS_SIZE) - lhi a3, (ARGUMENT_REGISTERS_SIZE + TEMPORARY_REGISTERS_SIZE) /* prepare a3 for handle_exception */ - - lhi %r0, 1 /* set maybe-leaf flag */ - -L_asm_handle_exception_stack_loop: - ahi sp,-(6*4) - st xptr,0*4(sp) /* save exception pointer */ - st xpc,1*4(sp) /* save exception pc */ - la a3,(6*4)(a3,sp) /* calculate Java sp into a3... */ - st a3,3*4(sp) /* ...and save it */ - st %r0,4*4(sp) /* save maybe-leaf flag */ - - lr a0,xpc /* exception pc */ - - ahi sp,-96 /* add register save area for C code */ - - bras %r14,L_ahe_bras /* call codegen_get_pv_from_pc */ - .long codegen_get_pv_from_pc +L_asm_handle_exception: + + /* a wrapper for md_handle_exception */ + +# define STACKFRAMESIZE (96 + (16 * 4) + (16 * 8) + (4 * 4)) +# define REGS 96 +# define FREGS (96 + (16 * 4)) +# define OUT (96 + (16 * 4) + (16 * 8)) + + ahi sp, -STACKFRAMESIZE /* allocate stack frame containing the arrays */ + + /* store special registers to array */ + + st xptr, REGS+(1*4)(sp) + st xpc, REGS+(12*4)(sp) + st pv, REGS+(13*4)(sp) + la itmp3, STACKFRAMESIZE(sp) + st itmp3, REGS+(15*4)(sp) + + /* store temporary and argument registers */ + + stm a0, a4, REGS+(2*4)(sp) + std %f0, FREGS+(0*8)(sp) + std %f1, FREGS+(1*8)(sp) + std %f2, FREGS+(2*8)(sp) + std %f3, FREGS+(3*8)(sp) + std %f5, FREGS+(5*8)(sp) + std %f7, FREGS+(7*8)(sp) + std %f8, FREGS+(8*8)(sp) + std %f9, FREGS+(9*8)(sp) + std %f10, FREGS+(10*8)(sp) + std %f11, FREGS+(11*8)(sp) + std %f12, FREGS+(12*8)(sp) + std %f13, FREGS+(13*8)(sp) + std %f14, FREGS+(14*8)(sp) + std %f15, FREGS+(15*8)(sp) + + /* call md_handle_exception */ + + la a0, REGS(sp) + la a1, FREGS(sp) + la a2, OUT(sp) + + bras %r14,L_ahe_bras + .long md_handle_exception L_ahe_bras: l %r14,0(%r14) basr %r14,%r14 - st v0,2*4+96(sp) /* save data segment pointer */ - - lr a2,v0 /* pass data segment pointer */ - l a0,0*4+96(sp) /* pass exception pointer */ - l a1,1*4+96(sp) /* pass exception pc */ - l a3,3*4+96(sp) /* pass Java stack pointer */ - - bras %r14,L_ahe_bras2 /* call exceptions_handle_exception */ - .long exceptions_handle_exception -L_ahe_bras2: - l %r14,0(%r14) - basr %r14,%r14 - ahi sp,96 /* remove regiser save area for C code */ + l itmp3, OUT+(2*4)(sp) /* out[2] contains maybe leaf flag */ + ltr itmp3, itmp3 + je L_restore_saved - ltr v0,v0 - jz L_asm_handle_exception_not_catched +L_restore_temporary_and_argument: - lr xpc,v0 /* move handlerpc into xpc */ - l xptr,0*4(sp) /* restore exception pointer */ - l pv,2*4(sp) /* restore PV */ - ahi pv,-0xffc /* offset PV */ - l %r0,4*4(sp) /* get maybe-leaf flag */ - ahi sp,(6*4) /* free stack frame */ + /* if we are maybe leaf, + * we have to restore argument and temporary registers + */ - ltr %r0, %r0 - jz L_asm_handle_exception_no_leaf + lm a0, a4, REGS+(2*4)(sp) + ld %f0, FREGS+(0*8)(sp) + ld %f1, FREGS+(1*8)(sp) + ld %f2, FREGS+(2*8)(sp) + ld %f3, FREGS+(3*8)(sp) + ld %f5, FREGS+(5*8)(sp) + ld %f7, FREGS+(7*8)(sp) + ld %f8, FREGS+(8*8)(sp) + ld %f9, FREGS+(9*8)(sp) + ld %f10, FREGS+(10*8)(sp) + ld %f11, FREGS+(11*8)(sp) + ld %f12, FREGS+(12*8)(sp) + ld %f13, FREGS+(13*8)(sp) + ld %f14, FREGS+(14*8)(sp) + ld %f15, FREGS+(15*8)(sp) + + j L_restore_done + +L_restore_saved: + + /* if we are not a maybe leaf, + * we have to restore callee saved registers of the callee + */ - LOAD_ARGUMENT_REGISTERS(0) - LOAD_TEMPORARY_REGISTERS(ARGUMENT_REGISTERS_SIZE) + l itmp3, OUT+(0*4)(sp) /* out[0] contains IntSav */ - ahi sp, (ARGUMENT_REGISTERS_SIZE + TEMPORARY_REGISTERS_SIZE) /* Remove maybe-leaf stackframe */ + ahi itmp3, -1 + jl L_int_done + l s4, REGS+(11*4)(sp) -L_asm_handle_exception_no_leaf: - br xpc /* jump to the handler */ + ahi itmp3, -1 + jl L_int_done + l s3, REGS+(10*4)(sp) -L_asm_handle_exception_not_catched: - l xptr,0*4(sp) /* restore exception pointer */ - l itmp3,2*4(sp) /* restore data segment pointer */ - ahi itmp3,-0xfff /* for negative displacements */ - l %r0,4*4(sp) /* get maybe-leaf flag */ - ahi sp,(6*4) + ahi itmp3, -1 + jl L_int_done + l s2, REGS+(9*4)(sp) - ltr %r0,%r0 - jz L_asm_handle_exception_no_leaf_stack + ahi itmp3, -1 + jl L_int_done + l s1, REGS+(8*4)(sp) - ahi sp, (ARGUMENT_REGISTERS_SIZE + TEMPORARY_REGISTERS_SIZE) /* Remove maybe-leaf stackframe */ - lhi %r0,0 /* clear the isleaf flag */ + ahi itmp3, -1 + jl L_int_done + l s0, REGS+(7*4)(sp) - /* - +-----------------+-----------+---------+----+ - | Memuse | Float Sav | Int Sav | RA | - | | 0 ... n | 0 ... n | | - +-----------------+-----------+---------+----+ - ^ ^ ^ - SP F I +L_int_done: - ^ ^ ^ - p3 p2 p1 - */ + /* restore callee saved float registers */ -L_asm_handle_exception_no_leaf_stack: + l itmp3, OUT+(1*4)(sp) /* out[1] contains FltSav */ - l itmp2,0xfff+FrameSize(itmp3)/* get frame size */ - la itmp2,0(itmp2,sp) /* pointer to save area (p1) */ - ahi itmp2,-4 /* skip RA (p2) */ - ahi itmp2,-0xfff /* for negative displacements */ + ahi itmp3, -1 + jl L_flt_done + ld %f6, FREGS+(6*8)(sp) - l a0,0xfff+IntSave(itmp3) /* a0 = saved int register count */ + ahi itmp3, -1 + jl L_flt_done + ld %f4, FREGS+(4*8)(sp) - ltr a0,a0 - je noint +L_flt_done: - chi a0,1 - je int1 - chi a0,2 - je int2 - chi a0,3 - je int3 - chi a0,4 - je int4 - -int5: - l s0,0xfff-5*4(itmp2) -int4: - l s1,0xfff-4*4(itmp2) -int3: - l s2,0xfff-3*4(itmp2) -int2: - l s3,0xfff-2*4(itmp2) -int1: - l s4,0xfff-1*4(itmp2) - -noint: - - sll a0,2 /* a0 = saved int register count * 4 */ - sr itmp2, a0 /* skip Int Sav (p3) */ - - l a0,0xfff+FltSave(itmp3) - ltr a0,a0 /* Number of saved floating point registers */ - je noflt - - chi a0,1 - je flt1 - -flt2: - ld %f4,0xfff-2*8(itmp2) -flt1: - ld %f6,0xfff-1*8(itmp2) - -noflt: - - l itmp3,0xfff+FrameSize(itmp3)/* get frame size (at least 4 - RA) */ - ahi itmp3,-4 /* substract 4 */ - l xpc,0(itmp3,sp) /* load the new xpc - return address */ - la sp, 4(itmp3,sp) /* unwind stack */ - - /* exception pointer is still set */ -#if 0 - sub $3,xpc /* subtract 3 bytes for call */ -#endif +L_restore_done: - lhi a3,0 /* prepare a3 for handle_exception */ - - j L_asm_handle_exception_stack_loop + /* write new values for special registers */ + + l xptr, REGS+(1*4)(sp) + l xpc, REGS+(12*4)(sp) + l pv, REGS+(13*4)(sp) + l sp, REGS+(15*4)(sp) + br xpc /* jump to handler */ + +# undef STACKFRAMESIZE +# undef REGS +# undef FREGS +# undef OUT #if 0 @@ -710,68 +446,6 @@ asm_abstractmethoderror: #endif -/* asm_patcher_wrapper ********************************************************* - - XXX - - Stack layout: - 20 return address into JIT code (patch position) - 16 pointer to virtual java_objectheader - 12 machine code (which is patched back later) - 8 unresolved class/method/field reference - 4 data segment displacement from load instructions - 0 patcher function pointer to call (pv afterwards) - -*******************************************************************************/ - -asm_patcher_wrapper: -# define apw_sfs (96 + 4 + VOLATILE_INTEGER_REGISTERS_SIZE + VOLATILE_FLOAT_REGISTERS_SIZE) - - ahi sp, -apw_sfs /* create stack frame */ - - /* store all volatile registers and a2, because we will touch it */ - - st a2, 96(sp) - STORE_VOLATILE_INTEGER_REGISTERS(96 + 4) - STORE_VOLATILE_FLOAT_REGISTERS(96 + 4 + VOLATILE_INTEGER_REGISTERS_SIZE) - - /* pass arguments */ - - la a0, apw_sfs(sp) /* pass SP of patcher stub */ - la a1, 0xffc(pv) /* pass PV (if NULL, use findmethod) */ - lhi a2, 0 /* pass RA */ - - /* call patcher_wrapper */ - - bras itmp1, L_apw_bras /* call patcher_wrapper */ - .long patcher_wrapper -L_apw_bras: - l itmp1, 0(itmp1) - basr %r14, itmp1 - - /* store return value */ - - st v0,0(sp) /* save return value */ - - /* restore volatile registers */ - - l a2, 96(sp) - LOAD_VOLATILE_INTEGER_REGISTERS(96 + 4) - LOAD_VOLATILE_FLOAT_REGISTERS(96 + 4 + VOLATILE_INTEGER_REGISTERS_SIZE) - - l itmp3, 0(sp) /* restore return value */ - ltr itmp3, itmp3 /* exception thrown ? */ - jne L_asm_patcher_wrapper_exception /* handle exception */ - l itmp3, apw_sfs + (5 * 4)(sp) /* load return address to JIT from stack */ - ahi sp, apw_sfs + (6 * 4) /* remove stack frame, and stack frame by patcher stub */ - br itmp3 /* return */ - -L_asm_patcher_wrapper_exception: - lr xptr,itmp3 /* get exception */ - l xpc, apw_sfs + (5 * 4)(sp) /* load return address to JIT from stack */ - ahi sp, apw_sfs + (6 * 4) /* remove stack frame, and stack frame by patcher stub */ - j L_asm_handle_exception - #if 0 /* asm_replacement_out ********************************************************* @@ -906,30 +580,6 @@ asm_replacement_in: ret #endif -/* TODO use move here ? */ - -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: - l %r0,offbaseval(a0) - l %r1,offdiffval(a0) - l a3,offbaseval(a1) -_crit_end: - st %r0,offcast_super_baseval(a2) - st %r1,offcast_super_diffval(a2) - st a3,offcast_sub_baseval(a2) - br %r14 - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .long _crit_begin - .long _crit_end - .long _crit_restart -#endif - .long 0 - /* * These are local overrides for various environment variables in Emacs. diff --git a/src/vm/jit/s390/codegen.c b/src/vm/jit/s390/codegen.c index a96e19678..c2beb38af 100644 --- a/src/vm/jit/s390/codegen.c +++ b/src/vm/jit/s390/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8240 2007-07-29 20:36:47Z pm $ + $Id: codegen.c 8297 2007-08-12 00:02:48Z michi $ */ @@ -30,32 +30,30 @@ #include "config.h" #include +#include #include -#include "vm/types.h" - -#include "md-abi.h" - -#include "vm/jit/s390/arch.h" -#include "vm/jit/s390/codegen.h" -#include "vm/jit/s390/emit.h" - -#include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/native.h" +#include "mm/memory.h" + #if defined(ENABLE_THREADS) +# include "threads/lock-common.h" # include "threads/native/lock.h" #endif -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" #include "vmcore/loader.h" #include "vmcore/options.h" #include "vmcore/statistics.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/builtin.h" +#include "vm/exceptions.h" +#include "vm/global.h" +#include "vm/jit/abi.h" +#if defined(ENABLE_LSRA) +# include "vm/jit/allocator/lsra.h" +#endif #include "vm/jit/asmpart.h" #include "vm/jit/codegen-common.h" #include "vm/jit/dseg.h" @@ -63,21 +61,37 @@ #include "vm/jit/jit.h" #include "vm/jit/methodheader.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher.h" +#include "vm/jit/patcher-common.h" #include "vm/jit/reg.h" #include "vm/jit/replace.h" +#include "vm/jit/s390/arch.h" +#include "vm/jit/s390/codegen.h" +#include "vm/jit/s390/emit.h" +#include "vm/jit/s390/md-abi.h" #include "vm/jit/stacktrace.h" -#include "vm/jit/abi.h" -#include "vm/jit/emit-common.h" +#include "vm/types.h" +#include "vm/stringlocal.h" +#include "vm/vm.h" -#if defined(ENABLE_LSRA) -# include "vm/jit/allocator/lsra.h" -#endif +/* DO__LOG generates a call to do__log. No registers are destroyed, + * so you may use it anywhere. regs is an array containing all general + * purpose registers. + */ -#define OOPS() assert(0); -#define SUPPORT_HERCULES 1 +static void do__log(u4 *regs) { + /* insert stuff here */ +} -void panic() { } +#define DO__LOG \ + N_AHI(REG_SP, -200); \ + N_STM(R0, R15, 96, REG_SP); \ + M_ALD_DSEG(R14, dseg_add_address(cd, &do__log)); \ + N_LA(R2, 96, RN, REG_SP); \ + N_BASR(R14, R14); \ + N_LM(R0, R15, 96, REG_SP); \ + N_AHI(REG_SP, 200); + +#define SUPPORT_HERCULES 1 /* codegen ********************************************************************* @@ -85,6 +99,30 @@ void panic() { } *******************************************************************************/ +/* + +Layout of stackframe: + +Meaning Offset +=============================================================================== +return_address (stackframesize - 1) * 8 +saved_int_reg[INT_SAV_CNT - 1] (stackframseize - 2) * 8 +... +saved_int_reg[rd->savintreguse] +saved_flt_reg[FLT_SAV_CNT - 1] +... +saved_flt_reg[rd->savfltreguse] (stackframesize - 1 - savedregs_num) * 8 + +return_value_tmp (rd->memuse + 1) * 8 +monitorenter_argument (rd->memuse) * 8 +??? +local[rd->memuse - 1] (rd->memuse - 1) * 8 +.... +local[2] 2 * 8 +local[1] 1 * 8 +local[0] 0 * 8 + +*/ bool codegen_emit(jitdata *jd) { @@ -136,7 +174,7 @@ bool codegen_emit(jitdata *jd) /* space to save used callee saved registers */ savedregs_num += (INT_SAV_CNT - rd->savintreguse); - savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2; + savedregs_num += (FLT_SAV_CNT - rd->savfltreguse); cd->stackframesize = rd->memuse + savedregs_num + 1 /* space to save RA */; @@ -151,12 +189,9 @@ bool codegen_emit(jitdata *jd) since both values reside in R2. */ if (checksync && (m->flags & ACC_SYNCHRONIZED)) { - /* reserve 2 slots for long/double return values for monitorexit */ - - if (IS_2_WORD_TYPE(m->parseddesc->returntype.type)) - cd->stackframesize += 3; - else - cd->stackframesize += 2; + /* 1 slot space to save argument of monitor_enter */ + /* 1 slot to temporary store return value before monitor_exit */ + cd->stackframesize += 2; } #endif @@ -166,12 +201,12 @@ bool codegen_emit(jitdata *jd) if (!jd->isleafmethod || opt_verbosecall ) /* TODO really 16 bytes ? */ - cd->stackframesize = (cd->stackframesize + 3) & ~3; + cd->stackframesize = (cd->stackframesize + 2) & ~2; /* 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 * 8); /* FrameSize */ #if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the @@ -181,10 +216,9 @@ 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 + 1) * 8); /* IsSync */ else #endif - (void) dseg_add_unique_s4(cd, 0); /* IsSync */ (void) dseg_add_unique_s4(cd, jd->isleafmethod); /* IsLeaf */ @@ -225,18 +259,18 @@ bool codegen_emit(jitdata *jd) /* create stack frame (if necessary) */ if (cd->stackframesize) - M_ASUB_IMM(cd->stackframesize * 4, REG_SP); + M_ASUB_IMM(cd->stackframesize * 8, REG_SP); /* save used callee saved registers and return address */ p = cd->stackframesize; - p--; M_AST(REG_RA, REG_SP, p * 4); + p--; M_AST(REG_RA, REG_SP, p * 8); for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) { - p--; M_IST(rd->savintregs[i], REG_SP, p * 4); + p--; M_IST(rd->savintregs[i], REG_SP, p * 8); } for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) { - p -= 2; M_DST(rd->savfltregs[i], REG_SP, p * 4); + p--; M_DST(rd->savfltregs[i], REG_SP, p * 8); } /* take arguments out of register or stack frame */ @@ -248,8 +282,9 @@ bool codegen_emit(jitdata *jd) varindex = jd->local_map[l * 5 + t]; l++; - if (IS_2_WORD_TYPE(t)) /* increment local counter for 2 word types */ - l++; + + if (IS_2_WORD_TYPE(t)) + l++; if (varindex == UNUSED) continue; @@ -257,6 +292,7 @@ bool codegen_emit(jitdata *jd) var = VAR(varindex); s1 = md->params[p].regoff; + if (IS_INT_LNG_TYPE(t)) { /* integer args */ if (IS_2_WORD_TYPE(t)) { s2 = PACK_REGS( @@ -268,31 +304,28 @@ bool codegen_emit(jitdata *jd) } if (!md->params[p].inmemory) { /* register arguments */ if (!IS_INMEMORY(var->flags)) { /* reg arg -> register */ - if (IS_2_WORD_TYPE(t)) + if (IS_2_WORD_TYPE(t)) { M_LNGMOVE(s2, var->vv.regoff); - else + } else { M_INTMOVE(s2, var->vv.regoff); - + } } else { /* reg arg -> spilled */ - if (IS_2_WORD_TYPE(t)) + if (IS_2_WORD_TYPE(t)) { M_LST(s2, REG_SP, var->vv.regoff); - else + } else { M_IST(s2, REG_SP, var->vv.regoff); + } } } else { /* stack arguments */ 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); - else - M_ILD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1); - - } else { /* stack arg -> spilled */ if (IS_2_WORD_TYPE(t)) { - N_MVC(var->vv.regoff, 8, REG_SP, cd->stackframesize * 4 + s1, REG_SP); + M_LLD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); } else { - N_MVC(var->vv.regoff, 4, REG_SP, cd->stackframesize * 4 + s1, REG_SP); + M_ILD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); } + } else { /* stack arg -> spilled */ + N_MVC(var->vv.regoff, 8, REG_SP, cd->stackframesize * 8 + s1, REG_SP); } } @@ -312,19 +345,14 @@ bool codegen_emit(jitdata *jd) } else { /* stack arguments */ 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); + M_DLD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); else - M_FLD(var->vv.regoff, REG_SP, cd->stackframesize * 4 + s1); + M_FLD(var->vv.regoff, REG_SP, cd->stackframesize * 8 + s1); } else { /* stack-arg -> spilled */ - if (IS_2_WORD_TYPE(t)) { - N_MVC(var->vv.regoff, 8, REG_SP, cd->stackframesize * 4 + s1, REG_SP); - var->vv.regoff = cd->stackframesize * 4 + s1; - - } else { - N_MVC(var->vv.regoff, 4, REG_SP, cd->stackframesize * 4 + s1, REG_SP); - } + N_MVC(var->vv.regoff, 8, REG_SP, cd->stackframesize * 8 + s1, REG_SP); + var->vv.regoff = cd->stackframesize * 8 + s1; } } } @@ -346,9 +374,9 @@ bool codegen_emit(jitdata *jd) M_IST(abi_registers_integer_argument[p], REG_SP, p * 8); for (p = 0; p < FLT_ARG_CNT; p++) - M_FST(abi_registers_float_argument[p], REG_SP, (INT_ARG_CNT + p) * 8); + M_DST(abi_registers_float_argument[p], REG_SP, (INT_ARG_CNT + p) * 8); - s1 += ((INT_ARG_CNT + FLT_ARG_CNT) * 2); + s1 += ((INT_ARG_CNT + FLT_ARG_CNT)); } #endif @@ -367,7 +395,7 @@ bool codegen_emit(jitdata *jd) disp = dseg_add_functionptr(cd, LOCK_monitor_enter); M_ALD_DSEG(REG_ITMP3, disp); - M_AST(REG_A0, REG_SP, s1 * 4); + M_AST(REG_A0, REG_SP, s1 * 8); M_ASUB_IMM(96, REG_SP); M_CALL(REG_ITMP3); @@ -379,7 +407,7 @@ bool codegen_emit(jitdata *jd) M_ILD(abi_registers_integer_argument[p], REG_SP, p * 8); for (p = 0; p < FLT_ARG_CNT; p++) - M_FLD(abi_registers_float_argument[p], REG_SP, (INT_ARG_CNT + p) * 8); + M_DLD(abi_registers_float_argument[p], REG_SP, (INT_ARG_CNT + p) * 8); M_AADD_IMM((INT_ARG_CNT + FLT_ARG_CNT) * 8, REG_SP); } @@ -558,7 +586,7 @@ bool codegen_emit(jitdata *jd) /* PROFILE_CYCLE_STOP; */ - codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_classinfo, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo, cr, disp); /* PROFILE_CYCLE_START; */ @@ -1968,19 +1996,19 @@ bool codegen_emit(jitdata *jd) /* PROFILE_CYCLE_STOP; */ - codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); + patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); /* PROFILE_CYCLE_START; */ } else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { PROFILE_CYCLE_STOP; - codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, 0); + patcher_add_patch_ref(jd, PATCHER_clinit, fi->class, 0); PROFILE_CYCLE_START; } @@ -2022,16 +2050,16 @@ bool codegen_emit(jitdata *jd) fieldtype = uf->fieldref->parseddesc.fd->type; disp = dseg_add_unique_address(cd, uf); - codegen_addpatchref(cd, PATCHER_get_putstatic, uf, disp); + patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp); } else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { PROFILE_CYCLE_STOP; - codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp); + patcher_add_patch_ref(jd, PATCHER_clinit, fi->class, disp); PROFILE_CYCLE_START; } } @@ -2071,7 +2099,7 @@ bool codegen_emit(jitdata *jd) fieldtype = uf->fieldref->parseddesc.fd->type; disp = 0; - codegen_addpatchref(cd, PATCHER_get_putfield, uf, 0); + patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); } else { fi = iptr->sx.s23.s3.fmiref->p.field; @@ -2135,11 +2163,11 @@ bool codegen_emit(jitdata *jd) * We pass in the disp parameter, how many bytes * to skip to the to the actual store. * - * XXX this relies on codegen_add_patch_ref internals + * XXX this relies on patcher_add_patch_ref internals */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, PATCHER_get_putfield, uf, 0); + patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0); ref = cd->mcodeptr; } @@ -2154,7 +2182,7 @@ bool codegen_emit(jitdata *jd) } if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - cd->patchrefs->disp = (cd->mcodeptr - ref); + ((patchref_t *)list_first_unsynced(jd->code->patchers))->disp = (cd->mcodeptr - ref); } switch (fieldtype) { @@ -2192,7 +2220,7 @@ bool codegen_emit(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uc = iptr->sx.s23.s2.uc; - codegen_add_patch_ref(cd, PATCHER_athrow_areturn, uc, 0); + patcher_add_patch_ref(jd, PATCHER_athrow_areturn, uc, 0); } #endif /* ENABLE_VERIFIER */ @@ -2521,7 +2549,7 @@ bool codegen_emit(jitdata *jd) unresolved_class *uc = iptr->sx.s23.s2.uc; PROFILE_CYCLE_STOP; - codegen_addpatchref(cd, PATCHER_athrow_areturn, uc, 0); + patcher_add_patch_ref(jd, PATCHER_athrow_areturn, uc, 0); PROFILE_CYCLE_START; } #endif /* ENABLE_VERIFIER */ @@ -2561,26 +2589,25 @@ nowperformreturn: #if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { - /* we need to save the proper return value */ switch (iptr->opc) { case ICMD_LRETURN: - M_IST(REG_RESULT2, REG_SP, rd->memuse * 4 + 8); + M_IST(REG_RESULT2, REG_SP, ((rd->memuse + 1) * 8) + 4); /* fall through */ case ICMD_IRETURN: case ICMD_ARETURN: - M_IST(REG_RESULT , REG_SP, rd->memuse * 4 + 4); + M_IST(REG_RESULT , REG_SP, (rd->memuse + 1) * 8); break; case ICMD_FRETURN: - M_FST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); + M_FST(REG_FRESULT, REG_SP, (rd->memuse + 1) * 8); break; case ICMD_DRETURN: - M_DST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); + M_DST(REG_FRESULT, REG_SP, (rd->memuse + 1) * 8); break; } - M_ALD(REG_A0, REG_SP, rd->memuse * 4); + M_ALD(REG_A0, REG_SP, rd->memuse * 8); disp = dseg_add_functionptr(cd, LOCK_monitor_exit); M_ALD_DSEG(REG_ITMP3, disp); @@ -2593,17 +2620,17 @@ nowperformreturn: switch (iptr->opc) { case ICMD_LRETURN: - M_ILD(REG_RESULT2, REG_SP, rd->memuse * 4 + 8); + M_ILD(REG_RESULT2, REG_SP, ((rd->memuse + 1) * 8) + 4); /* fall through */ case ICMD_IRETURN: case ICMD_ARETURN: - M_ILD(REG_RESULT , REG_SP, rd->memuse * 4 + 4); + M_ILD(REG_RESULT , REG_SP, (rd->memuse + 1) * 8); break; case ICMD_FRETURN: - M_FLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); + M_FLD(REG_FRESULT, REG_SP, (rd->memuse + 1) * 8); break; case ICMD_DRETURN: - M_DLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4); + M_DLD(REG_FRESULT, REG_SP, (rd->memuse + 1) * 8); break; } } @@ -2611,25 +2638,26 @@ nowperformreturn: /* restore return address */ - p--; M_ALD(REG_RA, REG_SP, p * 4); + p--; M_ALD(REG_RA, REG_SP, p * 8); /* restore saved registers */ for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) { - p--; M_ILD(rd->savintregs[i], REG_SP, p * 4); + p--; M_ILD(rd->savintregs[i], REG_SP, p * 8); } for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) { - p -= 2; M_DLD(rd->savfltregs[i], REG_SP, p * 4); + p--; M_DLD(rd->savfltregs[i], REG_SP, p * 8); } /* deallocate stack */ if (cd->stackframesize) - M_AADD_IMM(cd->stackframesize * 4, REG_SP); + M_AADD_IMM(cd->stackframesize * 8, REG_SP); /* generate method profiling code */ PROFILE_CYCLE_STOP; + M_RET; ALIGNCODENOP; } @@ -2824,7 +2852,7 @@ gen_method: if (lm == NULL) { disp = dseg_add_unique_address(cd, um); - codegen_addpatchref(cd, PATCHER_invokestatic_special, + patcher_add_patch_ref(jd, PATCHER_invokestatic_special, um, disp); } else @@ -2842,7 +2870,7 @@ gen_method: /* TODO softnull REG_A0 */ if (lm == NULL) { - codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0); + patcher_add_patch_ref(jd, PATCHER_invokevirtual, um, 0); s1 = 0; } @@ -2853,7 +2881,7 @@ gen_method: /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); break; @@ -2865,7 +2893,7 @@ gen_method: */ if (lm == NULL) { - codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0); + patcher_add_patch_ref(jd, PATCHER_invokeinterface, um, 0); s1 = 0; s2 = 0; @@ -2878,7 +2906,7 @@ gen_method: } /* Implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); N_LHI(REG_ITMP1, s1); N_L(REG_METHODPTR, 0, REG_ITMP1, REG_METHODPTR); M_ALD(REG_PV, REG_METHODPTR, s2); @@ -2986,7 +3014,7 @@ gen_method: disp = dseg_add_unique_s4(cd, 0); /* super->flags */ - codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_flags, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags, iptr->sx.s23.s3.c.ref, disp); @@ -3004,7 +3032,7 @@ gen_method: if ((super == NULL) || (super->flags & ACC_INTERFACE)) { if (super == NULL) { - codegen_add_patch_ref(cd, + patcher_add_patch_ref(jd, PATCHER_checkcast_instanceof_interface, iptr->sx.s23.s3.c.ref, 0); @@ -3013,7 +3041,7 @@ gen_method: emit_label_beq(cd, LABEL_EXIT_INTERFACE_NULL); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_ISUB_IMM(superindex, REG_ITMP3); emit_classcast_check(cd, iptr, BRANCH_LE, RN, s1); @@ -3040,7 +3068,7 @@ gen_method: if (super == NULL) { disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl, iptr->sx.s23.s3.c.ref, disp); @@ -3051,7 +3079,7 @@ gen_method: emit_label_beq(cd, LABEL_EXIT_CLASS_NULL); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD_DSEG(REG_ITMP3, disp); CODEGEN_CRITICAL_SECTION_START; @@ -3097,7 +3125,7 @@ gen_method: if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo, iptr->sx.s23.s3.c.ref, disp); @@ -3185,7 +3213,7 @@ gen_method: disp = dseg_add_unique_s4(cd, 0); /* super->flags */ - codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_flags, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags, iptr->sx.s23.s3.c.ref, disp); ICONST(REG_ITMP2, ACC_INTERFACE); @@ -3209,7 +3237,7 @@ gen_method: if (d == REG_ITMP2) M_CLR(d); - codegen_add_patch_ref(cd, + patcher_add_patch_ref(jd, PATCHER_checkcast_instanceof_interface, iptr->sx.s23.s3.c.ref, 0); } @@ -3219,7 +3247,7 @@ gen_method: emit_label_beq(cd, LABEL_EXIT_INTERFACE_NULL); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); M_ISUB_IMM(superindex, REG_ITMP3); @@ -3253,7 +3281,7 @@ gen_method: if (super == NULL) { disp = dseg_add_unique_address(cd, NULL); - codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_vftbl, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl, iptr->sx.s23.s3.c.ref, disp); } @@ -3266,7 +3294,7 @@ gen_method: emit_label_beq(cd, LABEL_EXIT_CLASS_NULL); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD_DSEG(REG_ITMP2, disp); CODEGEN_CRITICAL_SECTION_START; @@ -3333,7 +3361,7 @@ gen_method: if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_add_unique_address(cd, 0); - codegen_add_patch_ref(cd, PATCHER_resolve_classref_to_classinfo, + patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo, iptr->sx.s23.s3.c.ref, disp); } @@ -3395,10 +3423,7 @@ gen_method: /* generate stubs */ - emit_patcher_stubs(jd); -#if defined(ENABLE_REPLACEMENT) - REPLACEMENT_EMIT_STUBS(jd); -#endif + emit_patcher_traps(jd); /* everything's ok */ @@ -3490,20 +3515,17 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) cd->stackframesize = 1 + /* r14 - return address */ + - sizeof(stackframeinfo) / SIZEOF_VOID_P + - sizeof(localref_table) / SIZEOF_VOID_P + + ((sizeof(stackframeinfo) + 7) / 8) + + ((sizeof(localref_table) + 7) / 8) + 1 + /* itmp3 */ - (INT_ARG_CNT + FLT_ARG_CNT) * 2 + + (INT_ARG_CNT + FLT_ARG_CNT) + nmd->memuse + /* parameter passing */ - 96 / SIZEOF_VOID_P /* required by ABI */; - - cd->stackframesize |= 0x1; /* keep stack 8-byte aligned */ - + (96 / 8) /* required by ABI */; /* 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 * 8); /* FrameSize */ (void) dseg_add_unique_s4(cd, 0); /* IsSync */ (void) dseg_add_unique_s4(cd, 0); /* IsLeaf */ (void) dseg_add_unique_s4(cd, 0); /* IntSave */ @@ -3513,7 +3535,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* generate stub code */ - N_AHI(REG_SP, -(cd->stackframesize * SIZEOF_VOID_P)); + N_AHI(REG_SP, -(cd->stackframesize * 8)); N_AHI(REG_PV, N_PV_OFFSET); /* generate native method profiling code */ @@ -3530,7 +3552,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* save return address */ - N_ST(R14, (cd->stackframesize - 1) * SIZEOF_VOID_P, RN, REG_SP); + N_ST(R14, (cd->stackframesize - 1) * 8, RN, REG_SP); #if !defined(NDEBUG) if (JITDATA_HAS_FLAG_VERBOSECALL(jd)) @@ -3543,12 +3565,12 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) - codegen_add_patch_ref(cd, PATCHER_resolve_native, m, disp); + patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, disp); #endif M_ILD_DSEG(REG_ITMP1, disp); - j = 96 + (nmd->memuse * 4); + j = 96 + (nmd->memuse * 8); /* todo some arg registers are not volatile in C-abi terms */ @@ -3583,10 +3605,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* create dynamic stack info */ - N_LAE(REG_A0, (cd->stackframesize - 1) * 4, RN, REG_SP); /* datasp */ + N_LAE(REG_A0, (cd->stackframesize - 1) * 8 , RN, REG_SP); /* datasp */ N_LA(REG_A1, -N_PV_OFFSET, RN, REG_PV); /* pv */ - N_LAE(REG_A2, cd->stackframesize * 4, RN, REG_SP); /* old SP */ - N_L(REG_A3, (cd->stackframesize - 1) * 4, RN, REG_SP); /* return address */ + N_LAE(REG_A2, cd->stackframesize * 8, RN, REG_SP); /* old SP */ + N_L(REG_A3, (cd->stackframesize - 1) * 8, RN, REG_SP); /* return address */ disp = dseg_add_functionptr(cd, codegen_start_native_call); M_ILD_DSEG(REG_ITMP1, disp); @@ -3595,7 +3617,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* restore integer and float argument registers */ - j = 96 + (nmd->memuse * 4); + j = 96 + (nmd->memuse * 8); for (i = 0; i < md->paramcount; i++) { if (! md->params[i].inmemory) { @@ -3669,7 +3691,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) } } else { - s1 = cd->stackframesize * 4 + md->params[i].regoff; + s1 = cd->stackframesize * 8 + md->params[i].regoff; s2 = nmd->params[j].regoff; if (IS_2_WORD_TYPE(t)) { @@ -3684,7 +3706,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* registers keep unchanged. */ if (md->params[i].inmemory) { - s1 = cd->stackframesize * 4 + md->params[i].regoff; + s1 = cd->stackframesize * 8 + md->params[i].regoff; s2 = nmd->params[j].regoff; if (IS_2_WORD_TYPE(t)) { @@ -3739,7 +3761,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* remove native stackframe info */ - N_LAE(REG_A0, (cd->stackframesize - 1) * 4, RN, REG_SP); /* datasp */ + N_LAE(REG_A0, (cd->stackframesize - 1) * 8, RN, REG_SP); /* datasp */ disp = dseg_add_functionptr(cd, codegen_finish_native_call); M_ALD_DSEG(REG_ITMP1, disp); M_CALL(REG_ITMP1); @@ -3765,11 +3787,11 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* load return address */ - N_L(REG_ITMP2, (cd->stackframesize - 1) * 4, RN, REG_SP); + N_L(REG_ITMP2, (cd->stackframesize - 1) * 8, RN, REG_SP); /* remove stackframe */ - N_AHI(REG_SP, cd->stackframesize * 4); + N_AHI(REG_SP, cd->stackframesize * 8); /* test for exception */ @@ -3796,7 +3818,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* generate patcher stubs */ - emit_patcher_stubs(jd); + emit_patcher_traps(jd); } s4 codegen_reg_of_dst_notzero(jitdata *jd, instruction *iptr, s4 tempregnum) { diff --git a/src/vm/jit/s390/codegen.h b/src/vm/jit/s390/codegen.h index a536bf5a0..8a451a411 100644 --- a/src/vm/jit/s390/codegen.h +++ b/src/vm/jit/s390/codegen.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.h 8240 2007-07-29 20:36:47Z pm $ + $Id: codegen.h 8251 2007-08-01 15:26:59Z pm $ */ @@ -54,28 +54,9 @@ /* some patcher defines *******************************************************/ -#define PATCHER_CALL_SIZE 4 /* size in bytes of a patcher call */ - -#define PATCHER_NOPS \ - do { \ - /* do not generate additonal nops for long patcher branches */ \ - if (! CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) { \ - M_NOP; \ - M_NOP; \ - M_NOP; \ - } \ - } while (0) - -#define PATCHER_LONGBRANCHES_NOPS \ - do { \ - M_BR(SZ_BRC + (10 * 2)); \ - M_NOP2; M_NOP2; M_NOP2; M_NOP2; M_NOP2; M_NOP2; M_NOP2; M_NOP2; /* ild */ \ - M_NOP2; /* aadd */ \ - M_NOP2; /* jmp */ \ - } while (0) - -#define PATCHER_NOPS_SKIP 12 -#define PATCHER_LONGBRANCHES_NOPS_SKIP 24 +#define PATCHER_CALL_SIZE 2 /* size in bytes of a patcher call */ +#define PATCHER_NOPS M_NOP3 +#define PATCHER_NOPS_SKIP 2 /* branch defines ************************************************************/ @@ -692,6 +673,7 @@ #define M_JMP(rs, rd) _IF(rs == RN, N_BCR(DD_ANY, rd), N_BASR(rs, rd)) #define M_NOP N_BC(0, 0, RN, RN) #define M_NOP2 N_BCR(0, RN) +#define M_NOP3 N_BCR(0, 1) #define M_JSR(reg_ret, reg_addr) N_BASR(reg_ret, reg_addr) #define M_ICMP(a, b) N_CR(a, b) #define M_ICMPU(a, b) N_CLR(a, b) diff --git a/src/vm/jit/s390/emit.c b/src/vm/jit/s390/emit.c index 6f92167f3..8fa71c0d5 100644 --- a/src/vm/jit/s390/emit.c +++ b/src/vm/jit/s390/emit.c @@ -22,39 +22,35 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 8240 2007-07-29 20:36:47Z pm $ + $Id: emit.c 8296 2007-08-11 22:38:38Z pm $ */ - #include "config.h" #include +#include -#include "vm/types.h" - -#include "md-abi.h" - -#include "vm/jit/s390/codegen.h" -#include "vm/jit/s390/emit.h" - +#include "mm/memory.h" #if defined(ENABLE_THREADS) # include "threads/native/lock.h" #endif - #include "vm/builtin.h" +#include "vm/exceptions.h" +#include "vm/global.h" +#include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" #include "vm/jit/codegen-common.h" #include "vm/jit/emit-common.h" #include "vm/jit/jit.h" +#include "vm/jit/patcher-common.h" #include "vm/jit/replace.h" -#include "vm/jit/abi.h" -#include "vm/global.h" -#include "mm/memory.h" -#include "vm/exceptions.h" - -#define __PORTED__ +#include "vm/jit/s390/codegen.h" +#include "vm/jit/s390/emit.h" +#include "vm/jit/s390/md-abi.h" +#include "vm/types.h" +#include "vmcore/options.h" /* emit_load ******************************************************************* @@ -62,7 +58,7 @@ *******************************************************************************/ -__PORTED__ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) +s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) { codegendata *cd; s4 disp; @@ -108,7 +104,7 @@ __PORTED__ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg *******************************************************************************/ -__PORTED__ inline void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d) +void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d) { codegendata *cd; @@ -141,7 +137,7 @@ __PORTED__ inline void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, *******************************************************************************/ -__PORTED__ void emit_copy(jitdata *jd, instruction *iptr) +void emit_copy(jitdata *jd, instruction *iptr) { codegendata *cd; varinfo *src; @@ -210,234 +206,27 @@ __PORTED__ void emit_copy(jitdata *jd, instruction *iptr) } } +/* emit_trap ******************************************************************* -/* emit_patcher_stubs ********************************************************** - - Generates the code for the patcher stubs. + Emit a trap instruction and return the original machine code. *******************************************************************************/ -__PORTED__ void emit_patcher_stubs(jitdata *jd) +uint32_t emit_trap(codegendata *cd) { - - codegendata *cd; - patchref *pref; - u4 mcode; - u1 *savedmcodeptr; - u1 *tmpmcodeptr; - s4 targetdisp; - s4 disp; - u1 *ref; - - /* get required compiler data */ - - cd = jd->cd; - - /* generate code patching stub call code */ - - targetdisp = 0; + uint32_t mcode; - for (pref = cd->patchrefs; pref != NULL; pref = pref->next) { - /* check code segment size */ + /* Get machine code which is patched back in later. The + trap is 2 bytes long. */ - MCODECHECK(100); + mcode = *((u2 *) cd->mcodeptr); - /* Get machine code which is patched back in later. The - call is 1 instruction word long. */ + M_ILL(EXCEPTION_HARDWARE_PATCHER); - tmpmcodeptr = (u1 *) (cd->mcodebase + pref->branchpos); - - mcode = *((u4 *) tmpmcodeptr); - - /* Patch in the call to call the following code (done at - compile time). */ - - savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ - cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ - - disp = (savedmcodeptr) - (tmpmcodeptr); - - if (! N_VALID_BRANCH(disp)) { - /* Displacement overflow */ - - /* If LONGBRANCHES is not set, the flag and the error flag */ - - if (! CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) { - cd->flags |= (CODEGENDATA_FLAG_ERROR | - CODEGENDATA_FLAG_LONGBRANCHES); - } - - /* If error flag is set, do nothing. The method has to be recompiled. */ - - if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) && CODEGENDATA_HAS_FLAG_ERROR(cd)) { - return; - } - } - - if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) { - - /* Generating long branches */ - - disp = dseg_add_s4(cd, savedmcodeptr - cd->mcodebase - N_PV_OFFSET); - - M_ILD_DSEG(REG_ITMP3, disp); - M_AADD(REG_PV, REG_ITMP3); - - /* Do the branch at the end of NOP sequence. - * This way the patch position is at a *fixed* offset - * (PATCHER_LONGBRANCHES_NOPS_SKIP) of the return address. - */ - - cd->mcodeptr = tmpmcodeptr + PATCHER_LONGBRANCHES_NOPS_SKIP - SZ_BASR; - M_JMP(REG_ITMP3, REG_ITMP3); - } else { - - /* Generating short branches */ - - M_BSR(REG_ITMP3, disp); - } - - cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ - - /* create stack frame */ - - M_ASUB_IMM(6 * 4, REG_SP); - - /* move return address onto stack */ - - M_AST(REG_ITMP3, REG_SP, 5 * 4); - - /* move pointer to java_objectheader onto stack */ - -#if defined(ENABLE_THREADS) - /* create a virtual java_objectheader */ - - (void) dseg_add_unique_address(cd, NULL); /* flcword */ - (void) dseg_add_unique_address(cd, lock_get_initial_lock_word()); - disp = dseg_add_unique_address(cd, NULL); /* vftbl */ - - M_LDA_DSEG(REG_ITMP3, disp); - M_AST(REG_ITMP3, REG_SP, 4 * 4); -#else - /* nothing to do */ -#endif - - /* move machine code onto stack */ - - disp = dseg_add_s4(cd, mcode); - M_ILD_DSEG(REG_ITMP3, disp); - M_IST(REG_ITMP3, REG_SP, 3 * 4); - - /* move class/method/field reference onto stack */ - - disp = dseg_add_address(cd, pref->ref); - M_ALD_DSEG(REG_ITMP3, disp); - M_AST(REG_ITMP3, REG_SP, 2 * 4); - - /* move data segment displacement onto stack */ - - disp = dseg_add_s4(cd, pref->disp); - M_ILD_DSEG(REG_ITMP3, disp); - M_IST(REG_ITMP3, REG_SP, 1 * 4); - - /* move patcher function pointer onto stack */ - - disp = dseg_add_functionptr(cd, pref->patcher); - M_ALD_DSEG(REG_ITMP3, disp); - M_AST(REG_ITMP3, REG_SP, 0 * 4); - - if (targetdisp == 0) { - targetdisp = (cd->mcodeptr) - (cd->mcodebase); - - disp = dseg_add_functionptr(cd, asm_patcher_wrapper); - M_ALD_DSEG(REG_ITMP3, disp); - M_JMP(RN, REG_ITMP3); - } - else { - disp = ((cd->mcodebase) + targetdisp) - - (( cd->mcodeptr) ); - - emit_branch(cd, disp, BRANCH_UNCONDITIONAL, RN, 0); - } - } + return mcode; } -/* emit_replacement_stubs ****************************************************** - - Generates the code for the replacement stubs. - -*******************************************************************************/ -#if defined(ENABLE_REPLACEMENT) -void emit_replacement_stubs(jitdata *jd) -{ - codegendata *cd; - codeinfo *code; - rplpoint *rplp; - s4 disp; - s4 i, remain; - u1 *savedmcodeptr; - - /* get required compiler data */ - - cd = jd->cd; - code = jd->code; - - rplp = code->rplpoints; - - /* store beginning of replacement stubs */ - - code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase); - - for (i = 0; i < code->rplpointcount; ++i, ++rplp) { - /* do not generate stubs for non-trappable points */ - - if (rplp->flags & RPLPOINT_FLAG_NOTRAP) - continue; - - /* check code segment size */ - - MCODECHECK(512); - -#if !defined(NDEBUG) - savedmcodeptr = cd->mcodeptr; -#endif - - /* create stack frame - 8-byte aligned */ - - M_ASUB_IMM(REG_SP, 2 * 4); - - /* push address of `rplpoint` struct, will be used in asm_replacement_out */ - - disp = dseg_add_address(cd, rplp); - M_ALD_DSEG(REG_ITMP3, disp); - M_AST(REG_ITMP3, REG_SP, 0 * 4); - - /* jump to replacement function */ - - disp = dseg_add_functionptr(cd, asm_replacement_out); - M_ALD_DSEG(REG_ITMP3, disp); - M_JMP(RN, REG_ITMP3); - - assert((cd->mcodeptr - savedmcodeptr) <= REPLACEMENT_STUB_SIZE); - - /* pad with NOPs */ - - for (remain = REPLACEMENT_STUB_SIZE - (cd->mcodeptr - savedmcodeptr); remain > 0;) { - if (remain >= 4) { - M_NOP; - remain -= 4; - } else { - M_NOP2; - remain -= 2; - } - } - - assert((cd->mcodeptr - savedmcodeptr) == REPLACEMENT_STUB_SIZE); - } -} -#endif - /* emit_verbosecall_enter ****************************************************** Generates the code for the call trace. @@ -513,7 +302,7 @@ void emit_verbosecall_enter(jitdata *jd) /* offset to where first float arg is saved on stack */ foff = off + (INT_ARG_CNT * 8); /* offset to where first argument is passed on stack */ - aoff = (2 * 8) + stackframesize + (cd->stackframesize * 4); + aoff = (2 * 8) + stackframesize + (cd->stackframesize * 8); /* offset to destination on stack */ doff = 0; @@ -532,13 +321,15 @@ void emit_verbosecall_enter(jitdata *jd) N_STD(abi_registers_float_argument[fargctr], doff, RN, REG_SP); fargctr += 1; } else { /* passed on stack */ + /* if (IS_2_WORD_TYPE(t)) { N_MVC(doff, 8, REG_SP, aoff, REG_SP); - aoff += 8; } else { N_MVC(doff + 4, 4, REG_SP, aoff, REG_SP); - aoff += 4; } + */ + N_MVC(doff, 8, REG_SP, aoff, REG_SP); + aoff += 8; } } else { if (IS_2_WORD_TYPE(t)) { @@ -555,7 +346,7 @@ void emit_verbosecall_enter(jitdata *jd) iargctr += 1; } else { /* passed on stack */ N_MVC(doff + 4, 4, REG_SP, aoff, REG_SP); - aoff += 4; + aoff += 8; } } } @@ -689,7 +480,7 @@ void emit_verbosecall_exit(jitdata *jd) *******************************************************************************/ -__PORTED__ s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) +s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) { codegendata *cd; s4 disp; @@ -722,7 +513,7 @@ __PORTED__ s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 te *******************************************************************************/ -__PORTED__ s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) +s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) { codegendata *cd; s4 disp; diff --git a/src/vm/jit/s390/md-abi.c b/src/vm/jit/s390/md-abi.c index f0f6d1306..0257c5a2c 100644 --- a/src/vm/jit/s390/md-abi.c +++ b/src/vm/jit/s390/md-abi.c @@ -28,7 +28,7 @@ Changes: - $Id: md-abi.c 8123 2007-06-20 23:50:55Z michi $ + $Id: md-abi.c 8298 2007-08-12 18:49:16Z pm $ */ @@ -81,7 +81,7 @@ const s4 abi_registers_integer_temporary[] = { }; s4 nregdescfloat[] = { - REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_RES, REG_TMP, REG_RES, REG_TMP, + REG_ARG, REG_TMP, REG_ARG, REG_TMP, REG_SAV, REG_TMP, REG_SAV, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_END }; @@ -92,8 +92,8 @@ const s4 abi_registers_float_argument[] = { }; const s4 abi_registers_float_saved[] = { - /* nothing */ - -1 + 4, /* f4 */ + 6 /* f6 */ }; const s4 abi_registers_float_temporary[] = { @@ -111,13 +111,19 @@ const s4 abi_registers_float_temporary[] = { 15 /* f15/ft11 */ }; -/* md_param_alloc ************************************************************** +/* md_param_alloc_intern ******************************************************* - XXX + Allocates parameters to registers or stackslots for both native and java + methods. + + --- in: + slot: size in bytes of a stack slot + slots1w: number of stack slots used by a 1 word type parameter + slots2w: number of stack slots used by a 2 word type parameter *******************************************************************************/ -void md_param_alloc(methoddesc *md) +static void md_param_alloc_intern(methoddesc *md, s4 slot, s4 slots1w, s4 slots2w) { paramdesc *pd; s4 i; @@ -142,12 +148,14 @@ void md_param_alloc(methoddesc *md) if (iarg < INT_ARG_CNT) { pd->inmemory = false; pd->regoff = abi_registers_integer_argument[iarg]; + pd->index = iarg; iarg++; } else { pd->inmemory = true; - pd->regoff = stacksize * 4; - stacksize++; + pd->regoff = stacksize * slot; + pd->index = stacksize; + stacksize += slots1w; } break; @@ -158,14 +166,16 @@ void md_param_alloc(methoddesc *md) pd->regoff = PACK_REGS(abi_registers_integer_argument[iarg + 1], abi_registers_integer_argument[iarg]); + pd->index = PACK_REGS(iarg + 1, iarg); iarg += 2; } else { /* _ALIGN(stacksize); */ pd->inmemory = true; - pd->regoff = stacksize * 4; + pd->regoff = stacksize * slot; + pd->index = stacksize; iarg = INT_ARG_CNT; - stacksize += 2; + stacksize += slots2w; } break; @@ -173,12 +183,14 @@ void md_param_alloc(methoddesc *md) if (farg < FLT_ARG_CNT) { pd->inmemory = false; pd->regoff = abi_registers_float_argument[farg]; + pd->index = farg; farg++; } else { pd->inmemory = true; - pd->regoff = stacksize * 4; - stacksize++; + pd->regoff = stacksize * slot; + pd->index = stacksize; + stacksize += slots1w; } break; @@ -186,13 +198,15 @@ void md_param_alloc(methoddesc *md) if (farg < FLT_ARG_CNT) { pd->inmemory = false; pd->regoff = abi_registers_float_argument[farg]; + pd->index = farg; farg++; } else { /* _ALIGN(stacksize); */ pd->inmemory = true; - pd->regoff = stacksize * 4; - stacksize += 2; + pd->regoff = stacksize * slot; + pd->index = stacksize; + stacksize += slots2w; } break; @@ -222,12 +236,14 @@ void md_param_alloc(methoddesc *md) md->memuse = stacksize; } -void md_param_alloc_native(methoddesc *md) +void md_param_alloc(methoddesc *md) { - /* On PowerPC we use the same ABI for JIT method calls as for - * native method calls. */ + md_param_alloc_intern(md, 8, 1, 1); +} - md_param_alloc(md); +void md_param_alloc_native(methoddesc *md) +{ + md_param_alloc_intern(md, 4, 1, 2); } diff --git a/src/vm/jit/s390/md-abi.h b/src/vm/jit/s390/md-abi.h index 83db8ebed..ae55f7505 100644 --- a/src/vm/jit/s390/md-abi.h +++ b/src/vm/jit/s390/md-abi.h @@ -28,7 +28,7 @@ Changes: - $Id: md-abi.h 7839 2007-04-29 22:46:56Z pm $ + $Id: md-abi.h 8298 2007-08-12 18:49:16Z pm $ */ @@ -127,10 +127,10 @@ #define INT_RES_CNT 5 /* number of integer reserved registers */ #define FLT_REG_CNT 16 /* number of float registers */ -#define FLT_SAV_CNT 0 /* number of float callee saved registers */ +#define FLT_SAV_CNT 2 /* number of float callee saved registers */ #define FLT_ARG_CNT 2 /* number of float argument registers */ -#define FLT_TMP_CNT 12 /* number of float temporary registers */ -#define FLT_RES_CNT 2 /* number of float reserved registers */ +#define FLT_TMP_CNT 12 /* number of float temporary registers */ +#define FLT_RES_CNT 0 /* number of float reserved registers */ #define TRACE_ARGS_NUM 8 diff --git a/src/vm/jit/s390/md-asm.h b/src/vm/jit/s390/md-asm.h index 9cfd3ee5e..db6c69e0f 100644 --- a/src/vm/jit/s390/md-asm.h +++ b/src/vm/jit/s390/md-asm.h @@ -28,7 +28,7 @@ Changes: - $Id: md-asm.h 7839 2007-04-29 22:46:56Z pm $ + $Id: md-asm.h 8296 2007-08-11 22:38:38Z pm $ */ @@ -50,6 +50,7 @@ #define itmp3 %r14 #define v0 %r2 #define pv %r13 +#define ra %r14 #define mptr itmp2 #define xptr itmp1 diff --git a/src/vm/jit/s390/md.c b/src/vm/jit/s390/md.c index fd1f08c8d..b257a4035 100644 --- a/src/vm/jit/s390/md.c +++ b/src/vm/jit/s390/md.c @@ -1,6 +1,6 @@ -/* src/vm/jit/x86_64/md.c - machine dependent x86_64 Linux functions +/* src/vm/jit/s390/md.c - machine dependent s390 Linux functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, + Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,21 +22,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: Edwin Steiner - - $Id: md.c 8243 2007-07-31 08:57:54Z michi $ + $Id: md.c 8298 2007-08-12 18:49:16Z pm $ */ + #define _GNU_SOURCE #include "config.h" #include +#include #include #include @@ -50,6 +46,7 @@ #include "vm/exceptions.h" #include "vm/signallocal.h" #include "vm/jit/asmpart.h" +#include "vm/jit/abi.h" #include "vm/jit/methodheader.h" #include "vm/jit/stacktrace.h" @@ -90,7 +87,7 @@ void md_dump_context(u1 *pc, mcontext_t *mc) { int i; u1 *pv; methodinfo *m; - + union { u8 l; fpreg_t fr; @@ -104,7 +101,7 @@ void md_dump_context(u1 *pc, mcontext_t *mc) { if (pv == NULL) { log_println("No java method found at location."); } else { - m = ((codeinfo *)(pv + CodeinfoPointer))->m; + m = (*(codeinfo **)(pv + CodeinfoPointer))->m; log_println( "Java method: class %s, method %s, descriptor %s.", utf_bytes(m->class->name), utf_bytes(m->name), utf_bytes(m->descriptor) @@ -145,18 +142,18 @@ void md_dump_context(u1 *pc, mcontext_t *mc) { void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - s4 type; - ptrint val; - java_objectheader *e; - s4 base; - s4 is_null; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + int type; + intptr_t val; + void *p; + s4 base; + s4 is_null; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -197,31 +194,37 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc; - _mc->gregs[REG_ITMP1_XPTR] = (ptrint) e; - _mc->psw.addr = (ptrint) asm_handle_exception; + if (p != NULL) { + _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc; + _mc->psw.addr = (intptr_t) asm_handle_exception; + } + else { + _mc->psw.addr = (intptr_t) xpc; + } } -void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *xpc; - u1 *ra; - u1 *pv; - u1 *sp; - s4 type; - ptrint val; - java_objectheader *e; - s4 reg; +void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) +{ + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *xpc; + u1 *ra; + u1 *pv; + u1 *sp; + int type; + intptr_t val; + void *p; + s4 reg; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -245,18 +248,22 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) { stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gregs[REG_ITMP1_XPTR] = (ptrint)e; - _mc->gregs[REG_ITMP2_XPC] = (ptrint)xpc; - _mc->psw.addr = (ptrint) asm_handle_exception; - + if (p != NULL) { + _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc; + _mc->psw.addr = (intptr_t) asm_handle_exception; + } + else { + _mc->psw.addr = (intptr_t) xpc; + } } else { #if !defined(NDEBUG) md_dump_context(xpc, _mc); @@ -274,18 +281,18 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) { void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u1 *pc; - s4 r1, r2; - s4 type; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u1 *pc; + int r1, r2; + int type; + intptr_t val; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -305,7 +312,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) (_mc->gregs[r1 + 1] == 0x80000000) && (_mc->gregs[r2] == 0xFFFFFFFF) ) { - /* handle special case */ + /* handle special case 0x80000000 / 0xFFFFFFFF that fails on hardware */ /* next instruction */ pc = (u1 *)_mc->psw.addr; /* reminder */ @@ -316,7 +323,8 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) _mc->psw.addr = (ptrint) pc; return; - } else if (_mc->gregs[r2] == 0) { + } + else if (_mc->gregs[r2] == 0) { /* division by 0 */ pv = (u1 *)_mc->gregs[REG_PV] - N_PV_OFFSET; @@ -330,17 +338,17 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ stacktrace_remove_stackframeinfo(&sfi); - _mc->gregs[REG_ITMP1_XPTR] = (ptrint)e; - _mc->gregs[REG_ITMP2_XPC] = (ptrint)xpc; - _mc->psw.addr = (ptrint) asm_handle_exception; + _mc->gregs[REG_ITMP1_XPTR] = (intptr_t) p; + _mc->gregs[REG_ITMP2_XPC] = (intptr_t) xpc; + _mc->psw.addr = (intptr_t) asm_handle_exception; return; } @@ -448,7 +456,7 @@ u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize) /* on S390 the return address is located on the top of the stackframe */ - ra = *((u1 **) (sp + framesize - SIZEOF_VOID_P)); + ra = *((u1 **) (sp + framesize - 8)); return ra; } @@ -620,6 +628,110 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save } #endif +void md_handle_exception(int32_t *regs, int64_t *fregs, int32_t *out) { + + uint8_t *xptr; + uint8_t *xpc; + uint8_t *sp; + uint8_t *pv; + uint8_t *ra; + uint8_t *handler; + int32_t framesize; + int32_t intsave; + int32_t fltsave; + int64_t *savearea; + int i; + int reg; + int loops = 0; + + /* get registers */ + + xptr = *(uint8_t **)(regs + REG_ITMP1_XPTR); + xpc = *(uint8_t **)(regs + REG_ITMP2_XPC); + sp = *(uint8_t **)(regs + REG_SP); + + + /* initialize number of calle saved int regs to restore to 0 */ + out[0] = 0; + + /* initialize number of calle saved flt regs to restore to 0 */ + out[1] = 0; + + do { + + ++loops; + + pv = codegen_get_pv_from_pc(xpc); + + handler = exceptions_handle_exception(xptr, xpc, pv, sp); + + if (handler == NULL) { + + /* exception was not handled + * get values of calee saved registers and remove stack frame + */ + + /* read stuff from data segment */ + + framesize = *(int32_t *)(pv + FrameSize); + + intsave = *(int32_t *)(pv + IntSave); + if (intsave > out[0]) { + out[0] = intsave; + } + + fltsave = *(int32_t *)(pv + FltSave); + if (fltsave > out[1]) { + out[1] = fltsave; + } + + /* pointer to register save area */ + + savearea = (int64_t *)(sp + framesize - 8); + + /* return address */ + + ra = *(uint8_t **)(sp + framesize - 8); + + /* restore saved registers */ + + for (i = 0; i < intsave; ++i) { + --savearea; + reg = abi_registers_integer_saved[INT_SAV_CNT - 1 - i]; + regs[reg] = *(int32_t *)(savearea); + } + + for (i = 0; i < fltsave; ++i) { + --savearea; + reg = abi_registers_float_saved[FLT_SAV_CNT - 1 - i]; + fregs[reg] = *savearea; + } + + /* remove stack frame */ + + sp += framesize; + + /* new xpc is call before return address */ + + xpc = ra; + + } else { + xpc = handler; + } + } while (handler == NULL); + + /* write new values for registers */ + + *(uint8_t **)(regs + REG_ITMP1_XPTR) = xptr; + *(uint8_t **)(regs + REG_ITMP2_XPC) = xpc; + *(uint8_t **)(regs + REG_SP) = sp; + *(uint8_t **)(regs + REG_PV) = pv - 0XFFC; + + /* maybe leaf flag */ + + out[2] = (loops == 1); +} + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/s390/patcher.c b/src/vm/jit/s390/patcher.c index 3222c3daf..2eb44fe5a 100644 --- a/src/vm/jit/s390/patcher.c +++ b/src/vm/jit/s390/patcher.c @@ -26,150 +26,38 @@ Authors: Christian Thalinger - Changes: + Changes: Peter Molnar - $Id: patcher.c 8195 2007-07-11 11:27:55Z pm $ - - GENERATED PATCHER BRANCH AFTER PATCH - - Short patcher call: - - foo bras %r14, OFFSET foo - bar ===> bar ===> bar - baz baz baz - - Short patcher call with nops: - PATCHER_NOPS_SKIP <-+ - | - nop bras %r14, OFFSET nop --+ - nop ===> nop ===> nop | - nop nop nop --+ - foo foo foo - - Long pacher call: - PATCHER_LONGBRANCHES_NOPS_SKIP <-+ - | - br exit: ild itmp3, disp(pv) br exit -+ - nop aadd pv, itmp3 aadd pv, itmp3 | - nop ===> nop ===> nop | - ..... .... .... | - nop basr itmp3, itmp3 basr itmp3, itmp3 -+ - exit: exit: + $Id: patcher.c 8268 2007-08-07 13:24:43Z twisti $ */ #include "config.h" -#include "vm/types.h" -#include "vm/jit/s390/codegen.h" -#include "vm/jit/s390/md-abi.h" +#include +#include #include "mm/memory.h" #include "native/native.h" #include "vm/builtin.h" -#include "vmcore/class.h" #include "vm/exceptions.h" -#include "vmcore/field.h" #include "vm/initialize.h" +#include "vm/jit/patcher-common.h" +#include "vm/jit/s390/codegen.h" +#include "vm/jit/s390/md-abi.h" +#include "vm/jit/stacktrace.h" +#include "vm/resolve.h" +#include "vm/types.h" +#include "vmcore/class.h" +#include "vmcore/field.h" #include "vmcore/options.h" #include "vmcore/references.h" -#include "vm/resolve.h" -#include "vm/jit/patcher.h" -#include "vm/jit/stacktrace.h" - -#include -#define OOPS() assert(0); -#define __PORTED__ - -/* A normal patcher branch done using BRAS */ -#define PATCHER_IS_SHORTBRANCH(brcode) ((brcode & 0xFF0F0000) == 0xA7050000) - -/* patcher_wrapper ************************************************************* - - Wrapper for all patchers. It also creates the stackframe info - structure. - - If the return value of the patcher function is false, it gets the - exception object, clears the exception pointer and returns the - exception. - -*******************************************************************************/ - -java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) -{ - stackframeinfo sfi; - u1 *xpc; - java_objectheader *o; - functionptr f; - bool result; - java_objectheader *e; - - /* define the patcher function */ - - bool (*patcher_function)(u1 *); - - /* get stuff from the stack */ - - xpc = (u1 *) *((ptrint *) (sp + 5 * 4)); - o = (java_objectheader *) *((ptrint *) (sp + 4 * 4)); - f = (functionptr) *((ptrint *) (sp + 0 * 4)); - - /* For a normal branch, the patch position is SZ_BRAS bytes before the RA. - * For long branches it is PATCHER_LONGBRANCHES_NOPS_SKIP before the RA. - */ - - if (PATCHER_IS_SHORTBRANCH(*(u4 *)(xpc - SZ_BRAS))) { - xpc = xpc - SZ_BRAS; - } else { - xpc = xpc - PATCHER_LONGBRANCHES_NOPS_SKIP; - } - - *((ptrint *) (sp + 5 * 4)) = (ptrint) xpc; - - /* store PV into the patcher function position */ - - *((ptrint *) (sp + 0 * 4)) = (ptrint) pv; - - /* cast the passed function to a patcher function */ - - patcher_function = (bool (*)(u1 *)) (ptrint) f; - - /* enter a monitor on the patching position */ - - PATCHER_MONITORENTER; - - /* create the stackframeinfo */ - - /* RA is passed as NULL, but the XPC is correct and can be used in - stacktrace_create_extern_stackframeinfo for - md_codegen_get_pv_from_pc. */ - - stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + (6 * 4), ra, xpc); - - /* call the proper patcher function */ - - result = (patcher_function)(sp); - - /* remove the stackframeinfo */ - - stacktrace_remove_stackframeinfo(&sfi); - /* check for return value and exit accordingly */ - - if (result == false) { - e = exceptions_get_and_clear_exception(); - - PATCHER_MONITOREXIT; - - return e; - } - - PATCHER_MARK_PATCHED_MONITOREXIT; - - return NULL; -} +#define PATCH_BACK_ORIGINAL_MCODE \ + *((u2 *) pr->mpc) = (u2) pr->mcode; +#define PATCHER_TRACE /* patcher_get_putstatic ******************************************************* @@ -177,22 +65,18 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) *******************************************************************************/ -bool patcher_get_putstatic(u1 *sp) +bool patcher_get_putstatic(patchref_t *pr) { - u1 *ra; - u4 mcode; unresolved_field *uf; - s4 disp; + u1 *datap; fieldinfo *fi; - u1 *pv; + + PATCHER_TRACE; /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - uf = (unresolved_field *) *((ptrint *) (sp + 2 * 4)); - disp = *((s4 *) (sp + 1 * 4)); - pv = (u1 *) *((ptrint *) (sp + 0 * 4)); + uf = (unresolved_field *) pr->ref; + datap = (u1 *) pr->datap; /* get the fieldinfo */ @@ -205,11 +89,11 @@ bool patcher_get_putstatic(u1 *sp) if (!initialize_class(fi->class)) return false; - *((ptrint *) (pv + disp)) = (ptrint) &(fi->value); + PATCH_BACK_ORIGINAL_MCODE; - /* patch back original code */ + /* patch the field value's address */ - *((u4 *) ra) = mcode; + *((intptr_t *) datap) = (intptr_t) fi->value; return true; } @@ -221,37 +105,31 @@ bool patcher_get_putstatic(u1 *sp) *******************************************************************************/ -bool patcher_get_putfield(u1 *sp) +bool patcher_get_putfield(patchref_t *pr) { u1 *ra; - u4 mcode, brcode; unresolved_field *uf; fieldinfo *fi; - u1 byte; s4 disp; + PATCHER_TRACE; + /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - uf = (unresolved_field *) *((ptrint *) (sp + 2 * 4)); - disp = *((s4 *) (sp + 1 * 4)); + ra = (u1 *) pr->mpc; + uf = (unresolved_field *) pr->ref; + disp = pr->disp; /* get the fieldinfo */ if (!(fi = resolve_field_eager(uf))) return false; - /* patch back original code */ - - brcode = *((u4 *) ra); - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; /* If NOPs are generated, skip them */ - if (! PATCHER_IS_SHORTBRANCH(brcode)) - ra += PATCHER_LONGBRANCHES_NOPS_SKIP; - else if (opt_shownops) + if (opt_shownops) ra += PATCHER_NOPS_SKIP; /* If there is an operand load before, skip the load size passed in disp (see ICMD_PUTFIELD) */ @@ -281,59 +159,52 @@ bool patcher_get_putfield(u1 *sp) *******************************************************************************/ -__PORTED__ bool patcher_invokestatic_special(u1 *sp) +bool patcher_invokestatic_special(patchref_t *pr) { - u1 *ra; - u4 mcode; unresolved_method *um; - s4 disp; - u1 *pv; + u1 *datap; methodinfo *m; + PATCHER_TRACE; + /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - um = (unresolved_method *) *((ptrint *) (sp + 2 * 4)); - disp = *((s4 *) (sp + 1 * 4)); - pv = (u1 *) *((ptrint *) (sp + 0 * 4)); + um = (unresolved_method *) pr->ref; + datap = (u1 *) pr->datap; /* get the fieldinfo */ if (!(m = resolve_method_eager(um))) return false; - *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine; - - /* patch back original code */ - - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; /* patch stubroutine */ + *((ptrint *) datap) = (ptrint) m->stubroutine; + return true; } - /* patcher_invokevirtual ******************************************************* Machine code: *******************************************************************************/ -bool patcher_invokevirtual(u1 *sp) +bool patcher_invokevirtual(patchref_t *pr) { u1 *ra; - u4 mcode, brcode; unresolved_method *um; methodinfo *m; - s4 off; + s4 off; + + PATCHER_TRACE; /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - um = (unresolved_method *) *((ptrint *) (sp + 2 * 4)); + ra = (u1 *) pr->mpc; + um = (unresolved_method *) pr->ref; /* get the fieldinfo */ @@ -342,14 +213,11 @@ bool patcher_invokevirtual(u1 *sp) /* patch back original code */ - brcode = *((u4 *) ra); - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; /* If NOPs are generated, skip them */ - if (! PATCHER_IS_SHORTBRANCH(brcode)) - ra += PATCHER_LONGBRANCHES_NOPS_SKIP; - else if (opt_shownops) + if (opt_shownops) ra += PATCHER_NOPS_SKIP; /* patch vftbl index */ @@ -372,19 +240,19 @@ bool patcher_invokevirtual(u1 *sp) *******************************************************************************/ -bool patcher_invokeinterface(u1 *sp) +bool patcher_invokeinterface(patchref_t *pr) { u1 *ra; - u4 mcode, brcode; unresolved_method *um; methodinfo *m; s4 idx, off; + PATCHER_TRACE; + /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - um = (unresolved_method *) *((ptrint *) (sp + 2 * 4)); + ra = (u1 *) pr->mpc; + um = (unresolved_method *) pr->ref; /* get the fieldinfo */ @@ -393,14 +261,11 @@ bool patcher_invokeinterface(u1 *sp) /* patch back original code */ - brcode = *((u4 *) ra); - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; /* If NOPs are generated, skip them */ - if (! PATCHER_IS_SHORTBRANCH(brcode)) - ra += PATCHER_LONGBRANCHES_NOPS_SKIP; - else if (opt_shownops) + if (opt_shownops) ra += PATCHER_NOPS_SKIP; /* get interfacetable index */ @@ -433,35 +298,29 @@ bool patcher_invokeinterface(u1 *sp) *******************************************************************************/ -__PORTED__ bool patcher_resolve_classref_to_flags(u1 *sp) +bool patcher_resolve_classref_to_flags(patchref_t *pr) { constant_classref *cr; - s4 disp; - u1 *pv; + u1 *datap; classinfo *c; - u4 mcode; - u1 *ra; + + PATCHER_TRACE; /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - cr = (constant_classref *) *((ptrint *) (sp + 2 * 4)); - disp = *((s4 *) (sp + 1 * 4)); - pv = (u1 *) *((ptrint *) (sp + 0 * 4)); + cr = (constant_classref *) pr->ref; + datap = (u1 *) pr->datap; /* get the fieldinfo */ if (!(c = resolve_classref_eager(cr))) return false; - /* patch class flags */ - - *((s4 *) (pv + disp)) = (s4) c->flags; + PATCH_BACK_ORIGINAL_MCODE; - /* patch back original code */ + /* patch class flags */ - *((u4 *) ra) = mcode; + *((s4 *) datap) = (s4) c->flags; return true; } @@ -474,35 +333,29 @@ __PORTED__ bool patcher_resolve_classref_to_flags(u1 *sp) *******************************************************************************/ -__PORTED__ bool patcher_resolve_classref_to_classinfo(u1 *sp) +bool patcher_resolve_classref_to_classinfo(patchref_t *pr) { constant_classref *cr; - s4 disp; - u1 *pv; + u1 *datap; classinfo *c; - u4 mcode; - u1 *ra; + + PATCHER_TRACE; /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - cr = (constant_classref *) *((ptrint *) (sp + 2 * 4)); - disp = *((s4 *) (sp + 1 * 4)); - pv = (u1 *) *((ptrint *) (sp + 0 * 4)); + cr = (constant_classref *) pr->ref; + datap = (u1 *) pr->datap; /* get the classinfo */ if (!(c = resolve_classref_eager(cr))) return false; - /* patch the classinfo pointer */ - - *((ptrint *) (pv + disp)) = (ptrint) c; + PATCH_BACK_ORIGINAL_MCODE; - /* patch back original code */ + /* patch the classinfo pointer */ - *((u4 *) ra) = mcode; + *((ptrint *) datap) = (ptrint) c; return true; } @@ -514,35 +367,29 @@ __PORTED__ bool patcher_resolve_classref_to_classinfo(u1 *sp) *******************************************************************************/ -bool patcher_resolve_classref_to_vftbl(u1 *sp) +bool patcher_resolve_classref_to_vftbl(patchref_t *pr) { constant_classref *cr; - s4 disp; - u1 *pv; + u1 *datap; classinfo *c; - u4 mcode; - u1 *ra; + + PATCHER_TRACE; /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - cr = (constant_classref *) *((ptrint *) (sp + 2 * 4)); - disp = *((s4 *) (sp + 1 * 4)); - pv = (u1 *) *((ptrint *) (sp + 0 * 4)); + cr = (constant_classref *) pr->ref; + datap = (u1 *) pr->datap; /* get the fieldinfo */ if (!(c = resolve_classref_eager(cr))) return false; - /* patch super class' vftbl */ - - *((ptrint *) (pv + disp)) = (ptrint) c->vftbl; + PATCH_BACK_ORIGINAL_MCODE; - /* patch back original code */ + /* patch super class' vftbl */ - *((u4 *) ra) = mcode; + *((ptrint *) datap) = (ptrint) c->vftbl; return true; } @@ -553,18 +400,19 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp) *******************************************************************************/ -bool patcher_checkcast_instanceof_interface(u1 *sp) +bool patcher_checkcast_instanceof_interface(patchref_t *pr) { + u1 *ra; - u4 mcode, brcode; constant_classref *cr; classinfo *c; + PATCHER_TRACE; + /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - cr = (constant_classref *) *((ptrint *) (sp + 2 * 4)); + ra = (u1 *) pr->mpc; + cr = (constant_classref *) pr->ref; /* get the fieldinfo */ @@ -573,14 +421,11 @@ bool patcher_checkcast_instanceof_interface(u1 *sp) /* patch back original code */ - brcode = *((u4 *) ra); - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; /* If NOPs are generated, skip them */ - if (! PATCHER_IS_SHORTBRANCH(brcode)) - ra += PATCHER_LONGBRANCHES_NOPS_SKIP; - else if (opt_shownops) + if (opt_shownops) ra += PATCHER_NOPS_SKIP; /* patch super class index */ @@ -626,17 +471,15 @@ bool patcher_checkcast_instanceof_interface(u1 *sp) *******************************************************************************/ -__PORTED__ bool patcher_clinit(u1 *sp) +bool patcher_clinit(patchref_t *pr) { - u1 *ra; - u4 mcode; classinfo *c; + PATCHER_TRACE; + /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - c = (classinfo *) *((ptrint *) (sp + 2 * 4)); + c = (classinfo *)pr->ref; /* check if the class is initialized */ @@ -646,7 +489,7 @@ __PORTED__ bool patcher_clinit(u1 *sp) /* patch back original code */ - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; return true; } @@ -661,17 +504,15 @@ __PORTED__ bool patcher_clinit(u1 *sp) *******************************************************************************/ #ifdef ENABLE_VERIFIER -__PORTED__ bool patcher_athrow_areturn(u1 *sp) +bool patcher_athrow_areturn(patchref_t *pr) { - u1 *ra; - u4 mcode; unresolved_class *uc; + PATCHER_TRACE; + /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - uc = (unresolved_class *) *((ptrint *) (sp + 2 * 4)); + uc = (unresolved_class *) pr->ref; /* resolve the class and check subtype constraints */ @@ -680,7 +521,7 @@ __PORTED__ bool patcher_athrow_areturn(u1 *sp) /* patch back original code */ - *((u4 *) ra) = mcode; + PATCH_BACK_ORIGINAL_MCODE; return true; } @@ -692,41 +533,34 @@ __PORTED__ bool patcher_athrow_areturn(u1 *sp) *******************************************************************************/ #if !defined(WITH_STATIC_CLASSPATH) -__PORTED__ bool patcher_resolve_native(u1 *sp) +bool patcher_resolve_native_function(patchref_t *pr) { - u1 *ra; - u4 mcode; methodinfo *m; + u1 *datap; functionptr f; - s4 disp; - u1 *pv; + + PATCHER_TRACE; /* get stuff from the stack */ - ra = (u1 *) *((ptrint *) (sp + 5 * 4)); - mcode = *((u4 *) (sp + 3 * 4)); - disp = *((s4 *) (sp + 1 * 4)); - m = (methodinfo *) *((ptrint *) (sp + 2 * 4)); - pv = (u1 *) *((ptrint *) (sp + 0 * 4)); + m = (methodinfo *) pr->ref; + datap = (u1 *) pr->datap; /* resolve native function */ if (!(f = native_resolve_function(m))) return false; - /* patch native function pointer */ - - *((ptrint *) (pv + disp)) = (ptrint) f; + PATCH_BACK_ORIGINAL_MCODE; - /* patch back original code */ + /* patch native function pointer */ - *((u4 *) ra) = mcode; + *((ptrint *) datap) = (ptrint) f; return true; } #endif /* !defined(WITH_STATIC_CLASSPATH) */ - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/show.c b/src/vm/jit/show.c index 0c2d989ed..11f01a5c3 100644 --- a/src/vm/jit/show.c +++ b/src/vm/jit/show.c @@ -64,7 +64,7 @@ /* global variables ***********************************************************/ #if defined(ENABLE_THREADS) && !defined(NDEBUG) -static java_objectheader *show_global_lock; +static java_object_t *show_global_lock; #endif @@ -87,7 +87,7 @@ bool show_init(void) #if defined(ENABLE_THREADS) /* initialize the show lock */ - show_global_lock = NEW(java_objectheader); + show_global_lock = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(show_global_lock); #endif @@ -696,7 +696,7 @@ void show_basicblock(jitdata *jd, basicblock *bptr, int stage) if (stage >= SHOW_PARSE) { \ putchar('"'); \ utf_display_printable_ascii( \ - javastring_toutf((java_objectheader *)(val), false)); \ + javastring_toutf((java_handle_t *)(val), false)); \ printf("\" "); \ } \ else { \ diff --git a/src/vm/jit/sparc64/Makefile.am b/src/vm/jit/sparc64/Makefile.am index 60af8ea3e..fd86b6371 100644 --- a/src/vm/jit/sparc64/Makefile.am +++ b/src/vm/jit/sparc64/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/sparc64/Makefile.am ## -## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, +## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, ## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, ## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, ## J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,13 +22,6 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## Alexander Jordan -## -## Changes: -## ## $Id: Makefile.am 4563 2006-03-06 13:03:05Z twisti $ ## Process this file with automake to produce Makefile.in @@ -44,10 +37,6 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) LIBS = -BUILT_SOURCES = offsets.h - -CLEANFILES = offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h \ @@ -78,10 +67,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/sparc64/arch.h b/src/vm/jit/sparc64/arch.h index 15e2a1c45..b4806af76 100644 --- a/src/vm/jit/sparc64/arch.h +++ b/src/vm/jit/sparc64/arch.h @@ -104,7 +104,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 4 /* bytes */ -#define REPLACEMENT_STUB_SIZE 5 /* words */ /* XXX adapt for sparc64 */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/sparc64/asmpart.S b/src/vm/jit/sparc64/asmpart.S index 9dd83903d..671afc88e 100644 --- a/src/vm/jit/sparc64/asmpart.S +++ b/src/vm/jit/sparc64/asmpart.S @@ -29,10 +29,11 @@ #include "config.h" -#include "vm/jit/sparc64/md-abi.h" -#include "vm/jit/sparc64/offsets.h" #include "md-asm.h" +#include "vm/jit/sparc64/md-abi.h" + + .register %g2,#scratch /* define as scratch */ .register %g3,#scratch /* XXX reserve for application */ .text @@ -56,9 +57,6 @@ .global asm_abstractmethoderror - .global asm_criticalsections - .global asm_getclassvalues_atomic - .global asm_store_fp_state_reg .global asm_load_fp_state_reg @@ -442,34 +440,6 @@ asm_load_fp_state_reg: nop - - -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: -/* not doing a window save, using the global temporary registers */ - ldsw [offbaseval+%o0],itmp1 - ldsw [offdiffval+%o0],itmp2 - ldsw [offbaseval+%o1],itmp3 -_crit_end: - stw itmp1,[offcast_super_baseval+%o2] - stw itmp2,[offcast_super_diffval+%o2] - stw itmp3,[offcast_sub_baseval+%o2] - jmpl ra_caller+8,zero /* caller's ra, b/c no window save */ - nop - - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .xword _crit_begin - .xword _crit_end - .xword _crit_restart -#endif - .xword 0 - - /* disable exec-stacks ********************************************************/ #if defined(__linux__) && defined(__ELF__) diff --git a/src/vm/jit/sparc64/codegen.c b/src/vm/jit/sparc64/codegen.c index 670246d06..c56421a99 100644 --- a/src/vm/jit/sparc64/codegen.c +++ b/src/vm/jit/sparc64/codegen.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -42,6 +43,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/native.h" #include "vm/builtin.h" #include "vm/exceptions.h" @@ -310,7 +312,7 @@ bool codegen_emit(jitdata *jd) for (i = 0; i < jd->varcount; i++) { varinfo* uvar = VAR(i); - if (IS_FLT_DBL_TYPE(uvar->type)) + if (IS_FLT_DBL_TYPE(uvar->type) || IS_INMEMORY(uvar->flags)) continue; s2 = uvar->vv.regoff; @@ -1604,16 +1606,16 @@ bool codegen_emit(jitdata *jd) case ICMD_GETSTATIC: /* ... ==> ..., value */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - uf = iptr->sx.s23.s3.uf; + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; disp = dseg_add_unique_address(cd, uf); codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); } else { - fi = iptr->sx.s23.s3.fmiref->p.field; + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, disp); @@ -1649,16 +1651,16 @@ bool codegen_emit(jitdata *jd) case ICMD_PUTSTATIC: /* ..., value ==> ... */ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - uf = iptr->sx.s23.s3.uf; + uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; disp = dseg_add_unique_address(cd, uf); codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); } else { - fi = iptr->sx.s23.s3.fmiref->p.field; + fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, disp); @@ -1697,14 +1699,14 @@ bool codegen_emit(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; - disp = dseg_add_unique_address(cd, uf); + disp = dseg_add_unique_address(cd, uf); codegen_add_patch_ref(cd, PATCHER_get_putstatic, uf, disp); } else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) codegen_add_patch_ref(cd, PATCHER_clinit, fi->class, disp); @@ -2570,7 +2572,7 @@ gen_method: sizeof(methodptr) * lm->vftblindex; /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_OUT0,OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_OUT0,OFFSET(java_object_t, vftbl)); M_ALD(REG_PV_CALLER, REG_METHODPTR, s1); /* generate the actual call */ @@ -2600,7 +2602,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_OUT0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_OUT0, OFFSET(java_object_t, vftbl)); M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV_CALLER, REG_METHODPTR, s2); @@ -2700,7 +2702,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_3, s1); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_ADD_IMM(REG_ITMP3, -superindex, REG_ITMP3); @@ -2736,7 +2738,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_5, s1); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; @@ -2872,7 +2874,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_3, s1); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength)); M_CMP_IMM(REG_ITMP3, superindex); M_BLE(4); @@ -2906,7 +2908,7 @@ gen_method: emit_label_beqz(cd, BRANCH_LABEL_5, s1); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); CODEGEN_CRITICAL_SECTION_START; @@ -3263,7 +3265,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) sizeof(stackframeinfo) / SIZEOF_VOID_P + sizeof(localref_table) / SIZEOF_VOID_P + md->paramcount + /* for saving arguments over calls */ - nmd->memuse + /* nmd knows about the native stackframe layout */ + nmd->memuse + /* nmd->memuse includes the (6) abi params */ WINSAVE_CNT; @@ -3302,7 +3304,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) } #endif - /* save float argument registers (into abi parameter slots) */ + /* save float argument registers */ assert(ABIPARAMS_CNT >= FLT_ARG_CNT); @@ -3351,7 +3353,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) s1 = REG_WINDOW_TRANSPOSE(s1); if (!nmd->params[j].inmemory) { - s2 = nat_argintregs[nmd->params[j].regoff]; + s2 = nmd->params[j].regoff; M_INTMOVE(s1, s2); } else { /* nmd's regoff is relative to the start of the param array */ @@ -3370,7 +3372,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) } s1 = md->params[i].regoff + cd->stackframesize * 8; - s2 = BIAS + WINSAVE_CNT + 8 + nmd->params[j].regoff; + s2 = BIAS + WINSAVE_CNT * 8 + nmd->params[j].regoff; M_ALD(REG_ITMP1, REG_SP, CSTACK + s1); M_AST(REG_ITMP1, REG_SP, s2); } @@ -3404,25 +3406,25 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) } else { - s1 = md->params[i].regoff + cd->stackframesize * 8; + s1 = md->params[i].regoff; if (!nmd->params[j].inmemory) { /* JIT stack -> NAT reg */ - s2 = BIAS + WINSAVE_CNT * 8 + nmd->params[j].regoff; - M_DLD(s2, REG_SP, s1); + s2 = nmd->params[j].regoff; + M_DLD(s2, REG_FP, JITSTACK + s1); } else { /* JIT stack -> NAT stack */ - s2 = nmd->params[j].regoff - 6 * 8; + s2 = WINSAVE_CNT * 8 + nmd->params[j].regoff; /* The FTMP register may already be loaded with args */ /* we know $f0 is unused because of the env pointer */ - M_DLD(REG_F0, REG_SP, CSTACK + s1); - M_DST(REG_F0, REG_SP, CSTACK + s2); + M_DLD(REG_F0, REG_FP, JITSTACK + s1); + M_DST(REG_F0, REG_SP, BIAS + s2); } } } diff --git a/src/vm/jit/sparc64/emit.c b/src/vm/jit/sparc64/emit.c index c89716dc8..9ce83232d 100644 --- a/src/vm/jit/sparc64/emit.c +++ b/src/vm/jit/sparc64/emit.c @@ -123,7 +123,7 @@ void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d) COUNT_WRITE_SPILLS(dst) disp = JITSTACK + dst->vv.regoff; - + switch(dst->type) { case TYPE_INT: @@ -552,6 +552,27 @@ void emit_exception_check(codegendata *cd, instruction *iptr) } +/* emit_trap ******************************************************************* + + Emit a trap instruction and return the original machine code. + +*******************************************************************************/ + +uint32_t emit_trap(codegendata *cd) +{ + uint32_t mcode; + + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ + + mcode = *((u4 *) cd->mcodeptr); + + M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER); + + return mcode; +} + + /* emit_patcher_stubs ********************************************************** Generates the code for the patcher stubs. diff --git a/src/vm/jit/sparc64/linux/md-os.c b/src/vm/jit/sparc64/linux/md-os.c index 051e15894..ffa0b4495 100644 --- a/src/vm/jit/sparc64/linux/md-os.c +++ b/src/vm/jit/sparc64/linux/md-os.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #include "vm/types.h" @@ -37,7 +38,6 @@ #include "vm/jit/sparc64/codegen.h" #include "vm/jit/sparc64/md-abi.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" #include "vm/stringlocal.h" #include "vm/jit/asmpart.h" @@ -98,13 +98,13 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *info , void *_p) u1 *ra; u1 *xpc; u4 mcode; - s4 d; - s4 s1; - s4 disp; - ptrint val; - ptrint addr; - s4 type; - java_objectheader *e; + int d; + int s1; + int16_t disp; + intptr_t val; + intptr_t addr; + int type; + void *p; ctx = (sigcontext *) info; @@ -137,17 +137,17 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *info , void *_p) /* This is a normal NPE: addr must be NULL and the NPE-type define is 0. */ - addr = md_get_reg_from_context(ctx, s1); - type = (s4) addr; + addr = md_get_reg_from_context(ctx, s1); + type = (int) addr; } /* create stackframeinfo */ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -155,14 +155,13 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *info , void *_p) /* set registers */ - ctx->sigc_regs.u_regs[REG_ITMP2_XPTR] = (ptrint) e; - ctx->sigc_regs.u_regs[REG_ITMP3_XPC] = (ptrint) xpc; - ctx->sigc_regs.tpc = (ptrint) asm_handle_exception; - ctx->sigc_regs.tnpc = (ptrint) asm_handle_exception + 4; + ctx->sigc_regs.u_regs[REG_ITMP2_XPTR] = (intptr_t) p; + ctx->sigc_regs.u_regs[REG_ITMP3_XPC] = (intptr_t) xpc; + ctx->sigc_regs.tpc = (intptr_t) asm_handle_exception; + ctx->sigc_regs.tnpc = (intptr_t) asm_handle_exception + 4; } - /* md_icacheflush ************************************************************** Calls the system's function to flush the instruction cache. diff --git a/src/vm/jit/sparc64/md-abi.c b/src/vm/jit/sparc64/md-abi.c index c359dcc82..0aaf68aa8 100644 --- a/src/vm/jit/sparc64/md-abi.c +++ b/src/vm/jit/sparc64/md-abi.c @@ -196,6 +196,7 @@ void md_param_alloc(methoddesc *md) } break; } + assert(pd->regoff != 26); } /* Since O0 is used for passing return values, this */ @@ -225,10 +226,11 @@ void md_param_alloc_native(methoddesc *md) s4 stacksize; s4 min_nat_regs; + /* Note: regoff will be set relative to a stack base of $sp+16 */ + /* set default values */ - reguse = 0; - stacksize = 6; + stacksize = 6; /* abi params: allocated, but not used */ /* when we are above this, we have to increase the stacksize with every */ /* single argument to create the proper argument array */ @@ -245,7 +247,7 @@ void md_param_alloc_native(methoddesc *md) case TYPE_LNG: if (i < INT_NATARG_CNT) { pd->inmemory = false; - pd->regoff = reguse; + pd->regoff = nat_argintregs[reguse]; reguse++; md->argintreguse = reguse; @@ -254,9 +256,6 @@ void md_param_alloc_native(methoddesc *md) pd->regoff = reguse * 8; reguse++; } - - if (i >= min_nat_regs) - stacksize++; break; case TYPE_FLT: case TYPE_DBL: @@ -271,10 +270,11 @@ void md_param_alloc_native(methoddesc *md) reguse++; } - if (i >= min_nat_regs) - stacksize++; break; } + + if (i >= min_nat_regs) + stacksize++; } /* Since O0 is used for passing return values, this */ diff --git a/src/vm/jit/sparc64/md.c b/src/vm/jit/sparc64/md.c index af5c148fe..f7f6f2f1d 100644 --- a/src/vm/jit/sparc64/md.c +++ b/src/vm/jit/sparc64/md.c @@ -1,4 +1,4 @@ -/* src/vm/jit/alpha/md.c - machine dependent SPARC functions +/* src/vm/jit/sparc64/md.c - machine dependent SPARC functions Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, @@ -348,10 +348,7 @@ void md_dcacheflush(u1 *addr, s4 nbytes) #if defined(ENABLE_REPLACEMENT) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; u4 mcode; - - assert(0); if (index < 0) { /* restore the patched-over instruction */ @@ -362,12 +359,8 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save *(u4*)(savedmcode) = *(u4*)(rp->pc); /* build the machine code for the patch */ - disp = ((u4*)code->replacementstubs - (u4*)rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 1; - - mcode = (((s4)(0x00))<<30) | ((0)<<29) | ((0x8)<<25) | (0x1<<22) | (0<<20) - | (1 << 19 ) | ((disp) & 0x007ffff); + assert(0); /* XXX build trap instruction below */ + mcode = 0; /* write the new machine code */ *(u4*)(rp->pc) = (u4) mcode; diff --git a/src/vm/jit/sparc64/patcher.c b/src/vm/jit/sparc64/patcher.c index 634fe7f3d..038963487 100644 --- a/src/vm/jit/sparc64/patcher.c +++ b/src/vm/jit/sparc64/patcher.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -68,12 +69,12 @@ *******************************************************************************/ -java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) +java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) { stackframeinfo sfi; u1 *xpc; u1 *javasp; - java_objectheader *o; + java_object_t *o; #if SIZEOF_VOID_P == 8 u8 mcode; #else @@ -81,7 +82,7 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) #endif functionptr f; bool result; - java_objectheader *e; + java_handle_t *e; /* define the patcher function */ @@ -92,7 +93,7 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) /* get stuff from the stack */ xpc = (u1 *) *((ptrint *) (sp + 5 * 8)); - o = (java_objectheader *) *((ptrint *) (sp + 4 * 8)); + o = (java_object_t *) *((ptrint *) (sp + 4 * 8)); f = (functionptr) *((ptrint *) (sp + 0 * 8)); /* store PV into the patcher function position */ @@ -199,7 +200,7 @@ bool patcher_get_putstatic(u1 *sp) /* patch the field value's address */ - *((ptrint *) (pv + disp)) = (ptrint) &(fi->value); + *((intptr_t *) (pv + disp)) = (intptr_t) fi->value; /* synchronize data cache */ diff --git a/src/vm/jit/sparc64/solaris/md-os.c b/src/vm/jit/sparc64/solaris/md-os.c index e46f3abaf..7e47210ec 100644 --- a/src/vm/jit/sparc64/solaris/md-os.c +++ b/src/vm/jit/sparc64/solaris/md-os.c @@ -1,6 +1,6 @@ /* src/vm/jit/sparc64/solaris/md-os.c - machine dependent SPARC Solaris functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, + Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,19 +22,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - $Id: md-os.c 4357 2006-01-22 23:33:38Z twisti $ */ + #include "config.h" #include +#include #include /* work around name clash */ @@ -83,6 +79,7 @@ ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex) return val; } + /* md_signal_handler_sigsegv *************************************************** NullPointerException signal handler for hardware null pointer @@ -92,21 +89,21 @@ ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex) void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - ptrint addr; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - s4 d; - s4 s1; - s4 disp; - ptrint val; - s4 type; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + ptrint addr; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u4 mcode; + int d; + int s1; + int16_t disp; + intptr_t val; + int type; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -127,7 +124,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* flush register windows? */ - val = md_get_reg_from_context(_mc, d); + val = md_get_reg_from_context(_mc, d); /* check for special-load */ @@ -141,16 +138,16 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) define is 0. */ addr = md_get_reg_from_context(_mc, s1); - type = (s4) addr; + type = (int) addr; } /* create stackframeinfo */ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -158,10 +155,10 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _mc->gregs[REG_G2] = (ptrint) e; /* REG_ITMP2_XPTR */ - _mc->gregs[REG_G3] = (ptrint) xpc; /* REG_ITMP3_XPC */ - _mc->gregs[REG_PC] = (ptrint) asm_handle_exception; - _mc->gregs[REG_nPC] = (ptrint) asm_handle_exception + 4; + _mc->gregs[REG_G2] = (intptr_t) p; /* REG_ITMP2_XPTR */ + _mc->gregs[REG_G3] = (intptr_t) xpc; /* REG_ITMP3_XPC */ + _mc->gregs[REG_PC] = (intptr_t) asm_handle_exception; + _mc->gregs[REG_nPC] = (intptr_t) asm_handle_exception + 4; } diff --git a/src/vm/jit/stacktrace.c b/src/vm/jit/stacktrace.c index dc59d296e..91a25d18d 100644 --- a/src/vm/jit/stacktrace.c +++ b/src/vm/jit/stacktrace.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: stacktrace.c 8139 2007-06-24 10:12:27Z twisti $ + $Id: stacktrace.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -42,6 +42,7 @@ #include "vm/global.h" /* required here for native includes */ #include "native/jni.h" +#include "native/llni.h" #include "native/include/java_lang_Throwable.h" #if defined(WITH_CLASSPATH_GNU) @@ -781,7 +782,7 @@ java_objectarray *stacktrace_getClassContext(void) continue; } - oa->data[i] = (java_objectheader *) ste->method->class; + oa->data[i] = (java_object_t *) ste->method->class; } /* release dump memory */ @@ -891,7 +892,7 @@ java_objectarray *stacktrace_getStack(void) java_objectarray *classes; java_objectarray *methodnames; classinfo *c; - java_objectheader *string; + java_handle_t *string; s4 i; s4 dumpsize; CYCLES_STATS_DECLARE_AND_START @@ -930,15 +931,15 @@ java_objectarray *stacktrace_getStack(void) /* set up the 2-dimensional array */ - oa->data[0] = (java_objectheader *) classes; - oa->data[1] = (java_objectheader *) methodnames; + oa->data[0] = (java_object_t *) classes; + oa->data[1] = (java_object_t *) methodnames; /* iterate over all stacktrace entries */ for (i = 0, ste = &(stb->entries[0]); i < stb->used; i++, ste++) { c = ste->method->class; - classes->data[i] = (java_objectheader *) c; + classes->data[i] = (java_object_t *) c; string = javastring_new(ste->method->name); @@ -1014,7 +1015,7 @@ void stacktrace_print_trace_from_buffer(stacktracebuffer *stb) *******************************************************************************/ -void stacktrace_print_trace(java_objectheader *xptr) +void stacktrace_print_trace(java_handle_t *xptr) { java_lang_Throwable *t; #if defined(WITH_CLASSPATH_GNU) @@ -1031,8 +1032,8 @@ void stacktrace_print_trace(java_objectheader *xptr) /* now print the stacktrace */ #if defined(WITH_CLASSPATH_GNU) - vmt = t->vmState; - stc = (stacktracecontainer *) vmt->vmData; + LLNI_field_get_ref(t, vmState, vmt); + stc = (stacktracecontainer *) LLNI_field_direct(vmt, vmData); #elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1) stc = (stacktracecontainer *) t->backtrace; #else diff --git a/src/vm/jit/stacktrace.h b/src/vm/jit/stacktrace.h index be1c94283..ddf276232 100644 --- a/src/vm/jit/stacktrace.h +++ b/src/vm/jit/stacktrace.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: stacktrace.h 7937 2007-05-23 09:26:19Z michi $ + $Id: stacktrace.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -138,7 +138,7 @@ java_objectarray *stacktrace_getStack(void); #endif void stacktrace_print_trace_from_buffer(stacktracebuffer *stb); -void stacktrace_print_trace(java_objectheader *xptr); +void stacktrace_print_trace(java_handle_t *xptr); /* machine dependent functions (code in ARCH_DIR/md.c) */ diff --git a/src/vm/jit/tools/Makefile.am b/src/vm/jit/tools/Makefile.am deleted file mode 100644 index 0ee5235f0..000000000 --- a/src/vm/jit/tools/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -## src/vm/jit/tools/Makefile.am -## -## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, -## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -## J. Wenninger, Institut f. Computersprachen - TU Wien -## -## This file is part of CACAO. -## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 2, or (at -## your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. -## -## $Id: Makefile.am 7290 2007-02-06 08:48:29Z twisti $ - -## Process this file with automake to produce Makefile.in - -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) - -LIBS = - -noinst_PROGRAMS = \ - genoffsets - -genoffsets_SOURCES = \ - genoffsets.c - - -## Local variables: -## mode: Makefile -## indent-tabs-mode: t -## c-basic-offset: 4 -## tab-width: 8 -## compile-command: "automake --add-missing" -## End: diff --git a/src/vm/jit/tools/genoffsets.c b/src/vm/jit/tools/genoffsets.c deleted file mode 100644 index 5c8da95b3..000000000 --- a/src/vm/jit/tools/genoffsets.c +++ /dev/null @@ -1,100 +0,0 @@ -/* src/vm/jit/tools/genoffsets.c - generate asmpart offsets of structures - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - $Id: genoffsets.c 8123 2007-06-20 23:50:55Z michi $ - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "vm/global.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" -#include "vm/jit/replace.h" - - -int main(int argc, char **argv) -{ - printf("/* This file is machine generated, don't edit it! */\n\n"); - - printf("/* define some sizeof()'s */\n\n"); - - printf("#define sizevmarg %3d\n", (s4) sizeof(vm_arg)); - -#if defined(ENABLE_REPLACEMENT) - printf("#define sizeexecutionstate %3d\n", (s4) sizeof(executionstate_t)); -#endif - - printf("\n\n/* define some offsets */\n\n"); - - printf("/* vftbl_t */\n\n"); - printf("#define offbaseval %3d\n", (s4) OFFSET(vftbl_t, baseval)); - printf("#define offdiffval %3d\n", (s4) OFFSET(vftbl_t, diffval)); - printf("\n\n"); - - printf("#define offvmargtype %3d\n", (s4) OFFSET(vm_arg, type)); - printf("#define offvmargdata %3d\n", (s4) OFFSET(vm_arg, data)); - printf("\n\n"); - - printf("#define offcast_super_baseval %3d\n", (s4) OFFSET(castinfo, super_baseval)); - printf("#define offcast_super_diffval %3d\n", (s4) OFFSET(castinfo, super_diffval)); - printf("#define offcast_sub_baseval %3d\n", (s4) OFFSET(castinfo, sub_baseval)); - -#if defined(ENABLE_REPLACEMENT) - printf("#define offes_pc %3d\n", (s4) OFFSET(executionstate_t, pc)); - printf("#define offes_sp %3d\n", (s4) OFFSET(executionstate_t, sp)); - printf("#define offes_pv %3d\n", (s4) OFFSET(executionstate_t, pv)); - printf("#define offes_intregs %3d\n", (s4) OFFSET(executionstate_t, intregs)); - printf("#define offes_fltregs %3d\n", (s4) OFFSET(executionstate_t, fltregs)); -#endif /* defined(ENABLE_REPLACEMENT) */ - - /* everything is ok */ - - return 0; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ - - diff --git a/src/vm/jit/verify/typecheck-stackbased.c b/src/vm/jit/verify/typecheck-stackbased.c index 9d3cd8543..0a8007e4a 100644 --- a/src/vm/jit/verify/typecheck-stackbased.c +++ b/src/vm/jit/verify/typecheck-stackbased.c @@ -37,14 +37,13 @@ #include "mm/memory.h" #include "vm/global.h" +#include "vm/primitive.h" #include "vm/jit/parse.h" #include "vm/jit/show.h" #include "vm/jit/stack.h" #include "vm/jit/verify/typecheck-common.h" -#include "vmcore/primitive.h" - /* this #if runs over the whole file: */ #if defined(ENABLE_VERIFIER) diff --git a/src/vm/jit/verify/typecheck-typeinferer.c b/src/vm/jit/verify/typecheck-typeinferer.c index e3620f9b9..2dacbd54d 100644 --- a/src/vm/jit/verify/typecheck-typeinferer.c +++ b/src/vm/jit/verify/typecheck-typeinferer.c @@ -42,6 +42,7 @@ #include "vm/access.h" #include "vm/builtin.h" #include "vm/exceptions.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/vm.h" @@ -53,7 +54,6 @@ #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #define TYPECHECK_NO_STATISTICS #include diff --git a/src/vm/jit/verify/typecheck.c b/src/vm/jit/verify/typecheck.c index fab2c184d..a97fec3fa 100644 --- a/src/vm/jit/verify/typecheck.c +++ b/src/vm/jit/verify/typecheck.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: typecheck.c 8159 2007-06-28 00:31:31Z michi $ + $Id: typecheck.c 8288 2007-08-10 15:12:00Z twisti $ */ @@ -155,6 +155,7 @@ error reporting. #include "vm/builtin.h" #include "vm/exceptions.h" #include "vm/global.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/jit/jit.h" @@ -163,7 +164,6 @@ error reporting. #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include diff --git a/src/vm/jit/verify/typeinfo.c b/src/vm/jit/verify/typeinfo.c index 8e32e1460..c381f3637 100644 --- a/src/vm/jit/verify/typeinfo.c +++ b/src/vm/jit/verify/typeinfo.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: typeinfo.c 8123 2007-06-20 23:50:55Z michi $ + $Id: typeinfo.c 8288 2007-08-10 15:12:00Z twisti $ */ @@ -36,6 +36,7 @@ #include "toolbox/logging.h" #include "vm/exceptions.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/jit/jit.h" @@ -44,7 +45,6 @@ #include "vmcore/class.h" #include "vmcore/descriptor.h" #include "vmcore/loader.h" -#include "vmcore/primitive.h" /* check if a linked class is an array class. Only use for linked classes! */ diff --git a/src/vm/jit/x86_64/Makefile.am b/src/vm/jit/x86_64/Makefile.am index 3a0f1302f..bcd8db4b6 100644 --- a/src/vm/jit/x86_64/Makefile.am +++ b/src/vm/jit/x86_64/Makefile.am @@ -22,7 +22,7 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. ## -## $Id: Makefile.am 7294 2007-02-06 09:11:36Z twisti $ +## $Id: Makefile.am 8274 2007-08-08 15:58:17Z twisti $ ## Process this file with automake to produce Makefile.in @@ -37,12 +37,6 @@ DIST_SUBDIRS = \ SUBDIRS = $(OS_DIR) -BUILT_SOURCES = \ - offsets.h - -CLEANFILES = \ - offsets.h - noinst_HEADERS = \ arch.h \ machine-instr.h \ @@ -72,10 +66,7 @@ libarch_la_SOURCES = \ libarch_la_LIBADD = \ $(OS_DIR)/libmd.la -$(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h - -offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h - $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h +$(srcdir)/asmpart.S: $(top_builddir)/config.h ## Local variables: diff --git a/src/vm/jit/x86_64/arch.h b/src/vm/jit/x86_64/arch.h index 8206e3698..0fcb8aac4 100644 --- a/src/vm/jit/x86_64/arch.h +++ b/src/vm/jit/x86_64/arch.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $ + $Id: arch.h 8247 2007-07-31 12:06:44Z michi $ */ @@ -113,7 +113,6 @@ /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 5 /* bytes */ -#define REPLACEMENT_STUB_SIZE (10+2+10+2+1) /* bytes */ #endif /* _ARCH_H */ diff --git a/src/vm/jit/x86_64/asmpart.S b/src/vm/jit/x86_64/asmpart.S index 8f7b5a9e4..8d7b76f7a 100644 --- a/src/vm/jit/x86_64/asmpart.S +++ b/src/vm/jit/x86_64/asmpart.S @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 8197 2007-07-11 19:17:04Z twisti $ + $Id: asmpart.S 8274 2007-08-08 15:58:17Z twisti $ */ @@ -32,7 +32,6 @@ #include "vm/jit/x86_64/arch.h" #include "vm/jit/x86_64/md-abi.h" #include "vm/jit/x86_64/md-asm.h" -#include "vm/jit/x86_64/offsets.h" #include "vm/jit/abi-asm.h" #include "vm/jit/methodheader.h" @@ -73,9 +72,6 @@ .globl asm_compare_and_swap .globl asm_memory_barrier - .globl asm_criticalsections - .globl asm_getclassvalues_atomic - /********************* function asm_calljavafunction *************************** * * @@ -707,29 +703,6 @@ asm_memory_barrier: ret -asm_getclassvalues_atomic: -_crit_restart: -_crit_begin: - movl offbaseval(a0),itmp1l - movl offdiffval(a0),itmp2l - movl offbaseval(a1),itmp3l -_crit_end: - movl itmp1l,offcast_super_baseval(a2) - movl itmp2l,offcast_super_diffval(a2) - movl itmp3l,offcast_sub_baseval(a2) - ret - - .data - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .quad _crit_begin - .quad _crit_end - .quad _crit_restart -#endif - .quad 0 - - /* disable exec-stacks ********************************************************/ #if defined(__linux__) && defined(__ELF__) diff --git a/src/vm/jit/x86_64/codegen.c b/src/vm/jit/x86_64/codegen.c index 086b41eb4..e538a50e3 100644 --- a/src/vm/jit/x86_64/codegen.c +++ b/src/vm/jit/x86_64/codegen.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $ + $Id: codegen.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -43,6 +43,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" @@ -1768,7 +1769,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); disp = disp + -((cd->mcodeptr + 7) - cd->mcodebase); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { @@ -1832,7 +1833,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); disp = disp + -((cd->mcodeptr + 7) - cd->mcodebase); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { @@ -1897,7 +1898,7 @@ bool codegen_emit(jitdata *jd) else { fi = iptr->sx.s23.s3.fmiref->p.field; fieldtype = fi->type; - disp = dseg_add_address(cd, &(fi->value)); + disp = dseg_add_address(cd, fi->value); disp = disp + -((cd->mcodeptr + 7) - cd->mcodebase); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { @@ -2472,7 +2473,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD32(REG_ITMP3, REG_METHODPTR, s1); M_CALL(REG_ITMP3); break; @@ -2492,7 +2493,7 @@ gen_method: } /* implicit null-pointer check */ - M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_object_t, vftbl)); M_ALD32(REG_METHODPTR, REG_METHODPTR, s1); M_ALD32(REG_ITMP3, REG_METHODPTR, s2); M_CALL(REG_ITMP3); @@ -2578,7 +2579,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_add_patch_ref(cd, PATCHER_checkcast_interface, @@ -2614,7 +2615,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_add_patch_ref(cd, PATCHER_checkcast_class, @@ -2744,7 +2745,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_3); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_add_patch_ref(cd, PATCHER_instanceof_interface, @@ -2781,7 +2782,7 @@ gen_method: emit_label_beq(cd, BRANCH_LABEL_5); } - M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); + M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); if (super == NULL) { codegen_add_patch_ref(cd, PATCHER_instanceof_class, diff --git a/src/vm/jit/x86_64/emit.c b/src/vm/jit/x86_64/emit.c index 91d550681..68242346a 100644 --- a/src/vm/jit/x86_64/emit.c +++ b/src/vm/jit/x86_64/emit.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: emit.c 8211 2007-07-18 19:52:23Z michi $ + $Id: emit.c 8267 2007-08-07 11:07:48Z twisti $ */ @@ -507,6 +507,27 @@ void emit_patcher_stubs(jitdata *jd) } +/* emit_trap ******************************************************************* + + Emit a trap instruction and return the original machine code. + +*******************************************************************************/ + +uint32_t emit_trap(codegendata *cd) +{ + uint32_t mcode; + + /* Get machine code which is patched back in later. The + trap is 1 instruction word long. */ + + mcode = *((uint32_t *) cd->mcodeptr); + + M_NOP; + + return mcode; +} + + /* emit_verbosecall_enter ****************************************************** Generates the code for the call trace. diff --git a/src/vm/jit/x86_64/linux/md-os.c b/src/vm/jit/x86_64/linux/md-os.c index e0f007e00..4bd57c91e 100644 --- a/src/vm/jit/x86_64/linux/md-os.c +++ b/src/vm/jit/x86_64/linux/md-os.c @@ -32,6 +32,7 @@ #include "config.h" #include +#include #include #include @@ -58,20 +59,20 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *sp; - u1 *ra; - u1 *xpc; - u1 opc; - u1 mod; - u1 rm; - s4 d; - s4 disp; - s4 type; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *sp; + u1 *ra; + u1 *xpc; + u1 opc; + u1 mod; + u1 rm; + s4 d; + s4 disp; + int type; + intptr_t val; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -163,9 +164,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -173,9 +174,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _mc->gregs[REG_RAX] = (ptrint) e; - _mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */ - _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception; + _mc->gregs[REG_RAX] = (intptr_t) p; + _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception; } @@ -188,16 +189,16 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) { - stackframeinfo sfi; - ucontext_t *_uc; - mcontext_t *_mc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - s4 type; - ptrint val; - java_objectheader *e; + stackframeinfo sfi; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + int type; + intptr_t val; + void *p; _uc = (ucontext_t *) _p; _mc = &_uc->uc_mcontext; @@ -219,9 +220,9 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc); - /* generate appropriate exception */ + /* Handle the type. */ - e = exceptions_new_hardware_exception(xpc, type, val); + p = signal_handle(xpc, type, val); /* remove stackframeinfo */ @@ -229,9 +230,9 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) /* set registers */ - _mc->gregs[REG_RAX] = (ptrint) e; - _mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */ - _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception; + _mc->gregs[REG_RAX] = (intptr_t) p; + _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception; } diff --git a/src/vm/jit/x86_64/md.c b/src/vm/jit/x86_64/md.c index f1bdabdcc..546da55ce 100644 --- a/src/vm/jit/x86_64/md.c +++ b/src/vm/jit/x86_64/md.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: md.c 7947 2007-05-23 15:57:41Z twisti $ + $Id: md.c 8247 2007-07-31 12:06:44Z michi $ */ @@ -42,6 +42,10 @@ #include "vm/jit/codegen-common.h" #include "vm/jit/stacktrace.h" +#if defined(ENABLE_REPLACEMENT) +# include "vm/exceptions.h" +#endif + #if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) #include "vmcore/options.h" /* XXX debug */ #include "vm/jit/disass.h" /* XXX debug */ @@ -230,7 +234,6 @@ void md_dcacheflush(u1 *addr, s4 nbytes) #if defined(ENABLE_REPLACEMENT) void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode) { - s4 disp; u8 mcode; /* XXX this is probably unsafe! */ @@ -251,11 +254,8 @@ void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *save savedmcode[4] = rp->pc[4]; /* build the machine code for the patch */ - disp = (code->replacementstubs - rp->pc) - + index * REPLACEMENT_STUB_SIZE - - 5; - - mcode = 0xe9 | ((u8) disp << 8); + assert(0); /* XXX build trap instruction below */ + mcode = 0; /* write spinning instruction */ *(u2*)(rp->pc) = 0xebfe; diff --git a/src/vm/jit/x86_64/patcher.c b/src/vm/jit/x86_64/patcher.c index ef1551844..664090fa3 100644 --- a/src/vm/jit/x86_64/patcher.c +++ b/src/vm/jit/x86_64/patcher.c @@ -22,12 +22,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: patcher.c 7596 2007-03-28 21:05:53Z twisti $ + $Id: patcher.c 8295 2007-08-11 17:57:24Z michi $ */ #include "config.h" + +#include + #include "vm/types.h" #include "vm/jit/x86_64/codegen.h" @@ -61,14 +64,14 @@ *******************************************************************************/ -java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) +java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) { stackframeinfo sfi; u1 *xpc; - java_objectheader *o; + java_object_t *o; functionptr f; bool result; - java_objectheader *e; + java_handle_t *e; /* define the patcher function */ @@ -77,7 +80,7 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra) /* get stuff from the stack */ xpc = (u1 *) *((ptrint *) (sp + 5 * 8)); - o = (java_objectheader *) *((ptrint *) (sp + 4 * 8)); + o = (java_object_t *) *((ptrint *) (sp + 4 * 8)); f = (functionptr) *((ptrint *) (sp + 0 * 8)); /* calculate and set the new return address */ @@ -173,7 +176,7 @@ bool patcher_get_putstatic(u1 *sp) /* patch the field value's address */ - *((ptrint *) (ra + 7 + disp)) = (ptrint) &(fi->value); + *((intptr_t *) (ra + 7 + disp)) = (intptr_t) fi->value; return true; } @@ -226,9 +229,9 @@ bool patcher_get_putfield(u1 *sp) byte = *(ra + 3); if (byte == 0x24) - *((u4 *) (ra + 4)) = (u4) (fi->offset); + *((int32_t *) (ra + 4)) = fi->offset; else - *((u4 *) (ra + 3)) = (u4) (fi->offset); + *((int32_t *) (ra + 3)) = fi->offset; } else { /* check for special case: %rsp or %r12 as base register */ @@ -236,9 +239,9 @@ bool patcher_get_putfield(u1 *sp) byte = *(ra + 5); if (byte == 0x24) - *((u4 *) (ra + 6)) = (u4) (fi->offset); + *((int32_t *) (ra + 6)) = fi->offset; else - *((u4 *) (ra + 5)) = (u4) (fi->offset); + *((int32_t *) (ra + 5)) = fi->offset; } return true; @@ -287,21 +290,21 @@ bool patcher_putfieldconst(u1 *sp) /* handle special case when the base register is %r12 */ if (*(ra + 2) == 0x84) { - *((u4 *) (ra + 4)) = (u4) (fi->offset); - *((u4 *) (ra + 12 + 4)) = (u4) (fi->offset + 4); + *((uint32_t *) (ra + 4)) = fi->offset; + *((uint32_t *) (ra + 12 + 4)) = fi->offset + 4; } else { - *((u4 *) (ra + 3)) = (u4) (fi->offset); - *((u4 *) (ra + 11 + 3)) = (u4) (fi->offset + 4); + *((uint32_t *) (ra + 3)) = fi->offset; + *((uint32_t *) (ra + 11 + 3)) = fi->offset + 4; } } else { /* handle special case when the base register is %r12 */ if (*(ra + 2) == 0x84) - *((u4 *) (ra + 4)) = (u4) (fi->offset); + *((uint32_t *) (ra + 4)) = fi->offset; else - *((u4 *) (ra + 3)) = (u4) (fi->offset); + *((uint32_t *) (ra + 3)) = fi->offset; } return true; diff --git a/src/vm/properties.c b/src/vm/properties.c index ab49257b1..69458063f 100644 --- a/src/vm/properties.c +++ b/src/vm/properties.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: properties.c 8236 2007-07-27 10:18:17Z twisti $ + $Id: properties.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -390,11 +390,11 @@ char *properties_get(char *key) *******************************************************************************/ -void properties_system_add(java_objectheader *p, char *key, char *value) +void properties_system_add(java_handle_t *p, char *key, char *value) { - methodinfo *m; - java_objectheader *k; - java_objectheader *v; + methodinfo *m; + java_handle_t *k; + java_handle_t *v; /* search for method to add properties */ @@ -427,12 +427,12 @@ void properties_system_add(java_objectheader *p, char *key, char *value) *******************************************************************************/ #if defined(ENABLE_JAVASE) -void properties_system_add_all(java_objectheader *p) +void properties_system_add_all(java_handle_t *p) { list_properties_entry *pe; methodinfo *m; - java_objectheader *key; - java_objectheader *value; + java_handle_t *key; + java_handle_t *value; /* search for method to add properties */ @@ -454,7 +454,7 @@ void properties_system_add_all(java_objectheader *p) key = javastring_new_from_utf_string(pe->key); value = javastring_new_from_utf_string(pe->value); - (void) vm_call_method(m, (java_objectheader *) p, key, value); + (void) vm_call_method(m, (java_handle_t *) p, key, value); } } #endif /* defined(ENABLE_JAVASE) */ diff --git a/src/vm/properties.h b/src/vm/properties.h index a983c081d..d1e383751 100644 --- a/src/vm/properties.h +++ b/src/vm/properties.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: properties.h 8236 2007-07-27 10:18:17Z twisti $ + $Id: properties.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -43,10 +43,10 @@ bool properties_init(void); void properties_add(char *key, char *value); char *properties_get(char *key); -void properties_system_add(java_objectheader *p, char *key, char *value); +void properties_system_add(java_handle_t *p, char *key, char *value); #if defined(ENABLE_JAVASE) -void properties_system_add_all(java_objectheader *p); +void properties_system_add_all(java_handle_t *p); #endif #endif /* _PROPERTIES_H */ diff --git a/src/vm/resolve.c b/src/vm/resolve.c index f608af738..a02e120c9 100644 --- a/src/vm/resolve.c +++ b/src/vm/resolve.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: resolve.c 8123 2007-06-20 23:50:55Z michi $ + $Id: resolve.c 8288 2007-08-10 15:12:00Z twisti $ */ @@ -38,6 +38,7 @@ #include "vm/access.h" #include "vm/exceptions.h" #include "vm/global.h" +#include "vm/primitive.h" #include "vm/resolve.h" #include "vm/jit/jit.h" @@ -48,7 +49,6 @@ #include "vmcore/linker.h" #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" /******************************************************************************/ diff --git a/src/vm/signal.c b/src/vm/signal.c index 1b9aca5cb..a0348a03c 100644 --- a/src/vm/signal.c +++ b/src/vm/signal.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: signal.c 8027 2007-06-07 10:30:33Z michi $ + $Id: signal.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -32,6 +32,7 @@ #include #include #include +#include #include #if defined(__DARWIN__) @@ -40,8 +41,6 @@ # include #endif -#include "vm/types.h" - #include "arch.h" #include "mm/memory.h" @@ -52,10 +51,16 @@ # include "threads/none/threads.h" #endif +#include "toolbox/logging.h" + #include "vm/exceptions.h" #include "vm/signallocal.h" #include "vm/vm.h" +#include "vm/jit/codegen-common.h" +#include "vm/jit/disass.h" +#include "vm/jit/patcher-common.h" + #include "vmcore/options.h" #if defined(ENABLE_STATISTICS) @@ -77,8 +82,7 @@ void signal_handler_sighup(int sig, siginfo_t *siginfo, void *_p); bool signal_init(void) { #if !defined(__CYGWIN__) - sigset_t mask; - struct sigaction act; + sigset_t mask; #if defined(__LINUX__) && defined(ENABLE_THREADS) /* XXX Remove for exact-GC. */ @@ -112,55 +116,47 @@ bool signal_init(void) /* Allocate something so the garbage collector's signal handlers are installed. */ - (void) GCNEW(u1); + (void) GCNEW(int); #endif /* Install signal handlers for signals we want to catch in all threads. */ - sigemptyset(&act.sa_mask); - #if defined(ENABLE_JIT) # if defined(ENABLE_INTRP) if (!opt_intrp) { # endif /* SIGSEGV handler */ - act.sa_sigaction = md_signal_handler_sigsegv; - act.sa_flags = SA_NODEFER | SA_SIGINFO; - -# if defined(SIGSEGV) - sigaction(SIGSEGV, &act, NULL); -# endif + signal_register_signal(SIGSEGV, (void *) md_signal_handler_sigsegv, + SA_NODEFER | SA_SIGINFO); # if defined(SIGBUS) - sigaction(SIGBUS, &act, NULL); + signal_register_signal(SIGBUS, (void *) md_signal_handler_sigsegv, + SA_NODEFER | SA_SIGINFO); # endif # if SUPPORT_HARDWARE_DIVIDE_BY_ZERO /* SIGFPE handler */ - act.sa_sigaction = md_signal_handler_sigfpe; - act.sa_flags = SA_NODEFER | SA_SIGINFO; - sigaction(SIGFPE, &act, NULL); + signal_register_signal(SIGFPE, (void *) md_signal_handler_sigfpe, + SA_NODEFER | SA_SIGINFO); # endif # if defined(__ARM__) || defined(__S390__) /* XXX use better defines for that (in arch.h) */ /* SIGILL handler */ - act.sa_sigaction = md_signal_handler_sigill; - act.sa_flags = SA_NODEFER | SA_SIGINFO; - sigaction(SIGILL, &act, NULL); + signal_register_signal(SIGILL, (void *) md_signal_handler_sigill, + SA_NODEFER | SA_SIGINFO); # endif # if defined(__POWERPC__) /* XXX use better defines for that (in arch.h) */ /* SIGTRAP handler */ - act.sa_sigaction = md_signal_handler_sigtrap; - act.sa_flags = SA_NODEFER | SA_SIGINFO; - sigaction(SIGTRAP, &act, NULL); + signal_register_signal(SIGTRAP, (void *) md_signal_handler_sigtrap, + SA_NODEFER | SA_SIGINFO); # endif # if defined(ENABLE_INTRP) } @@ -170,9 +166,7 @@ bool signal_init(void) #if defined(ENABLE_THREADS) /* SIGHUP handler for threads_thread_interrupt */ - act.sa_sigaction = signal_handler_sighup; - act.sa_flags = 0; - sigaction(SIGHUP, &act, NULL); + signal_register_signal(SIGHUP, (void *) signal_handler_sighup, 0); #endif #if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) @@ -186,9 +180,8 @@ bool signal_init(void) #if defined(ENABLE_THREADS) && defined(ENABLE_PROFILING) /* SIGUSR2 handler for profiling sampling */ - act.sa_sigaction = md_signal_handler_sigusr2; - act.sa_flags = SA_SIGINFO; - sigaction(SIGUSR2, &act, NULL); + signal_register_signal(SIGUSR2, (void *) md_signal_handler_sigusr2, + SA_SIGINFO); #endif #endif /* !defined(__CYGWIN__) */ @@ -197,6 +190,109 @@ bool signal_init(void) } +/* signal_register_signal ****************************************************** + + Register the specified handler with the specified signal. + +*******************************************************************************/ + +void signal_register_signal(int signum, void *handler, int flags) +{ + struct sigaction act; + void (*function)(int, siginfo_t *, void *); + + function = (void (*)(int, siginfo_t *, void *)) handler; + + if (sigemptyset(&act.sa_mask) != 0) + vm_abort("signal_register_signal: sigemptyset failed: %s", + strerror(errno)); + + act.sa_sigaction = function; + act.sa_flags = flags; + + if (sigaction(signum, &act, NULL) != 0) + vm_abort("signal_register_signal: sigaction failed: %s", + strerror(errno)); +} + + +/* signal_handle *************************************************************** + + Handles the signal caught by a signal handler and calls the correct + function. + +*******************************************************************************/ + +void *signal_handle(void *xpc, int type, intptr_t val) +{ + void *p; + int32_t index; + java_object_t *o; + + switch (type) { + case EXCEPTION_HARDWARE_NULLPOINTER: + p = exceptions_new_nullpointerexception(); + break; + + case EXCEPTION_HARDWARE_ARITHMETIC: + p = exceptions_new_arithmeticexception(); + break; + + case EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS: + index = (s4) val; + p = exceptions_new_arrayindexoutofboundsexception(index); + break; + + case EXCEPTION_HARDWARE_CLASSCAST: + o = (java_object_t *) val; + p = exceptions_new_classcastexception(o); + break; + + case EXCEPTION_HARDWARE_EXCEPTION: + p = exceptions_fillinstacktrace(); + break; + + case EXCEPTION_HARDWARE_PATCHER: +#if defined(ENABLE_REPLACEMENT) + if (replace_me_wrapper(xpc)) { + p = NULL; + break; + } +#endif + p = patcher_handler(xpc); + break; + + default: + /* Let's try to get a backtrace. */ + + codegen_get_pv_from_pc(xpc); + + /* If that does not work, print more debug info. */ + + log_println("exceptions_new_hardware_exception: unknown exception type %d", type); + +#if SIZEOF_VOID_P == 8 + log_println("PC=0x%016lx", xpc); +#else + log_println("PC=0x%08x", xpc); +#endif + +#if defined(ENABLE_DISASSEMBLER) + log_println("machine instruction at PC:"); + disassinstr(xpc); +#endif + + vm_abort("Exiting..."); + + /* keep compiler happy */ + + p = NULL; + } + + return p; +} + + /* signal_thread ************************************************************ This thread sets the signal mask to catch the user input signals diff --git a/src/vm/signallocal.h b/src/vm/signallocal.h index e80c5413f..24a144800 100644 --- a/src/vm/signallocal.h +++ b/src/vm/signallocal.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: signallocal.h 8027 2007-06-07 10:30:33Z michi $ + $Id: signallocal.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -34,15 +34,15 @@ #include -#include "vm/types.h" - #include "vm/global.h" /* function prototypes ********************************************************/ -bool signal_init(void); -bool signal_start_thread(void); +bool signal_init(void); +void signal_register_signal(int signum, void *handler, int flags); +void *signal_handle(void *xpc, int type, intptr_t val); +bool signal_start_thread(void); /* machine dependent signal handler */ diff --git a/src/vm/string.c b/src/vm/string.c index 899a91760..8f13e685e 100644 --- a/src/vm/string.c +++ b/src/vm/string.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: string.c 8230 2007-07-25 08:23:10Z twisti $ + $Id: string.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -38,6 +38,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/include/java_lang_String.h" @@ -45,11 +46,11 @@ #include "vm/builtin.h" #include "vm/exceptions.h" +#include "vm/primitive.h" #include "vm/stringlocal.h" #include "vm/vm.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/statistics.h" #include "vmcore/utf8.h" @@ -63,7 +64,7 @@ hashtable hashtable_string; /* hashtable for javastrings */ #if defined(ENABLE_THREADS) -static java_objectheader *lock_hashtable_string; +static java_object_t *lock_hashtable_string; #endif @@ -82,7 +83,7 @@ bool string_init(void) #if defined(ENABLE_THREADS) /* create string hashtable lock object */ - lock_hashtable_string = NEW(java_objectheader); + lock_hashtable_string = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(lock_hashtable_string); #endif @@ -120,7 +121,7 @@ void stringtable_update(void) vm_abort("stringtable_update: invalid literalstring in hashtable"); } - a = js->value; + LLNI_field_get_ref(js, value, a); if (!js->header.vftbl) /* vftbl of javastring is NULL */ @@ -154,12 +155,12 @@ void stringtable_update(void) *******************************************************************************/ -static java_objectheader *javastring_new_from_utf_buffer(const char *buffer, +static java_handle_t *javastring_new_from_utf_buffer(const char *buffer, u4 blength) { const char *utf_ptr; /* current utf character in utf string */ u4 utflength; /* length of utf-string if uncompressed */ - java_objectheader *o; + java_handle_t *o; java_lang_String *s; /* result-string */ java_chararray *a; u4 i; @@ -187,9 +188,9 @@ static java_objectheader *javastring_new_from_utf_buffer(const char *buffer, s = (java_lang_String *) o; - s->value = a; - s->offset = 0; - s->count = utflength; + LLNI_field_set_ref(s, value , a); + LLNI_field_set_val(s, offset, 0); + LLNI_field_set_val(s, count , utflength); return o; } @@ -210,11 +211,11 @@ static java_objectheader *javastring_new_from_utf_buffer(const char *buffer, *******************************************************************************/ -java_objectheader *javastring_safe_new_from_utf8(const char *text) +java_handle_t *javastring_safe_new_from_utf8(const char *text) { - java_objectheader *o; - java_chararray *a; - java_lang_String *s; + java_handle_t *o; + java_chararray *a; + java_lang_String *s; s4 nbytes; s4 len; @@ -247,9 +248,9 @@ java_objectheader *javastring_safe_new_from_utf8(const char *text) s = (java_lang_String *) o; - s->value = a; - s->offset = 0; - s->count = len; + LLNI_field_set_ref(s, value , a); + LLNI_field_set_val(s, offset, 0); + LLNI_field_set_val(s, count , len); return o; } @@ -270,7 +271,7 @@ java_objectheader *javastring_safe_new_from_utf8(const char *text) *******************************************************************************/ -java_objectheader *javastring_new_from_utf_string(const char *utfstr) +java_handle_t *javastring_new_from_utf_string(const char *utfstr) { assert(utfstr); @@ -287,13 +288,13 @@ java_objectheader *javastring_new_from_utf_string(const char *utfstr) *******************************************************************************/ -java_objectheader *javastring_new(utf *u) +java_handle_t *javastring_new(utf *u) { char *utf_ptr; /* current utf character in utf string */ u4 utflength; /* length of utf-string if uncompressed */ - java_objectheader *o; - java_chararray *a; - java_lang_String *s; + java_handle_t *o; + java_chararray *a; + java_lang_String *s; s4 i; if (u == NULL) { @@ -321,9 +322,9 @@ java_objectheader *javastring_new(utf *u) s = (java_lang_String *) o; - s->value = a; - s->offset = 0; - s->count = utflength; + LLNI_field_set_ref(s, value , a); + LLNI_field_set_val(s, offset, 0); + LLNI_field_set_val(s, count , utflength); return o; } @@ -338,13 +339,13 @@ java_objectheader *javastring_new(utf *u) *******************************************************************************/ -java_objectheader *javastring_new_slash_to_dot(utf *u) +java_handle_t *javastring_new_slash_to_dot(utf *u) { char *utf_ptr; /* current utf character in utf string */ u4 utflength; /* length of utf-string if uncompressed */ - java_objectheader *o; - java_chararray *a; - java_lang_String *s; + java_handle_t *o; + java_chararray *a; + java_lang_String *s; s4 i; u2 ch; @@ -376,9 +377,9 @@ java_objectheader *javastring_new_slash_to_dot(utf *u) s = (java_lang_String *) o; - s->value = a; - s->offset = 0; - s->count = utflength; + LLNI_field_set_ref(s, value , a); + LLNI_field_set_val(s, offset, 0); + LLNI_field_set_val(s, count , utflength); return o; } @@ -398,13 +399,13 @@ java_objectheader *javastring_new_slash_to_dot(utf *u) *******************************************************************************/ -java_objectheader *javastring_new_from_ascii(const char *text) +java_handle_t *javastring_new_from_ascii(const char *text) { s4 i; s4 len; /* length of the string */ - java_objectheader *o; - java_lang_String *s; - java_chararray *a; + java_handle_t *o; + java_lang_String *s; + java_chararray *a; if (text == NULL) { exceptions_throw_nullpointerexception(); @@ -430,9 +431,9 @@ java_objectheader *javastring_new_from_ascii(const char *text) s = (java_lang_String *) o; - s->value = a; - s->offset = 0; - s->count = len; + LLNI_field_set_ref(s, value , a); + LLNI_field_set_val(s, offset, 0); + LLNI_field_set_val(s, count , len); return o; } @@ -448,7 +449,7 @@ java_objectheader *javastring_new_from_ascii(const char *text) *******************************************************************************/ -char *javastring_tochar(java_objectheader *so) +char *javastring_tochar(java_handle_t *so) { java_lang_String *s = (java_lang_String *) so; java_chararray *a; @@ -458,15 +459,15 @@ char *javastring_tochar(java_objectheader *so) if (!s) return ""; - a = s->value; + LLNI_field_get_ref(s, value, a); if (!a) return ""; - buf = MNEW(char, s->count + 1); + buf = MNEW(char, LLNI_field_direct(s, count) + 1); - for (i = 0; i < s->count; i++) - buf[i] = a->data[s->offset + i]; + for (i = 0; i < LLNI_field_direct(s, count); i++) + buf[i] = a->data[LLNI_field_direct(s, offset) + i]; buf[i] = '\0'; @@ -480,7 +481,7 @@ char *javastring_tochar(java_objectheader *so) *******************************************************************************/ -utf *javastring_toutf(java_objectheader *string, bool isclassname) +utf *javastring_toutf(java_handle_t *string, bool isclassname) { java_lang_String *s; @@ -489,7 +490,7 @@ utf *javastring_toutf(java_objectheader *string, bool isclassname) if (s == NULL) return utf_null; - return utf_new_u2(s->value->data + s->offset, s->count, isclassname); + return utf_new_u2(LLNI_field_direct(s, value)->data + LLNI_field_direct(s, offset), LLNI_field_direct(s, count), isclassname); } @@ -502,7 +503,7 @@ utf *javastring_toutf(java_objectheader *string, bool isclassname) *******************************************************************************/ -java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, +java_object_t *literalstring_u2(java_chararray *a, u4 length, u4 offset, bool copymode) { literalstring *s; /* hashtable element */ @@ -537,7 +538,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, LOCK_MONITOR_EXIT(lock_hashtable_string); - return (java_objectheader *) js; + return (java_object_t *) js; } nomatch: @@ -594,7 +595,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, #endif s->hashlink = hashtable_string.ptr[slot]; - s->string = (java_objectheader *) js; + s->string = (java_object_t *) js; hashtable_string.ptr[slot] = s; /* update number of hashtable entries */ @@ -644,7 +645,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, LOCK_MONITOR_EXIT(lock_hashtable_string); - return (java_objectheader *) js; + return (java_object_t *) js; } @@ -655,7 +656,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, *******************************************************************************/ -java_objectheader *literalstring_new(utf *u) +java_object_t *literalstring_new(utf *u) { char *utf_ptr; /* pointer to current unicode character */ /* utf string */ @@ -683,7 +684,7 @@ java_objectheader *literalstring_new(utf *u) *******************************************************************************/ -void literalstring_free(java_objectheader* string) +void literalstring_free(java_object_t* string) { java_lang_String *s; java_chararray *a; diff --git a/src/vm/stringlocal.h b/src/vm/stringlocal.h index c1ad5b62c..88b09d74d 100644 --- a/src/vm/stringlocal.h +++ b/src/vm/stringlocal.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: stringlocal.h 7967 2007-05-25 15:03:46Z twisti $ + $Id: stringlocal.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -47,7 +47,7 @@ typedef struct literalstring literalstring; struct literalstring { literalstring *hashlink; /* link for external hash chain */ - java_objectheader *string; + java_object_t *string; }; @@ -63,35 +63,35 @@ bool string_init(void); void stringtable_update(void); /* creates a new object of type java/lang/String from a utf-text */ -java_objectheader *javastring_new(utf *text); +java_handle_t *javastring_new(utf *text); /* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */ -java_objectheader *javastring_new_slash_to_dot(utf *text); +java_handle_t *javastring_new_slash_to_dot(utf *text); /* creates a new object of type java/lang/String from an ASCII c-string */ -java_objectheader *javastring_new_from_ascii(const char *text); +java_handle_t *javastring_new_from_ascii(const char *text); /* creates a new object of type java/lang/String from UTF-8 */ -java_objectheader *javastring_new_from_utf_string(const char *utfstr); +java_handle_t *javastring_new_from_utf_string(const char *utfstr); /* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */ -java_objectheader *javastring_safe_new_from_utf8(const char *text); +java_handle_t *javastring_safe_new_from_utf8(const char *text); /* make c-string from a javastring (debugging) */ -char *javastring_tochar(java_objectheader *string); +char *javastring_tochar(java_handle_t *string); /* make utf symbol from javastring */ -utf *javastring_toutf(java_objectheader *string, bool isclassname); +utf *javastring_toutf(java_handle_t *string, bool isclassname); /* creates a new javastring with the text of the u2-array */ -java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, +java_object_t *literalstring_u2(java_chararray *a, u4 length, u4 offset, bool copymode); /* creates a new javastring with the text of the utf-symbol */ -java_objectheader *literalstring_new(utf *u); +java_object_t *literalstring_new(utf *u); /* dispose a javastring */ -void literalstring_free(java_objectheader*); +void literalstring_free(java_object_t*); #endif /* _STRINGLOCAL_H */ diff --git a/src/vm/vm.c b/src/vm/vm.c index 3033b0b9a..7438df189 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: vm.c 8245 2007-07-31 09:55:04Z michi $ + $Id: vm.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -50,6 +50,7 @@ #include "mm/memory.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" #include "native/include/java_lang_Object.h" /* required by j.l.C */ @@ -82,6 +83,7 @@ #include "vm/finalizer.h" #include "vm/global.h" #include "vm/initialize.h" +#include "vm/primitive.h" #include "vm/properties.h" #include "vm/signallocal.h" #include "vm/stringlocal.h" @@ -99,7 +101,6 @@ #include "vmcore/classcache.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/statistics.h" #include "vmcore/suck.h" @@ -752,7 +753,7 @@ bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args) #if defined(ENABLE_JNI) /* setup the local ref table (must be created after vm_create) */ - if (!jni_init_localref_table()) + if (!localref_table_init()) goto error; #endif @@ -1225,7 +1226,6 @@ bool vm_create(JavaVMInitArgs *vm_args) else if (strcmp("jit", opt_arg) == 0) { opt_verbose = true; loadverbose = true; - linkverbose = true; initverbose = true; compileverbose = true; } @@ -1814,12 +1814,12 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args) { utf *mainutf; classinfo *mainclass; - java_objectheader *e; + java_handle_t *e; methodinfo *m; java_objectarray *oa; s4 oalength; utf *u; - java_objectheader *s; + java_handle_t *s; s4 status; s4 i; @@ -2157,10 +2157,10 @@ void vm_abort(const char *text, ...) static char *vm_get_mainclass_from_jar(char *mainstring) { - classinfo *c; - java_objectheader *o; - methodinfo *m; - java_objectheader *s; + classinfo *c; + java_handle_t *o; + methodinfo *m; + java_handle_t *s; c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile")); @@ -2472,7 +2472,7 @@ static void vm_array_store_flt(uint64_t *array, paramdesc *pd, uint64_t value) #else index = INT_ARG_CNT + pd->index; #endif -#if WORDS_BIGENDIAN == 1 && !defined(__POWERPC64__) +#if WORDS_BIGENDIAN == 1 && !defined(__POWERPC__) && !defined(__POWERPC64__) && !defined(__S390__) array[index] = value >> 32; #else array[index] = value; @@ -2546,7 +2546,7 @@ static void vm_array_store_adr(uint64_t *array, paramdesc *pd, void *value) #if SIZEOF_VOID_P == 8 array[index] = (uint64_t) (intptr_t) value; #else -# if WORDS_BIGENDIAN == 1 && !defined(__POWERPC64__) +# if WORDS_BIGENDIAN == 1 array[index] = ((uint64_t) (intptr_t) value) << 32; # else array[index] = (uint64_t) (intptr_t) value; @@ -2556,71 +2556,13 @@ static void vm_array_store_adr(uint64_t *array, paramdesc *pd, void *value) } -/* vm_vmargs_from_valist ******************************************************* +/* vm_array_from_valist ******************************************************** XXX *******************************************************************************/ -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o, - vm_arg *vmargs, va_list ap) -{ - typedesc *paramtypes; - s4 i; - - paramtypes = m->parseddesc->paramtypes; - - /* if method is non-static fill first block and skip `this' pointer */ - - i = 0; - - if (o != NULL) { - /* the `this' pointer */ - vmargs[0].type = TYPE_ADR; - vmargs[0].data.l = (u8) (ptrint) o; - - paramtypes++; - i++; - } - - for (; i < m->parseddesc->paramcount; i++, paramtypes++) { - switch (paramtypes->type) { - case TYPE_INT: - vmargs[i].type = TYPE_INT; - vmargs[i].data.l = (s8) va_arg(ap, s4); - break; - - case TYPE_LNG: - vmargs[i].type = TYPE_LNG; - vmargs[i].data.l = (s8) va_arg(ap, s8); - break; - - case TYPE_FLT: - vmargs[i].type = TYPE_FLT; -#if defined(__ALPHA__) - /* this keeps the assembler function much simpler */ - - vmargs[i].data.d = (jdouble) va_arg(ap, jdouble); -#else - vmargs[i].data.f = (jfloat) va_arg(ap, jdouble); -#endif - break; - - case TYPE_DBL: - vmargs[i].type = TYPE_DBL; - vmargs[i].data.d = (jdouble) va_arg(ap, jdouble); - break; - - case TYPE_ADR: - vmargs[i].type = TYPE_ADR; - vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*); - break; - } - } -} -#else -uint64_t *vm_array_from_valist(methodinfo *m, java_objectheader *o, va_list ap) +uint64_t *vm_array_from_valist(methodinfo *m, java_object_t *o, va_list ap) { methoddesc *md; paramdesc *pd; @@ -2665,8 +2607,9 @@ uint64_t *vm_array_from_valist(methodinfo *m, java_objectheader *o, va_list ap) break; case TYPE_FLT: -#if defined(__ALPHA__) || defined(__POWERPC64__) - /* this keeps the assembler function much simpler */ +#if defined(__ALPHA__) || defined(__POWERPC__) || defined(__POWERPC64__) + /* This is required to load the correct float value in + assembler code. */ value.d = (double) va_arg(ap, double); #else @@ -2689,75 +2632,15 @@ uint64_t *vm_array_from_valist(methodinfo *m, java_objectheader *o, va_list ap) return array; } -#endif -/* vm_vmargs_from_jvalue ******************************************************* +/* vm_array_from_jvalue ******************************************************** XXX *******************************************************************************/ -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o, - vm_arg *vmargs, const jvalue *args) -{ - typedesc *paramtypes; - s4 i; - s4 j; - - paramtypes = m->parseddesc->paramtypes; - - /* if method is non-static fill first block and skip `this' pointer */ - - i = 0; - - if (o != NULL) { - /* the `this' pointer */ - vmargs[0].type = TYPE_ADR; - vmargs[0].data.l = (u8) (ptrint) o; - - paramtypes++; - i++; - } - - for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) { - switch (paramtypes->decltype) { - case TYPE_INT: - vmargs[i].type = TYPE_INT; - vmargs[i].data.l = (s8) args[j].i; - break; - - case TYPE_LNG: - vmargs[i].type = TYPE_LNG; - vmargs[i].data.l = (s8) args[j].j; - break; - - case TYPE_FLT: - vmargs[i].type = TYPE_FLT; -#if defined(__ALPHA__) - /* this keeps the assembler function much simpler */ - - vmargs[i].data.d = (jdouble) args[j].f; -#else - vmargs[i].data.f = args[j].f; -#endif - break; - - case TYPE_DBL: - vmargs[i].type = TYPE_DBL; - vmargs[i].data.d = args[j].d; - break; - - case TYPE_ADR: - vmargs[i].type = TYPE_ADR; - vmargs[i].data.l = (u8) (ptrint) args[j].l; - break; - } - } -} -#else -static uint64_t *vm_array_from_jvalue(methodinfo *m, java_objectheader *o, +static uint64_t *vm_array_from_jvalue(methodinfo *m, java_object_t *o, const jvalue *args) { methoddesc *md; @@ -2820,193 +2703,26 @@ static uint64_t *vm_array_from_jvalue(methodinfo *m, java_objectheader *o, return array; } -#endif -/* vm_vmargs_from_objectarray ************************************************** + +/* vm_array_from_objectarray *************************************************** XXX *******************************************************************************/ -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o, - vm_arg *vmargs, java_objectarray *params) -{ - java_objectheader *param; - typedesc *paramtypes; - classinfo *c; - int32_t i; - int32_t j; - int64_t value; - - paramtypes = m->parseddesc->paramtypes; - - /* if method is non-static fill first block and skip `this' pointer */ - - i = 0; - - if (o != NULL) { - /* this pointer */ - vmargs[0].type = TYPE_ADR; - vmargs[0].data.l = (uint64_t) (intptr_t) o; - - paramtypes++; - i++; - } - - for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) { - switch (paramtypes->type) { - /* primitive types */ - case TYPE_INT: - case TYPE_LNG: - case TYPE_FLT: - case TYPE_DBL: - param = params->data[j]; - - if (param == NULL) - goto illegal_arg; - - /* internally used data type */ - vmargs[i].type = paramtypes->type; - - /* convert the value according to its declared type */ - - c = param->vftbl->class; - - switch (paramtypes->decltype) { - case PRIMITIVETYPE_BOOLEAN: - if (c == class_java_lang_Boolean) - value = (int64_t) ((java_lang_Boolean *) param)->value; - else - goto illegal_arg; - - vmargs[i].data.l = value; - break; - - case PRIMITIVETYPE_BYTE: - if (c == class_java_lang_Byte) - value = (int64_t) ((java_lang_Byte *) param)->value; - else - goto illegal_arg; - - vmargs[i].data.l = value; - break; - - case PRIMITIVETYPE_CHAR: - if (c == class_java_lang_Character) - value = (int64_t) ((java_lang_Character *) param)->value; - else - goto illegal_arg; - - vmargs[i].data.l = value; - break; - - case PRIMITIVETYPE_SHORT: - if (c == class_java_lang_Short) - value = (int64_t) ((java_lang_Short *) param)->value; - else if (c == class_java_lang_Byte) - value = (int64_t) ((java_lang_Byte *) param)->value; - else - goto illegal_arg; - - vmargs[i].data.l = value; - break; - - case PRIMITIVETYPE_INT: - if (c == class_java_lang_Integer) - value = (int64_t) ((java_lang_Integer *) param)->value; - else if (c == class_java_lang_Short) - value = (int64_t) ((java_lang_Short *) param)->value; - else if (c == class_java_lang_Byte) - value = (int64_t) ((java_lang_Byte *) param)->value; - else - goto illegal_arg; - - vmargs[i].data.l = value; - break; - - case PRIMITIVETYPE_LONG: - if (c == class_java_lang_Long) - value = (int64_t) ((java_lang_Long *) param)->value; - else if (c == class_java_lang_Integer) - value = (int64_t) ((java_lang_Integer *) param)->value; - else if (c == class_java_lang_Short) - value = (int64_t) ((java_lang_Short *) param)->value; - else if (c == class_java_lang_Byte) - value = (int64_t) ((java_lang_Byte *) param)->value; - else - goto illegal_arg; - - vmargs[i].data.l = value; - break; - - case PRIMITIVETYPE_FLOAT: - if (c == class_java_lang_Float) - vmargs[i].data.f = (jfloat) ((java_lang_Float *) param)->value; - else - goto illegal_arg; - break; - - case PRIMITIVETYPE_DOUBLE: - if (c == class_java_lang_Double) - vmargs[i].data.d = (jdouble) ((java_lang_Double *) param)->value; - else if (c == class_java_lang_Float) - vmargs[i].data.f = (jfloat) ((java_lang_Float *) param)->value; - else - goto illegal_arg; - break; - - default: - goto illegal_arg; - } - break; - - case TYPE_ADR: - if (!resolve_class_from_typedesc(paramtypes, true, true, &c)) - return false; - - if (params->data[j] != 0) { - if (paramtypes->arraydim > 0) { - if (!builtin_arrayinstanceof(params->data[j], c)) - goto illegal_arg; - - } else { - if (!builtin_instanceof(params->data[j], c)) - goto illegal_arg; - } - } - - vmargs[i].type = TYPE_ADR; - vmargs[i].data.l = (u8) (ptrint) params->data[j]; - break; - - default: - goto illegal_arg; - } - } - -/* if (rettype) */ -/* *rettype = descr->returntype.decltype; */ - - return true; - -illegal_arg: - exceptions_throw_illegalargumentexception(); - return false; -} -#else -uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o, +uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o, java_objectarray *params) { - methoddesc *md; - paramdesc *pd; - typedesc *td; - uint64_t *array; - java_objectheader *param; - classinfo *c; - int32_t i; - int32_t j; - imm_union value; + methoddesc *md; + paramdesc *pd; + typedesc *td; + uint64_t *array; + java_object_t *param; + classinfo *c; + int32_t i; + int32_t j; + imm_union value; /* get the descriptors */ @@ -3046,41 +2762,41 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o, switch (td->decltype) { case PRIMITIVETYPE_BOOLEAN: if (c == class_java_lang_Boolean) - value.i = ((java_lang_Boolean *) param)->value; + LLNI_field_get_val((java_lang_Boolean *) param, value, value.i); else goto illegal_arg; break; case PRIMITIVETYPE_BYTE: if (c == class_java_lang_Byte) - value.i = ((java_lang_Byte *) param)->value; + LLNI_field_get_val((java_lang_Byte *) param, value, value.i); else goto illegal_arg; break; case PRIMITIVETYPE_CHAR: if (c == class_java_lang_Character) - value.i = ((java_lang_Character *) param)->value; + LLNI_field_get_val((java_lang_Character *) param, value, value.i); else goto illegal_arg; break; case PRIMITIVETYPE_SHORT: if (c == class_java_lang_Short) - value.i = ((java_lang_Short *) param)->value; + LLNI_field_get_val((java_lang_Short *) param, value, value.i); else if (c == class_java_lang_Byte) - value.i = ((java_lang_Byte *) param)->value; + LLNI_field_get_val((java_lang_Byte *) param, value, value.i); else goto illegal_arg; break; case PRIMITIVETYPE_INT: if (c == class_java_lang_Integer) - value.i = ((java_lang_Integer *) param)->value; + LLNI_field_get_val((java_lang_Integer *) param, value, value.i); else if (c == class_java_lang_Short) - value.i = ((java_lang_Short *) param)->value; + LLNI_field_get_val((java_lang_Short *) param, value, value.i); else if (c == class_java_lang_Byte) - value.i = ((java_lang_Byte *) param)->value; + LLNI_field_get_val((java_lang_Byte *) param, value, value.i); else goto illegal_arg; break; @@ -3103,13 +2819,13 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o, switch (td->decltype) { case PRIMITIVETYPE_LONG: if (c == class_java_lang_Long) - value.l = ((java_lang_Long *) param)->value; + LLNI_field_get_val((java_lang_Long *) param, value, value.l); else if (c == class_java_lang_Integer) - value.l = (int64_t) ((java_lang_Integer *) param)->value; + value.l = (int64_t) LLNI_field_direct(((java_lang_Integer *) param), value); else if (c == class_java_lang_Short) - value.l = (int64_t) ((java_lang_Short *) param)->value; + value.l = (int64_t) LLNI_field_direct(((java_lang_Short *) param), value); else if (c == class_java_lang_Byte) - value.l = (int64_t) ((java_lang_Byte *) param)->value; + value.l = (int64_t) LLNI_field_direct(((java_lang_Byte *) param), value); else goto illegal_arg; break; @@ -3132,7 +2848,7 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o, switch (td->decltype) { case PRIMITIVETYPE_FLOAT: if (c == class_java_lang_Float) - value.f = ((java_lang_Float *) param)->value; + LLNI_field_get_val((java_lang_Float *) param, value, value.f); else goto illegal_arg; break; @@ -3155,9 +2871,9 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o, switch (td->decltype) { case PRIMITIVETYPE_DOUBLE: if (c == class_java_lang_Double) - value.d = ((java_lang_Double *) param)->value; + LLNI_field_get_val((java_lang_Double *) param, value, value.d); else if (c == class_java_lang_Float) - value.f = ((java_lang_Float *) param)->value; + LLNI_field_get_val((java_lang_Float *) param, value, value.f); else goto illegal_arg; break; @@ -3198,1140 +2914,129 @@ illegal_arg: exceptions_throw_illegalargumentexception(); return NULL; } -#endif /* vm_call_method ************************************************************** - Calls a Java method with a variable number of arguments and returns - an address. + Calls a Java method with a variable number of arguments. *******************************************************************************/ -java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...) -{ - va_list ap; - java_objectheader *ro; - - va_start(ap, o); - ro = vm_call_method_valist(m, o, ap); - va_end(ap); - - return ro; +#define VM_CALL_METHOD(name, type) \ +type vm_call_method##name(methodinfo *m, java_handle_t *o, ...) \ +{ \ + va_list ap; \ + type value; \ + \ + va_start(ap, o); \ + value = vm_call_method##name##_valist(m, o, ap); \ + va_end(ap); \ + \ + return value; \ } +VM_CALL_METHOD(, java_handle_t *) +VM_CALL_METHOD(_int, int32_t) +VM_CALL_METHOD(_long, int64_t) +VM_CALL_METHOD(_float, float) +VM_CALL_METHOD(_double, double) + /* vm_call_method_valist ******************************************************* Calls a Java method with a variable number of arguments, passed via - a va_list, and returns an address. + a va_list. *******************************************************************************/ -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__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) - s4 vmargscount; - vm_arg *vmargs; - java_objectheader *ro; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_valist(m, o, vmargs, ap); - - /* call the Java method */ - - ro = vm_call_method_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return ro; -#else - java_objectheader *ro; - int32_t dumpsize; - uint64_t *array; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_valist(m, o, ap); - - /* call the Java method */ - - ro = vm_call_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return ro; -#endif +#define VM_CALL_METHOD_VALIST(name, type) \ +type vm_call_method##name##_valist(methodinfo *m, java_handle_t *o, \ + va_list ap) \ +{ \ + int32_t dumpsize; \ + uint64_t *array; \ + type value; \ + \ + dumpsize = dump_size(); \ + array = vm_array_from_valist(m, o, ap); \ + value = vm_call##name##_array(m, array); \ + dump_release(dumpsize); \ + \ + return value; \ } +VM_CALL_METHOD_VALIST(, java_handle_t *) +VM_CALL_METHOD_VALIST(_int, int32_t) +VM_CALL_METHOD_VALIST(_long, int64_t) +VM_CALL_METHOD_VALIST(_float, float) +VM_CALL_METHOD_VALIST(_double, double) + /* vm_call_method_jvalue ******************************************************* Calls a Java method with a variable number of arguments, passed via - a jvalue array, and returns an address. + a jvalue array. *******************************************************************************/ -java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) - s4 vmargscount; - vm_arg *vmargs; - java_objectheader *ro; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_jvalue(m, o, vmargs, args); - - /* call the Java method */ - - ro = vm_call_method_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return ro; -#else - java_objectheader *ro; - int32_t dumpsize; - uint64_t *array; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_jvalue(m, o, args); - - /* call the Java method */ - - ro = vm_call_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return ro; -#endif +#define VM_CALL_METHOD_JVALUE(name, type) \ +type vm_call_method##name##_jvalue(methodinfo *m, java_handle_t *o, \ + const jvalue *args) \ +{ \ + int32_t dumpsize; \ + uint64_t *array; \ + type value; \ + \ + dumpsize = dump_size(); \ + array = vm_array_from_jvalue(m, o, args); \ + value = vm_call##name##_array(m, array); \ + dump_release(dumpsize); \ + \ + return value; \ } +VM_CALL_METHOD_JVALUE(, java_handle_t *) +VM_CALL_METHOD_JVALUE(_int, int32_t) +VM_CALL_METHOD_JVALUE(_long, int64_t) +VM_CALL_METHOD_JVALUE(_float, float) +VM_CALL_METHOD_JVALUE(_double, double) + /* vm_call_array *************************************************************** Calls a Java method with a variable number of arguments, passed via - an argument array, and returns an address. + an argument array. *******************************************************************************/ -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount, - vm_arg *vmargs) -{ - java_objectheader *o; - - STATISTICS(count_calls_native_to_java++); +#define VM_CALL_ARRAY(name, type) \ +type vm_call##name##_array(methodinfo *m, uint64_t *array) \ +{ \ + methoddesc *md; \ + void *pv; \ + type value; \ + \ + md = m->parseddesc; \ + \ + if (m->code == NULL) \ + if (!jit_compile(m)) \ + return 0; \ + \ + pv = m->code->entrypoint; \ + \ + STATISTICS(count_calls_native_to_java++); \ + \ + value = asm_vm_call_method##name(pv, array, md->memuse); \ + \ + return value; \ +} -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE; -#endif +VM_CALL_ARRAY(, java_handle_t *) +VM_CALL_ARRAY(_int, int32_t) +VM_CALL_ARRAY(_long, int64_t) +VM_CALL_ARRAY(_float, float) +VM_CALL_ARRAY(_double, double) -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - o = intrp_asm_vm_call_method(m, vmargscount, vmargs); - else -# endif - o = asm_vm_call_method(m, vmargscount, vmargs); -#else - o = intrp_asm_vm_call_method(m, vmargscount, vmargs); -#endif - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE; -#endif - - return o; -} -#else -java_objectheader *vm_call_array(methodinfo *m, uint64_t *array) -{ - methoddesc *md; - java_objectheader *o; - - md = m->parseddesc; - - /* compile the method if not already done */ - - if (m->code == NULL) - if (!jit_compile(m)) - return NULL; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - o = intrp_asm_vm_call_method(m, vmargscount, vmargs); - else -# endif - o = asm_vm_call_method(m->code->entrypoint, array, md->memuse); -#else - o = intrp_asm_vm_call_method(m, vmargscount, vmargs); -#endif - - return o; -} -#endif - - -/* vm_call_int_array *********************************************************** - - Calls a Java method with a variable number of arguments, passed via - an argument array, and returns an integer (int32_t). - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs) -{ - s4 i; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE; -#endif - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs); - else -# endif - i = asm_vm_call_method_int(m, vmargscount, vmargs); -#else - i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs); -#endif - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE; -#endif - - return i; -} -#else -int32_t vm_call_int_array(methodinfo *m, uint64_t *array) -{ - methoddesc *md; - int32_t i; - - md = m->parseddesc; - - /* compile the method if not already done */ - - if (m->code == NULL) - if (!jit_compile(m)) - return 0; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs); - else -# endif - i = asm_vm_call_method_int(m->code->entrypoint, array, md->memuse); -#else - i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs); -#endif - - return i; -} -#endif - - -/* vm_call_method_int ********************************************************** - - Calls a Java method with a variable number of arguments and returns - an integer (s4). - -*******************************************************************************/ - -s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...) -{ - va_list ap; - s4 i; - - va_start(ap, o); - i = vm_call_method_int_valist(m, o, ap); - va_end(ap); - - return i; -} - - -/* vm_call_method_int_valist *************************************************** - - Calls a Java method with a variable number of arguments, passed via - a va_list, and returns an integer (int32_t). - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap) -{ - s4 vmargscount; - vm_arg *vmargs; - s4 i; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_valist(m, o, vmargs, ap); - - /* call the Java method */ - - i = vm_call_method_int_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return i; -} -#else -int32_t vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap) -{ - int32_t dumpsize; - uint64_t *array; - int32_t i; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_valist(m, o, ap); - - /* call the Java method */ - - i = vm_call_int_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return i; -} -#endif - - -/* vm_call_method_int_jvalue *************************************************** - - Calls a Java method with a variable number of arguments, passed via - a jvalue array, and returns an integer (s4). - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ - s4 vmargscount; - vm_arg *vmargs; - s4 i; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_jvalue(m, o, vmargs, args); - - /* call the Java method */ - - i = vm_call_method_int_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return i; -} -#else -int32_t vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ - int32_t dumpsize; - uint64_t *array; - int32_t i; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_jvalue(m, o, args); - - /* call the Java method */ - - i = vm_call_int_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return i; -} -#endif - - -/* vm_call_long_array ********************************************************** - - Calls a Java method with a variable number of arguments, passed via - an argument array, and returns a long (int64_t). - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs) -{ - s8 l; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE; -#endif - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs); - else -# endif - l = asm_vm_call_method_long(m, vmargscount, vmargs); -#else - l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs); -#endif - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE; -#endif - - return l; -} -#else -int64_t vm_call_long_array(methodinfo *m, uint64_t *array) -{ - methoddesc *md; - int64_t l; - - md = m->parseddesc; - - /* compile the method if not already done */ - - if (m->code == NULL) - if (!jit_compile(m)) - return 0; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs); - else -# endif - l = asm_vm_call_method_long(m->code->entrypoint, array, md->memuse); -#else - l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs); -#endif - - return l; -} -#endif - - -/* vm_call_method_long ********************************************************* - - Calls a Java method with a variable number of arguments and returns - a long (s8). - -*******************************************************************************/ - -s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...) -{ - va_list ap; - s8 l; - - va_start(ap, o); - l = vm_call_method_long_valist(m, o, ap); - va_end(ap); - - return l; -} - - -/* vm_call_method_long_valist ************************************************** - - Calls a Java method with a variable number of arguments, passed via - a va_list, and returns a long (s8). - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap) -{ - s4 vmargscount; - vm_arg *vmargs; - s8 l; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_valist(m, o, vmargs, ap); - - /* call the Java method */ - - l = vm_call_method_long_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return l; -} -#else -int64_t vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap) -{ - int32_t dumpsize; - uint64_t *array; - int64_t l; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_valist(m, o, ap); - - /* call the Java method */ - - l = vm_call_long_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return l; -} -#endif - - -/* vm_call_method_long_jvalue ************************************************** - - Calls a Java method with a variable number of arguments, passed via - a jvalue array, and returns a long (s8). - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ - s4 vmargscount; - vm_arg *vmargs; - s8 l; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_jvalue(m, o, vmargs, args); - - /* call the Java method */ - - l = vm_call_method_long_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return l; -} -#else -int64_t vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ - int32_t dumpsize; - uint64_t *array; - int64_t l; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_jvalue(m, o, args); - - /* call the Java method */ - - l = vm_call_long_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return l; -} -#endif - - -/* vm_call_float_array ********************************************************* - - Calls a Java method with a variable number of arguments and returns - an float. - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs) -{ - float f; - - vm_abort("IMPLEMENT ME!"); - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE; -#endif - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs); - else -# endif - f = asm_vm_call_method_float(m, vmargscount, vmargs); -#else - f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs); -#endif - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE; -#endif - - return f; -} -#else -float vm_call_float_array(methodinfo *m, uint64_t *array) -{ - methoddesc *md; - float f; - - md = m->parseddesc; - - /* compile the method if not already done */ - - if (m->code == NULL) - if (!jit_compile(m)) - return 0; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs); - else -# endif - f = asm_vm_call_method_float(m->code->entrypoint, array, md->memuse); -#else - f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs); -#endif - - return f; -} -#endif - -/* vm_call_method_float ******************************************************** - - Calls a Java method with a variable number of arguments and returns - an float. - -*******************************************************************************/ - -float vm_call_method_float(methodinfo *m, java_objectheader *o, ...) -{ - va_list ap; - float f; - - va_start(ap, o); - f = vm_call_method_float_valist(m, o, ap); - va_end(ap); - - return f; -} - - -/* vm_call_method_float_valist ************************************************* - - Calls a Java method with a variable number of arguments, passed via - a va_list, and returns a float. - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -float vm_call_method_float_valist(methodinfo *m, java_objectheader *o, - va_list ap) -{ - s4 vmargscount; - vm_arg *vmargs; - float f; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_valist(m, o, vmargs, ap); - - /* call the Java method */ - - f = vm_call_method_float_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return f; -} -#else -float vm_call_method_float_valist(methodinfo *m, java_objectheader *o, va_list ap) -{ - int32_t dumpsize; - uint64_t *array; - float f; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_valist(m, o, ap); - - /* call the Java method */ - - f = vm_call_float_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return f; -} -#endif - -/* vm_call_method_float_jvalue ************************************************* - - Calls a Java method with a variable number of arguments, passed via - a jvalue array, and returns a float. - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ - s4 vmargscount; - vm_arg *vmargs; - float f; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_jvalue(m, o, vmargs, args); - - /* call the Java method */ - - f = vm_call_method_float_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return f; -} -#else -float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o, const jvalue *args) -{ - int32_t dumpsize; - uint64_t *array; - float f; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_jvalue(m, o, args); - - /* call the Java method */ - - f = vm_call_float_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return f; -} -#endif - - -/* vm_call_double_array ******************************************************** - - Calls a Java method with a variable number of arguments and returns - a double. - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount, - vm_arg *vmargs) -{ - double d; - - vm_abort("IMPLEMENT ME!"); - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE; -#endif - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs); - else -# endif - d = asm_vm_call_method_double(m, vmargscount, vmargs); -#else - d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs); -#endif - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE; -#endif - - return d; -} -#else -double vm_call_double_array(methodinfo *m, uint64_t *array) -{ - methoddesc *md; - double d; - - md = m->parseddesc; - - /* compile the method if not already done */ - - if (m->code == NULL) - if (!jit_compile(m)) - return 0; - - STATISTICS(count_calls_native_to_java++); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs); - else -# endif - d = asm_vm_call_method_double(m->code->entrypoint, array, md->memuse); -#else - d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs); -#endif - - return d; -} -#endif - - -/* vm_call_method_double ******************************************************* - - Calls a Java method with a variable number of arguments and returns - a double. - -*******************************************************************************/ - -double vm_call_method_double(methodinfo *m, java_objectheader *o, ...) -{ - va_list ap; - double d; - - va_start(ap, o); - d = vm_call_method_double_valist(m, o, ap); - va_end(ap); - - return d; -} - - -/* vm_call_method_double_valist ************************************************ - - Calls a Java method with a variable number of arguments, passed via - a va_list, and returns a double. - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -double vm_call_method_double_valist(methodinfo *m, java_objectheader *o, - va_list ap) -{ - s4 vmargscount; - vm_arg *vmargs; - double d; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_valist(m, o, vmargs, ap); - - /* call the Java method */ - - d = vm_call_method_double_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return d; -} -#else -double vm_call_method_double_valist(methodinfo *m, java_objectheader *o, va_list ap) -{ - int32_t dumpsize; - uint64_t *array; - double d; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_valist(m, o, ap); - - /* call the Java method */ - - d = vm_call_double_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return d; -} -#endif - - -/* vm_call_method_double_jvalue ************************************************ - - Calls a Java method with a variable number of arguments, passed via - a jvalue array, and returns a double. - -*******************************************************************************/ - -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o, - const jvalue *args) -{ - s4 vmargscount; - vm_arg *vmargs; - double d; - s4 dumpsize; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* get number of Java method arguments */ - - vmargscount = m->parseddesc->paramcount; - - /* allocate vm_arg array */ - - vmargs = DMNEW(vm_arg, vmargscount); - - /* fill the vm_arg array from a va_list */ - - vm_vmargs_from_jvalue(m, o, vmargs, args); - - /* call the Java method */ - - d = vm_call_method_double_vmarg(m, vmargscount, vmargs); - - /* release dump area */ - - dump_release(dumpsize); - - return d; -} -#else -double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o, const jvalue *args) -{ - int32_t dumpsize; - uint64_t *array; - double d; - - /* mark start of dump memory area */ - - dumpsize = dump_size(); - - /* fill the argument array from a va_list */ - - array = vm_array_from_jvalue(m, o, args); - - /* call the Java method */ - - d = vm_call_double_array(m, array); - - /* release dump area */ - - dump_release(dumpsize); - - return d; -} -#endif /* * These are local overrides for various environment variables in Emacs. diff --git a/src/vm/vm.h b/src/vm/vm.h index 9aefe59f5..1c78bd6df 100644 --- a/src/vm/vm.h +++ b/src/vm/vm.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: finalizer.c 4357 2006-01-22 23:33:38Z twisti $ + $Id: vm.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -68,26 +68,6 @@ extern u1 *intrp_main_stack; #endif -/* vm_arg ********************************************************************** - - Datastructure for arguments to call Java methods via vm_call_method - functions. - -*******************************************************************************/ - -typedef struct vm_arg vm_arg; - -struct vm_arg { - u8 type; - - union { - u8 l; - float f; - double d; - } data; -}; - - /* function prototypes ********************************************************/ void usage(void); @@ -105,56 +85,37 @@ 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__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o, - vm_arg *vmargs, java_objectarray *params); -#else -uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o, + +uint64_t *vm_array_from_objectarray(methodinfo *m, java_handle_t *o, java_objectarray *params); -#endif -java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...); -java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o, +java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...); +java_handle_t *vm_call_method_valist(methodinfo *m, java_handle_t *o, va_list ap); -java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o, +java_handle_t *vm_call_method_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); -#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__) -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); -s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs); -float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs); -double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs); -#else -java_objectheader *vm_call_array(methodinfo *m, uint64_t *array); +java_handle_t *vm_call_array(methodinfo *m, uint64_t *array); int32_t vm_call_int_array(methodinfo *m, uint64_t *array); int64_t vm_call_long_array(methodinfo *m, uint64_t *array); float vm_call_float_array(methodinfo *m, uint64_t *array); double vm_call_double_array(methodinfo *m, uint64_t *array); -#endif -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, - 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, - 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, - 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, - const jvalue *args); +int32_t vm_call_method_int(methodinfo *m, java_handle_t *o, ...); +int32_t vm_call_method_int_valist(methodinfo *m, java_handle_t *o, va_list ap); +int32_t vm_call_method_int_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +int64_t vm_call_method_long(methodinfo *m, java_handle_t *o, ...); +int64_t vm_call_method_long_valist(methodinfo *m, java_handle_t *o, va_list ap); +int64_t vm_call_method_long_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +float vm_call_method_float(methodinfo *m, java_handle_t *o, ...); +float vm_call_method_float_valist(methodinfo *m, java_handle_t *o, va_list ap); +float vm_call_method_float_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +double vm_call_method_double(methodinfo *m, java_handle_t *o, ...); +double vm_call_method_double_valist(methodinfo *m, java_handle_t *o, va_list ap); +double vm_call_method_double_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); #endif /* _VM_H */ diff --git a/src/vmcore/Makefile.am b/src/vmcore/Makefile.am index 1d647a9ef..7a21b34fe 100644 --- a/src/vmcore/Makefile.am +++ b/src/vmcore/Makefile.am @@ -31,9 +31,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top LIBS = if ENABLE_JAVASE +if ENABLE_ANNOTATIONS ANNOTATION_SOURCES = \ annotation.c \ annotation.h +endif STACKMAP_SOURCES = \ stackmap.c \ @@ -79,8 +81,7 @@ libvmcore_la_SOURCES = \ method.h \ options.c \ options.h \ - primitive.c \ - primitive.h \ + primitivecore.c \ references.h \ $(RT_TIMING_SOURCES) \ $(STACKMAP_SOURCES) \ diff --git a/src/vmcore/annotation.c b/src/vmcore/annotation.c index 86e7f115e..a266b4aa4 100644 --- a/src/vmcore/annotation.c +++ b/src/vmcore/annotation.c @@ -22,148 +22,533 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: utf8.h 5920 2006-11-05 21:23:09Z twisti $ + $Id$ */ - #include "config.h" + +#include + #include "vm/types.h" #include "mm/memory.h" +#include "toolbox/logging.h" + #include "vmcore/annotation.h" #include "vmcore/class.h" #include "vmcore/suck.h" +#if !defined(ENABLE_ANNOTATIONS) +# error annotation support has to be enabled when compling this file! +#endif + +/* annotation_bytearray_new *************************************************** + + Allocate a new bytearray. + +*******************************************************************************/ + +annotation_bytearray_t *annotation_bytearray_new(uint32_t size) +{ + annotation_bytearray_t *ba = + mem_alloc(sizeof(uint32_t) + sizeof(uint8_t) * size); + + if (ba != NULL) { + ba->size = size; + } + + return ba; +} + + +/* annotation_bytearray_free ************************************************** + + Free a bytearray. + +*******************************************************************************/ + +void annotation_bytearray_free(annotation_bytearray_t *ba) +{ + if (ba != NULL) { + mem_free(ba, sizeof(uint32_t) + sizeof(uint8_t) * ba->size); + } +} + + +/* annotation_bytearrays_new ************************************************** -/* annotation_load_attribute_runtimevisibleannotations ************************* + Allocate a new array of bytearrays. - RuntimeVisibleAnnotations_attribute { +*******************************************************************************/ + +annotation_bytearrays_t *annotation_bytearrays_new(uint32_t size) +{ + annotation_bytearrays_t *bas = + mem_alloc(sizeof(uint32_t) + sizeof(annotation_bytearray_t*) * size); + + if (bas != NULL) { + bas->size = size; + } + + return bas; +} + + +/* annotation_bytearrays_resize *********************************************** + + Resize an array of bytearrays. + +*******************************************************************************/ + +bool annotation_bytearrays_resize(annotation_bytearrays_t **bas, + uint32_t size) +{ + annotation_bytearrays_t *newbas = NULL; + uint32_t i; + uint32_t minsize; + + assert(bas != NULL); + + newbas = annotation_bytearrays_new(size); + + if (newbas == NULL) { + return false; + } + + if (*bas != NULL) { + minsize = size < (*bas)->size ? size : (*bas)->size; + + for (i = size; i < (*bas)->size; ++ i) { + annotation_bytearray_free((*bas)->data[i]); + } + + for (i = 0; i < minsize; ++i) { + newbas->data[i] = (*bas)->data[i]; + } + } + + *bas = newbas; + + return true; +} + + +/* annotation_bytearrays_insert *********************************************** + + Insert a bytearray into an array of bytearrays. + +*******************************************************************************/ + +bool annotation_bytearrays_insert(annotation_bytearrays_t **bas, + uint32_t index, annotation_bytearray_t *ba) +{ + assert(bas != NULL); + + if (ba != NULL) { + if (*bas == NULL || (*bas)->size <= index) { + if (!annotation_bytearrays_resize(bas, index + 1)) { + return false; + } + } + else { + /* free old bytearray (if any) */ + annotation_bytearray_free((*bas)->data[index]); + } + + /* insert new bytearray */ + (*bas)->data[index] = ba; + } + else if (*bas != NULL && (*bas)->size > index) { + /* do not resize when just inserting NULL, + * but free old bytearray if there is any */ + annotation_bytearray_free((*bas)->data[index]); + } + + return true; +} + + +/* annotation_bytearrays_free ************************************************* + + Free an array of bytearrays. + +*******************************************************************************/ + +void annotation_bytearrays_free(annotation_bytearrays_t *bas) +{ + uint32_t i; + + if (bas != NULL) { + for (i = 0; i < bas->size; ++ i) { + annotation_bytearray_free(bas->data[i]); + } + + mem_free(bas, sizeof(uint32_t) + + sizeof(annotation_bytearray_t*) * bas->size); + } +} + + +/* annotation_load_attribute_body ********************************************* + + This function loads the body of a generic attribute. + + XXX: Maybe this function should be called loader_load_attribute_body and + located in vmcore/loader.c? + + attribute_info { u2 attribute_name_index; u4 attribute_length; - u2 num_annotations; - annotation annotations[num_annotations]; + u1 info[attribute_length]; } - annotation { - u2 type_index; - u2 num_element_value_pairs; - { - u2 element_name_index; - element_value element; - } element_value_pairs[num_element_value_pairs]; - } + IN: + cb.................classbuffer from which to read the data. + errormsg_prefix....prefix for error messages (if any). - element_value { - u1 tag; - union { - u2 const_value_index; - { - u2 type_name_index; - u2 const_name_index; - } enum_const_value; - u2 class_info_index; - annotation annotation_value; - { - u2 num_values; - element_value values[num_values]; - } array_value; - } value; - } + OUT: + attribute..........bytearray-pointer which will be set to the read data. + + RETURN VALUE: + true if all went good. false otherwhise. *******************************************************************************/ -bool annotation_load_attribute_runtimevisibleannotations(classbuffer *cb) +static bool annotation_load_attribute_body(classbuffer *cb, + annotation_bytearray_t **attribute, const char *errormsg_prefix) { - classinfo *c; - u4 attribute_length; - u2 num_annotations; - annotation_t *annotations; - element_value_t *element_value; - u2 type_index; - u2 num_element_value_pairs; - u2 element_name_index; - u4 i, j; + uint32_t size = 0; + annotation_bytearray_t *ba = NULL; - /* get classinfo */ + assert(cb != NULL); + assert(attribute != NULL); - c = cb->class; + if (!suck_check_classbuffer_size(cb, 4)) { + log_println("%s: size missing", errormsg_prefix); + return false; + } - if (!suck_check_classbuffer_size(cb, 4 + 2)) + /* load attribute_length */ + size = suck_u4(cb); + + if (!suck_check_classbuffer_size(cb, size)) { + log_println("%s: invalid size", errormsg_prefix); return false; + } + + /* if attribute_length == 0 then NULL is + * the right value for this attribute */ + if (size > 0) { + ba = annotation_bytearray_new(size); + + if (ba == NULL) { + /* out of memory */ + return false; + } + + /* load data */ + suck_nbytes(ba->data, cb, size); + + /* return data */ + *attribute = ba; + } + + return true; +} - /* attribute_length */ - attribute_length = suck_u4(cb); +/* annotation_load_method_attribute_annotationdefault ************************* - if (!suck_check_classbuffer_size(cb, attribute_length)) + Load annotation default value. + + AnnotationDefault_attribute { + u2 attribute_name_index; + u4 attribute_length; + element_value default_value; + } + + IN: + cb.................classbuffer from which to read the data. + m..................methodinfo for the method of which the annotation + default value is read and into which the value is + stored into. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_method_attribute_annotationdefault( + classbuffer *cb, methodinfo *m) +{ + int slot = 0; + annotation_bytearray_t *annotationdefault = NULL; + annotation_bytearrays_t **annotationdefaults = NULL; + + assert(cb != NULL); + assert(m != NULL); + + annotationdefaults = &(m->class->method_annotationdefaults); + + if (!annotation_load_attribute_body( + cb, &annotationdefault, + "invalid annotation default method attribute")) { return false; + } + + if (annotationdefault != NULL) { + slot = m - m->class->methods; - /* get number of annotations */ + if (!annotation_bytearrays_insert( + annotationdefaults, slot, annotationdefault)) { + annotation_bytearray_free(annotationdefault); + return false; + } + } - num_annotations = suck_u2(cb); + return true; +} - printf("num_annotations: %d\n", num_annotations); - /* allocate annotations-array */ +/* annotation_load_method_attribute_runtimevisibleparameterannotations ******** - annotations = MNEW(annotation_t, num_annotations); + Load runtime visible parameter annotations. - /* parse all annotations */ + RuntimeVisibleParameterAnnotations_attribute { + u2 attribute_name_index; + u4 attribute_length; + u1 num_parameters; + { + u2 num_annotations; + annotation annotations[num_annotations]; + } parameter_annotations[num_parameters]; + } - for (i = 0; i < num_annotations; i++) { - /* get annotation type */ + IN: + cb.................classbuffer from which to read the data. + m..................methodinfo for the method of which the parameter + annotations are read and into which the parameter + annotations are stored into. - type_index = suck_u2(cb); + RETURN VALUE: + true if all went good. false otherwhise. - if (!(annotations[i].type = - class_getconstant(c, type_index, CONSTANT_Utf8))) +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimevisibleparameterannotations( + classbuffer *cb, methodinfo *m) +{ + int slot = 0; + annotation_bytearray_t *annotations = NULL; + annotation_bytearrays_t **parameterannotations = NULL; + + assert(cb != NULL); + assert(m != NULL); + + parameterannotations = &(m->class->method_parameterannotations); + + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible parameter annotations method attribute")) { + return false; + } + + if (annotations != NULL) { + slot = m - m->class->methods; + + if (!annotation_bytearrays_insert( + parameterannotations, slot, annotations)) { + annotation_bytearray_free(annotations); return false; + } + } + + return true; +} + - printf("type: "); - utf_display_printable_ascii(annotations[i].type); - printf("\n"); +/* annotation_load_method_attribute_runtimeinvisibleparameterannotations ****** + + Load runtime invisible parameter annotations. - /* get number of element values */ + + The RuntimeInvisibleParameterAnnotations attribute is similar to the + RuntimeVisibleParameterAnnotations attribute, except that the annotations + represented by a RuntimeInvisibleParameterAnnotations attribute must not be + made available for return by reflective APIs, unless the the JVM has + specifically been instructed to retain these annotations via some + implementation-specific mechanism such as a command line flag. In the + absence of such instructions, the JVM ignores this attribute. + - num_element_value_pairs = suck_u2(cb); + Hotspot loads them into the same bytearray as the runtime visible parameter + annotations (after the runtime visible parameter annotations). But in J2SE + the bytearray will only be parsed as if ther is only one annotation + structure in it, so the runtime invisible parameter annotatios will be + ignored. - printf("num_element_value_pairs: %d\n", num_element_value_pairs); + Therefore I do not even bother to read them. - element_value = MNEW(element_value_t, num_element_value_pairs); + RuntimeInvisibleParameterAnnotations_attribute { + u2 attribute_name_index; + u4 attribute_length; + u1 num_parameters; + { + u2 num_annotations; + annotation annotations[num_annotations]; + } parameter_annotations[num_parameters]; + } - /* parse all element values */ + IN: + cb.................classbuffer from which to read the data. + m..................methodinfo for the method of which the parameter + annotations are read and into which the parameter + annotations are stored into. - for (j = 0; j < num_element_value_pairs; j++) { - /* get element name */ + RETURN VALUE: + true if all went good. false otherwhise. - element_name_index = suck_u2(cb); +*******************************************************************************/ - if (!(element_value[j].name = - class_getconstant(c, element_name_index, CONSTANT_Utf8))) - return false; +bool annotation_load_method_attribute_runtimeinvisibleparameterannotations( + classbuffer *cb, methodinfo *m) +{ + return loader_skip_attribute_body(cb); +} - /* get element tag */ - element_value[i].tag = suck_u1(cb); +/* annotation_load_class_attribute_runtimevisibleannotations ****************** + + Load runtime visible annotations of a class. + +*******************************************************************************/ + +bool annotation_load_class_attribute_runtimevisibleannotations( + classbuffer *cb) +{ + return annotation_load_attribute_body( + cb, &(cb->class->annotations), + "invalid runtime visible annotations class attribute"); +} + + +/* annotation_load_class_attribute_runtimeinvisibleannotations **************** + + Load runtime invisible annotations of a class (just skip them). + +*******************************************************************************/ + +bool annotation_load_class_attribute_runtimeinvisibleannotations( + classbuffer *cb) +{ + return loader_skip_attribute_body(cb); +} + + +/* annotation_load_method_attribute_runtimevisibleannotations ***************** + + Load runtime visible annotations of a method. + +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimevisibleannotations( + classbuffer *cb, methodinfo *m) +{ + int slot = 0; + annotation_bytearray_t *annotations = NULL; + annotation_bytearrays_t **method_annotations = NULL; + + assert(cb != NULL); + assert(m != NULL); + + method_annotations = &(m->class->method_annotations); + + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible annotations method attribute")) { + return false; + } + + if (annotations != NULL) { + slot = m - m->class->methods; + + if (!annotation_bytearrays_insert( + method_annotations, slot, annotations)) { + annotation_bytearray_free(annotations); + return false; } + } + + return true; +} + + +/* annotation_load_method_attribute_runtimeinvisibleannotations **************** + + Load runtime invisible annotations of a method (just skip them). + +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimeinvisibleannotations( + classbuffer *cb, methodinfo *m) +{ + return loader_skip_attribute_body(cb); +} + + +/* annotation_load_field_attribute_runtimevisibleannotations ****************** + + Load runtime visible annotations of a field. + +*******************************************************************************/ + +bool annotation_load_field_attribute_runtimevisibleannotations( + classbuffer *cb, fieldinfo *f) +{ + int slot = 0; + annotation_bytearray_t *annotations = NULL; + annotation_bytearrays_t **field_annotations = NULL; + + assert(cb != NULL); + assert(f != NULL); - /* store element value data */ + field_annotations = &(f->class->field_annotations); - annotations[i].element_valuescount = num_element_value_pairs; - annotations[i].element_values = element_value; + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible annotations field attribute")) { + return false; } - /* store annotation variables */ + if (annotations != NULL) { + slot = f - f->class->fields; - c->runtimevisibleannotationscount = num_annotations; - c->runtimevisibleannotations = annotations; + if (!annotation_bytearrays_insert( + field_annotations, slot, annotations)) { + annotation_bytearray_free(annotations); + return false; + } + } return true; } +/* annotation_load_field_attribute_runtimeinvisibleannotations **************** + + Load runtime invisible annotations of a field (just skip them). + +*******************************************************************************/ + +bool annotation_load_field_attribute_runtimeinvisibleannotations( + classbuffer *cb, fieldinfo *f) +{ + return loader_skip_attribute_body(cb); +} + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vmcore/annotation.h b/src/vmcore/annotation.h index cafa190f7..3d2f4b768 100644 --- a/src/vmcore/annotation.h +++ b/src/vmcore/annotation.h @@ -22,8 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: utf8.h 5920 2006-11-05 21:23:09Z twisti $ - */ @@ -32,18 +30,37 @@ /* forward typedefs ***********************************************************/ -typedef struct annotation_t annotation_t; -typedef struct element_value_t element_value_t; +typedef struct annotation_bytearray_t annotation_bytearray_t; +typedef struct annotation_t annotation_t; +typedef struct element_value_t element_value_t; +typedef struct annotation_bytearrays_t annotation_bytearrays_t; #include "config.h" #include "vm/types.h" #include "vm/global.h" +#include "vmcore/class.h" +#include "vmcore/field.h" +#include "vmcore/method.h" #include "vmcore/loader.h" #include "vmcore/utf8.h" +/* annotation_bytearray *******************************************************/ + +struct annotation_bytearray_t { + uint32_t size; + uint8_t data[1]; +}; + +/* annotation_bytearrays ******************************************************/ + +struct annotation_bytearrays_t { + uint32_t size; + annotation_bytearray_t *data[1]; +}; + /* annotation *****************************************************************/ struct annotation_t { @@ -52,7 +69,6 @@ struct annotation_t { element_value_t *element_values; }; - /* element_value **************************************************************/ struct element_value_t { @@ -63,7 +79,46 @@ struct element_value_t { /* function prototypes ********************************************************/ -bool annotation_load_attribute_runtimevisibleannotations(classbuffer *cb); +annotation_bytearray_t *annotation_bytearray_new(uint32_t size); + +void annotation_bytearray_free(annotation_bytearray_t *ba); + +annotation_bytearrays_t *annotation_bytearrays_new(uint32_t size); + +bool annotation_bytearrays_resize(annotation_bytearrays_t **bas, + uint32_t size); + +bool annotation_bytearrays_insert(annotation_bytearrays_t **bas, + uint32_t index, annotation_bytearray_t *ba); + +void annotation_bytearrays_free(annotation_bytearrays_t *bas); + +bool annotation_load_class_attribute_runtimevisibleannotations( + classbuffer *cb); + +bool annotation_load_class_attribute_runtimeinvisibleannotations( + classbuffer *cb); + +bool annotation_load_method_attribute_runtimevisibleannotations( + classbuffer *cb, methodinfo *m); + +bool annotation_load_method_attribute_runtimeinvisibleannotations( + classbuffer *cb, methodinfo *m); + +bool annotation_load_field_attribute_runtimevisibleannotations( + classbuffer *cb, fieldinfo *f); + +bool annotation_load_field_attribute_runtimeinvisibleannotations( + classbuffer *cb, fieldinfo *f); + +bool annotation_load_method_attribute_annotationdefault( + classbuffer *cb, methodinfo *m); + +bool annotation_load_method_attribute_runtimevisibleparameterannotations( + classbuffer *cb, methodinfo *m); + +bool annotation_load_method_attribute_runtimeinvisibleparameterannotations( + classbuffer *cb, methodinfo *m); #endif /* _ANNOTATION_H */ diff --git a/src/vmcore/class.c b/src/vmcore/class.c index 99c3713cf..eedf0bc98 100644 --- a/src/vmcore/class.c +++ b/src/vmcore/class.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: class.c 8245 2007-07-31 09:55:04Z michi $ + $Id: class.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -52,6 +52,7 @@ #include "vmcore/class.h" #include "vmcore/classcache.h" +#include "vmcore/linker.h" #include "vmcore/loader.h" #include "vmcore/options.h" @@ -132,6 +133,11 @@ classinfo *class_java_security_PrivilegedAction; classinfo *class_java_util_Vector; classinfo *arrayclass_java_lang_Object; + +#if defined(ENABLE_ANNOTATIONS) +classinfo *class_sun_reflect_ConstantPool; +classinfo *class_sun_reflect_annotation_AnnotationParser; +#endif #endif @@ -602,17 +608,31 @@ bool class_load_attributes(classbuffer *cb) if (!loader_load_attribute_signature(cb, &(c->signature))) return false; } -#if 0 +#endif + +#if defined(ENABLE_ANNOTATIONS) /* XXX We can't do a release with that enabled */ else if (attribute_name == utf_RuntimeVisibleAnnotations) { /* RuntimeVisibleAnnotations */ - - if (!annotation_load_attribute_runtimevisibleannotations(cb)) + if (!annotation_load_class_attribute_runtimevisibleannotations(cb)) + return false; + } + /* XXX RuntimeInvisibleAnnotations should only be loaded + * (or returned to Java) if some commandline options says so. + * Currently there is no such option available in cacao, + * therefore I load them allways (for testing purpose). + * Anyway, bytecode for RuntimeInvisibleAnnotations is only + * generated if you tell javac to do so. So in most cases + * there won't be any. + */ + else if (attribute_name == utf_RuntimeInvisibleAnnotations) { + /* RuntimeInvisibleAnnotations */ + if (!annotation_load_class_attribute_runtimeinvisibleannotations(cb)) return false; } #endif -#endif + else { /* unknown attribute */ @@ -784,6 +804,16 @@ void class_free(classinfo *c) mem_free(c->header.vftbl, sizeof(vftbl) + sizeof(methodptr)*(c->vftbl->vftbllength-1)); */ /* GCFREE(c); */ + +#if defined(ENABLE_ANNOTATIONS) + annotation_bytearray_free(c->annotations); + + annotation_bytearrays_free(c->method_annotations); + annotation_bytearrays_free(c->method_parameterannotations); + annotation_bytearrays_free(c->method_annotationdefaults); + + annotation_bytearrays_free(c->field_annotations); +#endif } @@ -1522,8 +1552,7 @@ bool class_issubclass(classinfo *sub, classinfo *super) bool class_isanysubclass(classinfo *sub, classinfo *super) { - castinfo classvalues; - u4 diffval; + uint32_t diffval; bool result; /* This is the trivial case. */ @@ -1549,10 +1578,12 @@ bool class_isanysubclass(classinfo *sub, classinfo *super) if (sub->flags & ACC_INTERFACE) return (super == class_java_lang_Object); - ASM_GETCLASSVALUES_ATOMIC(super->vftbl, sub->vftbl, &classvalues); + LOCK_MONITOR_ENTER(linker_classrenumber_lock); + + diffval = sub->vftbl->baseval - super->vftbl->baseval; + result = diffval <= (uint32_t) super->vftbl->diffval; - diffval = classvalues.sub_baseval - classvalues.super_baseval; - result = diffval <= (u4) classvalues.super_diffval; + LOCK_MONITOR_EXIT(linker_classrenumber_lock); } return result; diff --git a/src/vmcore/class.h b/src/vmcore/class.h index c33e5d7b5..ac24cd1e8 100644 --- a/src/vmcore/class.h +++ b/src/vmcore/class.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: class.h 8245 2007-07-31 09:55:04Z michi $ + $Id: class.h 8299 2007-08-13 08:41:18Z michi $ */ @@ -85,7 +85,7 @@ typedef struct castinfo castinfo; runtime in vm_create. */ typedef struct { - java_objectheader header; + java_object_t header; #if defined(WITH_CLASSPATH_GNU) intptr_t padding[4]; #elif defined(WITH_CLASSPATH_SUN) @@ -147,8 +147,14 @@ struct classinfo { /* class structure */ utf *sourcefile; /* SourceFile attribute */ #if defined(ENABLE_JAVASE) utf *signature; /* Signature attribute */ - s4 runtimevisibleannotationscount; - annotation_t *runtimevisibleannotations; +#if defined(ENABLE_ANNOTATIONS) + annotation_bytearray_t *annotations; + + annotation_bytearrays_t *method_annotations; + annotation_bytearrays_t *method_parameterannotations; + annotation_bytearrays_t *method_annotationdefaults; + + annotation_bytearrays_t *field_annotations; #endif classloader *classloader; /* NULL for bootstrap classloader */ }; @@ -227,6 +233,13 @@ extern classinfo *class_java_lang_ClassNotFoundException; #if defined(ENABLE_JAVASE) extern classinfo *class_java_lang_Void; + +#if defined(ENABLE_ANNOTATIONS) +extern classinfo *class_sun_reflect_ConstantPool; +#if defined(WITH_CLASSPATH_GNU) +extern classinfo *class_sun_reflect_annotation_AnnotationParser; +#endif +#endif #endif extern classinfo *class_java_lang_Boolean; diff --git a/src/vmcore/classcache.c b/src/vmcore/classcache.c index 93107b50b..27013ef2f 100644 --- a/src/vmcore/classcache.c +++ b/src/vmcore/classcache.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: classcache.c 7813 2007-04-25 19:20:13Z twisti $ + $Id: classcache.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -227,7 +227,7 @@ void classcache_print_statistics(FILE *file) { hashtable hashtable_classcache; #if defined(ENABLE_THREADS) -static java_objectheader *lock_hashtable_classcache; +static java_object_t *lock_hashtable_classcache; #endif @@ -262,7 +262,7 @@ bool classcache_init(void) #if defined(ENABLE_THREADS) /* create utf hashtable lock object */ - lock_hashtable_classcache = NEW(java_objectheader); + lock_hashtable_classcache = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(lock_hashtable_classcache); #endif diff --git a/src/vmcore/descriptor.c b/src/vmcore/descriptor.c index 9fce46c62..a9b8a378b 100644 --- a/src/vmcore/descriptor.c +++ b/src/vmcore/descriptor.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: descriptor.c 8233 2007-07-25 15:11:20Z twisti $ + $Id: descriptor.c 8288 2007-08-10 15:12:00Z twisti $ */ @@ -39,10 +39,10 @@ #include "vm/exceptions.h" #include "vm/jit_interface.h" +#include "vm/primitive.h" #include "vm/vm.h" #include "vmcore/descriptor.h" -#include "vmcore/primitive.h" #include "vmcore/options.h" diff --git a/src/vmcore/field.c b/src/vmcore/field.c index c2c337a7a..98e29f2a6 100644 --- a/src/vmcore/field.c +++ b/src/vmcore/field.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: field.c 8227 2007-07-24 11:55:07Z twisti $ + $Id: field.c 8288 2007-08-10 15:12:00Z twisti $ */ @@ -33,18 +33,24 @@ #include #include +#include "mm/memory.h" + #include "vm/types.h" +#include "mm/memory.h" + #include "vm/exceptions.h" +#include "vm/global.h" +#include "vm/primitive.h" #include "vm/stringlocal.h" #include "vm/vm.h" +#include "vmcore/annotation.h" #include "vmcore/class.h" #include "vmcore/descriptor.h" #include "vmcore/field.h" #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/references.h" #include "vmcore/suck.h" #include "vmcore/utf8.h" @@ -63,22 +69,31 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) { classinfo *c; u4 attrnum, i; - u4 jtype; u4 pindex = field_load_NOVALUE; /* constantvalue_index */ utf *u; + /* Get class. */ + c = cb->class; + f->class = c; + + /* Get access flags. */ + if (!suck_check_classbuffer_size(cb, 2 + 2 + 2)) return false; f->flags = suck_u2(cb); + /* Get name. */ + if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) return false; f->name = u; + /* Get descriptor. */ + if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) return false; @@ -133,46 +148,79 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) /* data type */ - jtype = descriptor_to_basic_type(f->descriptor); + f->type = descriptor_to_basic_type(f->descriptor); - f->class = c; - f->type = jtype; - f->offset = 0; /* offset from start of object */ + /* For static-fields allocate memory for the value and set the + value to 0. */ - switch (f->type) { - case TYPE_INT: - f->value.i = 0; - break; + if (f->flags & ACC_STATIC) { + switch (f->type) { + case TYPE_INT: + case TYPE_LNG: + case TYPE_FLT: + case TYPE_DBL: + f->value = NEW(imm_union); + break; - case TYPE_FLT: - f->value.f = 0.0; - break; + case TYPE_ADR: +#if defined(ENABLE_GC_CACAO) + f->value = NEW(imm_union); +#else + f->value = GCNEW_UNCOLLECTABLE(imm_union, 1); +#endif + break; - case TYPE_DBL: - f->value.d = 0.0; - break; + default: + vm_abort("field_load: invalid field type %d", f->type); + } - case TYPE_ADR: - f->value.a = NULL; - if (!(f->flags & ACC_STATIC)) - c->flags |= ACC_CLASS_HAS_POINTERS; - break; + /* Set the field to zero, for float and double fields set the + correct 0.0 value. */ - case TYPE_LNG: -#if U8_AVAILABLE - f->value.l = 0; -#else - f->value.l.low = 0; - f->value.l.high = 0; -#endif - break; + switch (f->type) { + case TYPE_INT: + case TYPE_LNG: + case TYPE_ADR: + f->value->l = 0; + break; + + case TYPE_FLT: + f->value->f = 0.0; + break; + + case TYPE_DBL: + f->value->d = 0.0; + break; + } + } + else { + /* For instance-fields set the offset to 0. */ + + f->offset = 0; + + /* For final fields, which are not static, we need a value + structure. */ + + if (f->flags & ACC_FINAL) { + f->value = NEW(imm_union); + /* XXX hack */ + f->value->l = 0; + } + + switch (f->type) { + case TYPE_ADR: + c->flags |= ACC_CLASS_HAS_POINTERS; + break; + } } /* read attributes */ + if (!suck_check_classbuffer_size(cb, 2)) return false; attrnum = suck_u2(cb); + for (i = 0; i < attrnum; i++) { if (!suck_check_classbuffer_size(cb, 2)) return false; @@ -204,14 +252,14 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) /* initialize field with value from constantpool */ - switch (jtype) { + switch (f->type) { case TYPE_INT: { constant_integer *ci; if (!(ci = class_getconstant(c, pindex, CONSTANT_Integer))) return false; - f->value.i = ci->value; + f->value->i = ci->value; } break; @@ -221,7 +269,7 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) if (!(cl = class_getconstant(c, pindex, CONSTANT_Long))) return false; - f->value.l = cl->value; + f->value->l = cl->value; } break; @@ -231,7 +279,7 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) if (!(cf = class_getconstant(c, pindex, CONSTANT_Float))) return false; - f->value.f = cf->value; + f->value->f = cf->value; } break; @@ -241,7 +289,7 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) if (!(cd = class_getconstant(c, pindex, CONSTANT_Double))) return false; - f->value.d = cd->value; + f->value->d = cd->value; } break; @@ -249,12 +297,13 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) if (!(u = class_getconstant(c, pindex, CONSTANT_String))) return false; - /* create javastring from compressed utf8-string */ - f->value.a = literalstring_new(u); + /* Create Java-string from compressed UTF8-string. */ + + f->value->a = literalstring_new(u); break; default: - vm_abort("field_load: invalid field type %d", jtype); + vm_abort("field_load: invalid field type %d", f->type); } } #if defined(ENABLE_JAVASE) @@ -264,6 +313,19 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) if (!loader_load_attribute_signature(cb, &(f->signature))) return false; } + +#if defined(ENABLE_ANNOTATIONS) + else if (u == utf_RuntimeVisibleAnnotations) { + /* RuntimeVisibleAnnotations */ + if (!annotation_load_field_attribute_runtimevisibleannotations(cb, f)) + return false; + } + else if (u == utf_RuntimeInvisibleAnnotations) { + /* RuntimeInvisibleAnnotations */ + if (!annotation_load_field_attribute_runtimeinvisibleannotations(cb, f)) + return false; + } +#endif #endif else { /* unknown attribute */ @@ -323,6 +385,28 @@ void field_free(fieldinfo *f) } +#if defined(ENABLE_ANNOTATIONS) +/* field_get_annotations ****************************************************** + + Gets a fields' annotations (or NULL if none). + +*******************************************************************************/ + +annotation_bytearray_t *field_get_annotations(fieldinfo *f) +{ + classinfo *c = f->class; + int slot = f - c->fields; + + if (c->field_annotations != NULL && + c->field_annotations->size > slot) { + return c->field_annotations->data[slot]; + } + + return NULL; +} +#endif + + /* field_printflags ************************************************************ (debugging only) diff --git a/src/vmcore/field.h b/src/vmcore/field.h index d995261ae..dce84cefe 100644 --- a/src/vmcore/field.h +++ b/src/vmcore/field.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: field.h 8229 2007-07-24 18:42:44Z twisti $ + $Id: field.h 8268 2007-08-07 13:24:43Z twisti $ */ @@ -65,9 +65,8 @@ struct fieldinfo { /* field of a class */ utf *signature; /* Signature attribute string */ typedesc *parseddesc;/* parsed descriptor */ - s4 offset; /* offset from start of object (instance variables) */ - - imm_union value; /* storage for static values (class variables) */ + int32_t offset; /* offset from start of object (instance variables) */ + imm_union *value; /* storage for static values (class variables) */ }; @@ -77,6 +76,10 @@ bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool); classinfo *field_get_type(fieldinfo *f); void field_free(fieldinfo *f); +#if defined(ENABLE_ANNOTATIONS) +annotation_bytearray_t *field_get_annotations(fieldinfo *f); +#endif + #if !defined(NDEBUG) void field_printflags(fieldinfo *f); void field_print(fieldinfo *f); diff --git a/src/vmcore/linker.c b/src/vmcore/linker.c index 7df0f32d4..2d9d9bd3e 100644 --- a/src/vmcore/linker.c +++ b/src/vmcore/linker.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: linker.c 8245 2007-07-31 09:55:04Z michi $ + $Id: linker.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -43,6 +43,7 @@ #include "vm/access.h" #include "vm/exceptions.h" +#include "vm/primitive.h" #include "vm/stringlocal.h" #include "vm/vm.h" @@ -52,7 +53,6 @@ #include "vmcore/classcache.h" #include "vmcore/loader.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/rt-timing.h" /* #include "vm/resolve.h" */ @@ -75,7 +75,7 @@ classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool c static s4 interfaceindex; /* sequential numbering of interfaces */ static s4 classvalue; -java_objectheader *linker_classrenumber_lock; +java_object_t *linker_classrenumber_lock; /* private functions **********************************************************/ @@ -115,7 +115,7 @@ bool linker_init(void) /* Check for if alignment for long and double matches what we assume for the current architecture. */ -#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) +#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) if (OFFSET(dummy_alignment_long_t, l) != 4) vm_abort("linker_init: long alignment is different from what assumed: %d != %d", OFFSET(dummy_alignment_long_t, l), 4); @@ -140,7 +140,7 @@ bool linker_init(void) #if defined(ENABLE_THREADS) /* create the global lock object */ - linker_classrenumber_lock = NEW(java_objectheader); + linker_classrenumber_lock = NEW(java_object_t); LOCK_INIT_OBJECT_LOCK(linker_classrenumber_lock); #endif @@ -574,7 +574,7 @@ static classinfo *link_class_intern(classinfo *c) if (c->super.any == NULL) { /* class java.lang.Object */ c->index = 0; - c->instancesize = sizeof(java_objectheader); + c->instancesize = sizeof(java_object_t); vftbllength = supervftbllength = 0; @@ -882,7 +882,7 @@ static classinfo *link_class_intern(classinfo *c) if (!(f->flags & ACC_STATIC)) { dsize = descriptor_typesize(f->parseddesc); -#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) +#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) /* On i386 and ARM we align double and s8 fields to 4-bytes. This matches what GCC does for struct members. We must do the same as gcc here because the @@ -1137,6 +1137,12 @@ static arraydescriptor *link_array(classinfo *c) XXX + ATTENTION: DO NOT REMOVE ANY OF THE LOCKING MECHANISMS BELOW: + This function needs to take the class renumber lock and stop the + world during class renumbering. The lock is used in C code which + is not that performance critical. Whereas JIT code uses critical + sections to atomically access the class values. + *******************************************************************************/ static void linker_compute_subclasses(classinfo *c) diff --git a/src/vmcore/linker.h b/src/vmcore/linker.h index 44ba317be..864851366 100644 --- a/src/vmcore/linker.h +++ b/src/vmcore/linker.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: linker.h 8123 2007-06-20 23:50:55Z michi $ + $Id: linker.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -139,7 +139,7 @@ struct arraydescriptor { /* This lock must be taken while renumbering classes or while atomically */ /* accessing classes. */ -extern java_objectheader *linker_classrenumber_lock; +extern java_object_t *linker_classrenumber_lock; /* function prototypes ********************************************************/ diff --git a/src/vmcore/loader.c b/src/vmcore/loader.c index 721d578c8..e0618c786 100644 --- a/src/vmcore/loader.c +++ b/src/vmcore/loader.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: loader.c 8245 2007-07-31 09:55:04Z michi $ + $Id: loader.c 8299 2007-08-13 08:41:18Z michi $ */ @@ -45,6 +45,7 @@ #include "vm/builtin.h" #include "vm/exceptions.h" #include "vm/global.h" +#include "vm/primitive.h" #include "vm/stringlocal.h" #include "vm/vm.h" @@ -61,7 +62,6 @@ #include "vmcore/loader.h" #include "vmcore/method.h" #include "vmcore/options.h" -#include "vmcore/primitive.h" #include "vmcore/rt-timing.h" #if defined(ENABLE_STATISTICS) @@ -237,7 +237,22 @@ bool loader_init(void) if (!(arrayclass_java_lang_Object = load_class_bootstrap(utf_new_char("[Ljava/lang/Object;")))) return false; + +#if defined(ENABLE_ANNOTATIONS) + /* needed by annotation support */ + if (!(class_sun_reflect_ConstantPool = + load_class_bootstrap(utf_sun_reflect_ConstantPool))) + return false; + +#if defined(WITH_CLASSPATH_GNU) + /* needed by GNU Classpaths annotation support */ + if (!(class_sun_reflect_annotation_AnnotationParser = + load_class_bootstrap(utf_sun_reflect_annotation_AnnotationParser))) + return false; +#endif #endif +#endif + return true; } @@ -953,10 +968,10 @@ bool loader_load_attribute_signature(classbuffer *cb, utf **signature) classinfo *load_class_from_sysloader(utf *name) { - methodinfo *m; - java_objectheader *clo; - classloader *cl; - classinfo *c; + methodinfo *m; + java_handle_t *clo; + classloader *cl; + classinfo *c; assert(class_java_lang_Object); assert(class_java_lang_ClassLoader); @@ -1000,10 +1015,10 @@ classinfo *load_class_from_sysloader(utf *name) classinfo *load_class_from_classloader(utf *name, classloader *cl) { - java_objectheader *o; - classinfo *c; - classinfo *tmpc; - java_objectheader *string; + java_handle_t *o; + classinfo *c; + classinfo *tmpc; + java_handle_t *string; #if defined(ENABLE_RT_TIMING) struct timespec time_start, time_lookup, time_prepare, time_java, time_cache; @@ -1532,16 +1547,14 @@ classinfo *load_class_from_classbuffer(classbuffer *cb) RT_TIMING_GET_TIME(time_setup); /* load fields */ + if (!suck_check_classbuffer_size(cb, 2)) goto return_exception; c->fieldscount = suck_u2(cb); -#if defined(ENABLE_GC_CACAO) - c->fields = MNEW(fieldinfo, c->fieldscount); + c->fields = MNEW(fieldinfo, c->fieldscount); + MZERO(c->fields, fieldinfo, c->fieldscount); -#else - c->fields = GCNEW_UNCOLLECTABLE(fieldinfo, c->fieldscount); -#endif for (i = 0; i < c->fieldscount; i++) { if (!field_load(cb, &(c->fields[i]), descpool)) @@ -1551,11 +1564,12 @@ classinfo *load_class_from_classbuffer(classbuffer *cb) RT_TIMING_GET_TIME(time_fields); /* load methods */ + if (!suck_check_classbuffer_size(cb, 2)) goto return_exception; c->methodscount = suck_u2(cb); - c->methods = MNEW(methodinfo, c->methodscount); + c->methods = MNEW(methodinfo, c->methodscount); MZERO(c->methods, methodinfo, c->methodscount); diff --git a/src/vmcore/method.c b/src/vmcore/method.c index 7e81098d5..87715ad96 100644 --- a/src/vmcore/method.c +++ b/src/vmcore/method.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: method.c 8228 2007-07-24 12:37:25Z twisti $ + $Id: method.c 8295 2007-08-11 17:57:24Z michi $ */ @@ -435,6 +435,34 @@ bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool) if (!loader_load_attribute_signature(cb, &(m->signature))) return false; } + +#if defined(ENABLE_ANNOTATIONS) + else if (attribute_name == utf_RuntimeVisibleAnnotations) { + /* RuntimeVisibleAnnotations */ + if (!annotation_load_method_attribute_runtimevisibleannotations(cb, m)) + return false; + } + else if (attribute_name == utf_RuntimeInvisibleAnnotations) { + /* RuntimeInvisibleAnnotations */ + if (!annotation_load_method_attribute_runtimeinvisibleannotations(cb, m)) + return false; + } + else if (attribute_name == utf_RuntimeVisibleParameterAnnotations) { + /* RuntimeVisibleParameterAnnotations */ + if (!annotation_load_method_attribute_runtimevisibleparameterannotations(cb, m)) + return false; + } + else if (attribute_name == utf_RuntimeInvisibleParameterAnnotations) { + /* RuntimeInvisibleParameterAnnotations */ + if (!annotation_load_method_attribute_runtimeinvisibleparameterannotations(cb, m)) + return false; + } + else if (attribute_name == utf_AnnotationDefault) { + /* AnnotationDefault */ + if (!annotation_load_method_attribute_annotationdefault(cb, m)) + return false; + } +#endif #endif else { /* unknown attribute */ @@ -551,6 +579,42 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m) } +/* method_get_parametercount ************************************************** + + Use the descriptor of a method to determine the number of parameters + of the method. The this pointer of non-static methods is not counted. + + Returns -1 on error. + +*******************************************************************************/ + +int32_t method_get_parametercount(methodinfo *m) +{ + methoddesc *md; + int32_t paramcount = 0; + + md = m->parseddesc; + + /* is the descriptor fully parsed? */ + + if (m->parseddesc->params == NULL) { + if (!descriptor_params_from_paramtypes(md, m->flags)) { + return -1; + } + } + + paramcount = md->paramcount; + + /* skip `this' pointer */ + + if (!(m->flags & ACC_STATIC)) { + --paramcount; + } + + return paramcount; +} + + /* method_get_parametertypearray *********************************************** Use the descriptor of a method to generate a java.lang.Class array @@ -564,9 +628,9 @@ java_objectarray *method_get_parametertypearray(methodinfo *m) { methoddesc *md; typedesc *paramtypes; - s4 paramcount; - java_objectarray *oa; - s4 i; + int32_t paramcount; + java_objectarray *oa; + int32_t i; classinfo *c; md = m->parseddesc; @@ -600,7 +664,7 @@ java_objectarray *method_get_parametertypearray(methodinfo *m) if (!resolve_class_from_typedesc(¶mtypes[i], true, false, &c)) return NULL; - oa->data[i] = (java_objectheader *) c; + oa->data[i] = c; } return oa; @@ -634,7 +698,7 @@ java_objectarray *method_get_exceptionarray(methodinfo *m) if (c == NULL) return NULL; - oa->data[i] = (java_objectheader *) c; + oa->data[i] = c; } return oa; @@ -710,6 +774,67 @@ s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found) } +#if defined(ENABLE_ANNOTATIONS) +/* method_get_annotations ****************************************************** + + Gets a methods' annotations (or NULL if none). + +*******************************************************************************/ + +annotation_bytearray_t *method_get_annotations(methodinfo *m) +{ + classinfo *c = m->class; + int slot = m - c->methods; + + if (c->method_annotations != NULL && c->method_annotations->size > slot) { + return c->method_annotations->data[slot]; + } + + return NULL; +} + + +/* method_get_parameterannotations ******************************************** + + Gets a methods' parameter annotations (or NULL if none). + +*******************************************************************************/ + +annotation_bytearray_t *method_get_parameterannotations(methodinfo *m) +{ + classinfo *c = m->class; + int slot = m - c->methods; + + if (c->method_parameterannotations != NULL && + c->method_parameterannotations->size > slot) { + return c->method_parameterannotations->data[slot]; + } + + return NULL; +} + + +/* method_get_annotationdefault *********************************************** + + Gets a methods' annotation default value (or NULL if none). + +*******************************************************************************/ + +annotation_bytearray_t *method_get_annotationdefault(methodinfo *m) +{ + classinfo *c = m->class; + int slot = m - c->methods; + + if (c->method_annotationdefaults != NULL && + c->method_annotationdefaults->size > slot) { + return c->method_annotationdefaults->data[slot]; + } + + return NULL; +} +#endif + + /* method_add_to_worklist ****************************************************** Add the method to the given worklist. If the method already occurs in diff --git a/src/vmcore/method.h b/src/vmcore/method.h index 282db25bf..af9930d54 100644 --- a/src/vmcore/method.h +++ b/src/vmcore/method.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: method.h 8231 2007-07-25 14:21:24Z twisti $ + $Id: method.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -64,7 +64,7 @@ typedef struct codeinfo codeinfo; /* methodinfo *****************************************************************/ struct methodinfo { /* method structure */ - java_objectheader header; /* we need this in jit's monitorenter */ + java_object_t header; /* we need this in jit's monitorenter */ s4 flags; /* ACC flags */ utf *name; /* name of method */ utf *descriptor; /* JavaVM descriptor string of method */ @@ -164,6 +164,7 @@ bool method_canoverwrite(methodinfo *m, methodinfo *old); methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m); +int32_t method_get_parametercount(methodinfo *m); java_objectarray *method_get_parametertypearray(methodinfo *m); java_objectarray *method_get_exceptionarray(methodinfo *m); classinfo *method_returntype_get(methodinfo *m); @@ -173,6 +174,12 @@ void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl); s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found); +#if defined(ENABLE_ANNOTATIONS) +annotation_bytearray_t *method_get_annotations(methodinfo *m); +annotation_bytearray_t *method_get_parameterannotations(methodinfo *m); +annotation_bytearray_t *method_get_annotationdefault(methodinfo *m); +#endif + #if !defined(NDEBUG) void method_printflags(methodinfo *m); void method_print(methodinfo *m); diff --git a/src/vmcore/primitive.c b/src/vmcore/primitive.c deleted file mode 100644 index 8d39343b3..000000000 --- a/src/vmcore/primitive.c +++ /dev/null @@ -1,282 +0,0 @@ -/* src/vmcore/primitive.c - primitive types - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - $Id: linker.c 8042 2007-06-07 17:43:29Z twisti $ - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/primitive.h" -#include "vmcore/utf8.h" - - -/* primitivetype_table ********************************************************* - - Structure for primitive classes: contains the class for wrapping - the primitive type, the primitive class, the name of the class for - wrapping, the one character type signature and the name of the - primitive class. - - CAUTION: Don't change the order of the types. This table is indexed - by the ARRAYTYPE_ constants (except ARRAYTYPE_OBJECT). - -*******************************************************************************/ - -primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = { - { "int" , NULL, NULL, NULL, "java/lang/Integer", 'I', "[I", NULL }, - { "long" , NULL, NULL, NULL, "java/lang/Long", 'J', "[J", NULL }, - { "float" , NULL, NULL, NULL, "java/lang/Float", 'F', "[F", NULL }, - { "double" , NULL, NULL, NULL, "java/lang/Double", 'D', "[D", NULL }, - { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, - { "byte" , NULL, NULL, NULL, "java/lang/Byte", 'B', "[B", NULL }, - { "char" , NULL, NULL, NULL, "java/lang/Character", 'C', "[C", NULL }, - { "short" , NULL, NULL, NULL, "java/lang/Short", 'S', "[S", NULL }, - { "boolean" , NULL, NULL, NULL, "java/lang/Boolean", 'Z', "[Z", NULL }, - { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, -#if defined(ENABLE_JAVASE) - { "void" , NULL, NULL, NULL, "java/lang/Void", 'V', NULL, NULL } -#else - { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, -#endif -}; - - -/* primitive_init ************************************************************** - - Create classes representing primitive types. - -*******************************************************************************/ - -bool primitive_init(void) -{ - utf *name; - classinfo *c; - utf *u; - int i; - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) { - /* skip dummies */ - - if (primitivetype_table[i].cname == NULL) - continue; - - /* create UTF-8 name */ - - name = utf_new_char(primitivetype_table[i].cname); - - primitivetype_table[i].name = name; - - /* create primitive class */ - - c = class_create_classinfo(name); - - /* primitive classes don't have a super class */ - - c->super.any = NULL; - - /* set flags and mark it as primitive class */ - - c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT | ACC_CLASS_PRIMITIVE; - - /* prevent loader from loading primitive class */ - - c->state |= CLASS_LOADED; - - /* INFO: don't put primitive classes into the classcache */ - - if (!link_class(c)) - return false; - - primitivetype_table[i].class_primitive = c; - - /* create class for wrapping the primitive type */ - - u = utf_new_char(primitivetype_table[i].wrapname); - c = load_class_bootstrap(u); - - if (c == NULL) - return false; - - primitivetype_table[i].class_wrap = c; - - /* create the primitive array class */ - - if (primitivetype_table[i].arrayname) { - u = utf_new_char(primitivetype_table[i].arrayname); - c = class_create_classinfo(u); - c = load_newly_created_array(c, NULL); - - if (c == NULL) - return false; - - primitivetype_table[i].arrayclass = c; - - assert(c->state & CLASS_LOADED); - - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - return false; - } - } - - return true; -} - - -/* primitive_class_get_by_name ************************************************* - - Returns the primitive class of the given class name. - -*******************************************************************************/ - -classinfo *primitive_class_get_by_name(utf *name) -{ - int i; - - /* search table of primitive classes */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) - if (primitivetype_table[i].name == name) - return primitivetype_table[i].class_primitive; - - /* keep compiler happy */ - - return NULL; -} - - -/* primitive_class_get_by_type ************************************************* - - Returns the primitive class of the given type. - -*******************************************************************************/ - -classinfo *primitive_class_get_by_type(int32_t type) -{ - return primitivetype_table[type].class_primitive; -} - - -/* primitive_class_get_by_char ************************************************* - - Returns the primitive class of the given type. - -*******************************************************************************/ - -classinfo *primitive_class_get_by_char(char ch) -{ - int32_t index; - - switch (ch) { - case 'I': - index = PRIMITIVETYPE_INT; - break; - case 'J': - index = PRIMITIVETYPE_LONG; - break; - case 'F': - index = PRIMITIVETYPE_FLOAT; - break; - case 'D': - index = PRIMITIVETYPE_DOUBLE; - break; - case 'B': - index = PRIMITIVETYPE_BYTE; - break; - case 'C': - index = PRIMITIVETYPE_CHAR; - break; - case 'S': - index = PRIMITIVETYPE_SHORT; - break; - case 'Z': - index = PRIMITIVETYPE_BOOLEAN; - break; - case 'V': - index = PRIMITIVETYPE_VOID; - break; - default: - return NULL; - } - - return primitivetype_table[index].class_primitive; -} - - -/* primitive_arrayclass_get_by_name ******************************************** - - Returns the primitive array-class of the given primitive class - name. - -*******************************************************************************/ - -classinfo *primitive_arrayclass_get_by_name(utf *name) -{ - int i; - - /* search table of primitive classes */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) - if (primitivetype_table[i].name == name) - return primitivetype_table[i].arrayclass; - - /* keep compiler happy */ - - return NULL; -} - - -/* primitive_arrayclass_get_by_type ******************************************** - - Returns the primitive array-class of the given type. - -*******************************************************************************/ - -classinfo *primitive_arrayclass_get_by_type(int32_t type) -{ - return primitivetype_table[type].arrayclass; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/primitive.h b/src/vmcore/primitive.h deleted file mode 100644 index f9feb5103..000000000 --- a/src/vmcore/primitive.h +++ /dev/null @@ -1,129 +0,0 @@ -/* src/vmcore/primitive.c - primitive types - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - $Id: linker.c 8042 2007-06-07 17:43:29Z twisti $ - -*/ - - -#ifndef _PRIMITIVE_H -#define _PRIMITIVE_H - -#include "config.h" - -#include - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/linker.h" -#include "vmcore/utf8.h" - - -/* primitive data types *******************************************************/ - -/* These values are used in parsed descriptors and in some other - places were the different types handled internally as TYPE_INT have - to be distinguished. */ - -#define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */ - -/* CAUTION: Don't change the numerical values! These constants are - used as indices into the primitive type table. */ - -#define PRIMITIVETYPE_INT TYPE_INT -#define PRIMITIVETYPE_LONG TYPE_LNG -#define PRIMITIVETYPE_FLOAT TYPE_FLT -#define PRIMITIVETYPE_DOUBLE TYPE_DBL -#define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */ -#define PRIMITIVETYPE_BYTE 5 -#define PRIMITIVETYPE_CHAR 6 -#define PRIMITIVETYPE_SHORT 7 -#define PRIMITIVETYPE_BOOLEAN 8 -#define PRIMITIVETYPE_DUMMY2 9 /* not used! */ -#define PRIMITIVETYPE_VOID TYPE_VOID - - -/* CAUTION: Don't change the numerical values! These constants (with - the exception of ARRAYTYPE_OBJECT) are used as indices in the - primitive type table. */ - -#define ARRAYTYPE_INT PRIMITIVETYPE_INT -#define ARRAYTYPE_LONG PRIMITIVETYPE_LONG -#define ARRAYTYPE_FLOAT PRIMITIVETYPE_FLOAT -#define ARRAYTYPE_DOUBLE PRIMITIVETYPE_DOUBLE -#define ARRAYTYPE_BYTE PRIMITIVETYPE_BYTE -#define ARRAYTYPE_CHAR PRIMITIVETYPE_CHAR -#define ARRAYTYPE_SHORT PRIMITIVETYPE_SHORT -#define ARRAYTYPE_BOOLEAN PRIMITIVETYPE_BOOLEAN -#define ARRAYTYPE_OBJECT PRIMITIVETYPE_VOID /* don't use as index! */ - - -/* primitivetypeinfo **********************************************************/ - -struct primitivetypeinfo { - char *cname; /* char name of primitive class */ - utf *name; /* name of primitive class */ - classinfo *class_wrap; /* class for wrapping primitive type */ - classinfo *class_primitive; /* primitive class */ - char *wrapname; /* name of class for wrapping */ - char typesig; /* one character type signature */ - char *arrayname; /* name of primitive array class */ - classinfo *arrayclass; /* primitive array class */ -}; - - -/* global variables ***********************************************************/ - -/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_ - constants (except ARRAYTYPE_OBJECT). */ - -extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT]; - - -/* function prototypes ********************************************************/ - -bool primitive_init(void); -classinfo *primitive_class_get_by_name(utf *name); -classinfo *primitive_class_get_by_type(int32_t type); -classinfo *primitive_class_get_by_char(char ch); -classinfo *primitive_arrayclass_get_by_name(utf *name); -classinfo *primitive_arrayclass_get_by_type(int32_t type); - -#endif /* _PRIMITIVE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/suck.h b/src/vmcore/suck.h index 1913e5f7f..63543f411 100644 --- a/src/vmcore/suck.h +++ b/src/vmcore/suck.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: suck.h 7783 2007-04-20 13:28:27Z twisti $ + $Id: suck.h 8295 2007-08-11 17:57:24Z michi $ */ @@ -53,7 +53,7 @@ typedef struct list_classpath_entry list_classpath_entry; struct list_classpath_entry { #if defined(ENABLE_THREADS) - java_objectheader header; /* monitor locking on zip/jar files */ + java_object_t header; /* monitor locking on zip/jar files */ #endif s4 type; char *path; diff --git a/src/vmcore/utf8.c b/src/vmcore/utf8.c index d9893ef00..2dccde9cd 100644 --- a/src/vmcore/utf8.c +++ b/src/vmcore/utf8.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: utf8.c 8132 2007-06-22 11:15:47Z twisti $ + $Id: utf8.c 8249 2007-07-31 12:59:03Z panzi $ */ @@ -152,8 +152,20 @@ utf *utf_SourceFile; /* SourceFile */ #if defined(ENABLE_JAVASE) utf *utf_EnclosingMethod; utf *utf_Signature; -utf *utf_RuntimeVisibleAnnotations; utf *utf_StackMapTable; + +#if defined(ENABLE_ANNOTATIONS) +utf *utf_sun_reflect_ConstantPool; +#if defined(WITH_CLASSPATH_GNU) +utf *utf_sun_reflect_annotation_AnnotationParser; +#endif + +utf *utf_RuntimeVisibleAnnotations; +utf *utf_RuntimeInvisibleAnnotations; +utf *utf_RuntimeVisibleParameterAnnotations; +utf *utf_RuntimeInvisibleParameterAnnotations; +utf *utf_AnnotationDefault; +#endif #endif utf *utf_init; /* */ @@ -393,8 +405,20 @@ bool utf8_init(void) #if defined(ENABLE_JAVASE) utf_EnclosingMethod = utf_new_char("EnclosingMethod"); utf_Signature = utf_new_char("Signature"); - utf_RuntimeVisibleAnnotations = utf_new_char("RuntimeVisibleAnnotations"); utf_StackMapTable = utf_new_char("StackMapTable"); + +#if defined(ENABLE_ANNOTATIONS) + utf_sun_reflect_ConstantPool = utf_new_char("sun/reflect/ConstantPool"); +#if defined(WITH_CLASSPATH_GNU) + utf_sun_reflect_annotation_AnnotationParser = utf_new_char("sun/reflect/annotation/AnnotationParser"); +#endif + + utf_RuntimeVisibleAnnotations = utf_new_char("RuntimeVisibleAnnotations"); + utf_RuntimeInvisibleAnnotations = utf_new_char("RuntimeInvisibleAnnotations"); + utf_RuntimeVisibleParameterAnnotations = utf_new_char("RuntimeVisibleParameterAnnotations"); + utf_RuntimeInvisibleParameterAnnotations = utf_new_char("RuntimeInvisibleParameterAnnotations"); + utf_AnnotationDefault = utf_new_char("AnnotationDefault"); +#endif #endif utf_init = utf_new_char(""); diff --git a/src/vmcore/utf8.h b/src/vmcore/utf8.h index b6a6992ab..7502ecf67 100644 --- a/src/vmcore/utf8.h +++ b/src/vmcore/utf8.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: utf8.h 8132 2007-06-22 11:15:47Z twisti $ + $Id: utf8.h 8249 2007-07-31 12:59:03Z panzi $ */ @@ -148,8 +148,25 @@ extern utf *utf_SourceFile; #if defined(ENABLE_JAVASE) extern utf *utf_EnclosingMethod; extern utf *utf_Signature; -extern utf *utf_RuntimeVisibleAnnotations; extern utf *utf_StackMapTable; + +#if defined(ENABLE_ANNOTATIONS) +/* OpenJDKs sun.reflect.ConstantPool class is for now only + * used by annotations but will probably be used for other + * things in the future. For now I just couple it with + * annotation support. + */ +extern utf *utf_sun_reflect_ConstantPool; +#if defined(WITH_CLASSPATH_GNU) +extern utf *utf_sun_reflect_annotation_AnnotationParser; +#endif + +extern utf *utf_RuntimeVisibleAnnotations; +extern utf *utf_RuntimeInvisibleAnnotations; +extern utf *utf_RuntimeVisibleParameterAnnotations; +extern utf *utf_RuntimeInvisibleParameterAnnotations; +extern utf *utf_AnnotationDefault; +#endif #endif extern utf *utf_init; diff --git a/tests/rtIn/at/dms/kjc/Main b/tests/rtIn/at/dms/kjc/Main deleted file mode 100644 index 94d4ea715..000000000 --- a/tests/rtIn/at/dms/kjc/Main +++ /dev/null @@ -1,8 +0,0 @@ -gnu/java/net/protocol/file/Connection getInputStream ()Ljava/io/InputStream; -java/lang/VMThrowable ()V -gnu/java/net/protocol/file/Handler ()V -gnu/java/locale/Calendar ()V -gnu/java/locale/Calendar_en ()V -gnu/java/locale/LocaleInformation ()V -gnu/java/locale/LocaleInformation_en_US ()V -gnu/java/lang/SystemClassLoader ()V diff --git a/tests/rtMissedIn0 b/tests/rtMissedIn0 deleted file mode 100644 index 99deaa4c3..000000000 --- a/tests/rtMissedIn0 +++ /dev/null @@ -1,10 +0,0 @@ -java/lang/VMThrowable ()V -gnu/java/nio/channels/FileChannelImpl (II)V -java/lang/reflect/Constructor ()V -gnu/java/io/decode/Decoder8859_1 (Ljava/io/InputStream;)V -gnu/java/io/encode/Encoder8859_1 (Ljava/io/OutputStream;)V -gnu/java/net/protocol/file/Handler ()V -gnu/java/net/protocol/jar/Handler ()V -gnu/java/net/protocol/jar/Connection (Ljava/net/URL;)V -gnu/java/locale/Calendar ()V -gnu/java/locale/Calendar_en ()V -- 2.25.1