+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.
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.
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],
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],
[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]
[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
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
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
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>,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>,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)
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=<dir>,installation directory of Java core library native libraries [[default=/usr/local/classpath/lib]])],
+ [AS_HELP_STRING(--with-classpath-libdir=<dir>,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})
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 $
*/
#include "toolbox/logging.h"
#include "vm/global.h"
+#include "vm/primitive.h"
#include "vm/vm.h"
#include "vmcore/class.h"
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");
/* builtin ********************************************************************/
-java_objectheader *builtin_clone(void *env, java_objectheader *o)
+java_handle_t *builtin_clone(void *env, java_handle_t *o)
{
abort();
return 0;
}
-java_objectheader *builtin_new(classinfo *c)
+java_handle_t *builtin_new(classinfo *c)
{
abort();
/* 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;
}
}
+/* 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)
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;
}
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!");
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 $
*/
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, "*");
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;
}
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 $
*/
/* 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;
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);
## 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
$(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 \
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
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 \
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 $
*/
#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 *****************************************************************
#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
## 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
if ENABLE_JNI
JNI_SOURCES = \
jni.c \
- jni.h
+ jni.h \
+ localref.c \
+ localref.h
endif
libnative_la_SOURCES = \
## 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
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
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 $
*/
#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)
#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/initialize.h"
+#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
#include "vmcore/statistics.h"
#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 **************************************************/
}
-/* 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.
*******************************************************************************/
-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());
*******************************************************************************/
-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());
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-#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();
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();
return ro;
}
-#endif
/* GetVersion ******************************************************************
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);
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);
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());
jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env)
{
- java_objectheader *o;
+ java_handle_t *o;
STATISTICS(jniinvokation());
void _Jv_JNI_ExceptionDescribe(JNIEnv *env)
{
- java_objectheader *o;
- methodinfo *m;
+ java_handle_t *o;
+ methodinfo *m;
STATISTICS(jniinvokation());
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;
}
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 */
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) */
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;
jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
{
- classinfo *c;
- java_objectheader *o;
+ classinfo *c;
+ java_handle_t *o;
STATISTICS(jniinvokation());
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());
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());
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());
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;
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;
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;
java_lang_reflect_Field *rf;
classinfo *c;
fieldinfo *f;
+ int32_t slot;
STATISTICS(jniinvokation());
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
/* 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);
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);
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);
}
-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
+ Get<type>Field and Set<type>Field 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;
}
+/* Get<type>Field 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!");
+/* Set<type>Field 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 GetStatic<type>Field and
+ SetStatic<type>Field 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
- Get<type>Field and Set<type>Field families of accessor functions
- use field IDs to retrieve object fields.
-
-*******************************************************************************/
-
-jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
- const char *sig)
-{
- classinfo *c;
- fieldinfo *f;
- utf *uname;
- utf *udesc;
-
- STATISTICS(jniinvokation());
-
- c = (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;
-}
-
-
-/* Get<type>Field Routines *****************************************************
-
- This family of accessor routines returns the value of an instance
- (nonstatic) field of an object. The field to access is specified by
- a field ID obtained by calling GetFieldID().
-
-*******************************************************************************/
-
-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;
-}
-
-
-/* Set<type>Field Routines *****************************************************
-
- This family of accessor routines sets the value of an instance
- (nonstatic) field of an object. The field to access is specified by
- a field ID obtained by calling GetFieldID().
-
-*******************************************************************************/
-
-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 GetStatic<type>Field and
- SetStatic<type>Field families of accessor functions use field IDs
- to retrieve static fields.
-
-*******************************************************************************/
-
-jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
- const char *sig)
-{
- classinfo *c;
- fieldinfo *f;
- utf *uname;
- utf *usig;
-
- STATISTICS(jniinvokation());
-
- c = (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;
-}
-
-
-/* GetStatic<type>Field ********************************************************
-
- 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;
-}
-
-
-/* SetStatic<type>Field *******************************************************
-
- 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());
+/* GetStatic<type>Field ********************************************************
- 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());
+/* SetStatic<type>Field *******************************************************
- 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};
-/* Get<PrimitiveType>ArrayElements *********************************************
+/* 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;
-}
-
-
-/* Release<PrimitiveType>ArrayElements *****************************************
-
- A family of functions that informs the VM that the native code no
- longer needs access to elems. The elems argument is a pointer
- derived from array using the corresponding
- Get<PrimitiveType>ArrayElements() function. If necessary, this
- function copies back all changes made to elems to the original
- array.
-
-*******************************************************************************/
+ 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);
}
-/* Get<PrimitiveType>ArrayRegion **********************************************
+/* 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;
}
-/* Set<PrimitiveType>ArrayRegion **********************************************
+/* 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());
+/* Get<PrimitiveType>ArrayElements *********************************************
- 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());
+/* Release<PrimitiveType>ArrayElements *****************************************
- 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
+ Get<PrimitiveType>ArrayElements() 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());
+/* Get<PrimitiveType>ArrayRegion **********************************************
+
+ 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)
+
+
+/* Set<PrimitiveType>ArrayRegion **********************************************
+
+ A family of functions that copies back a region of a primitive
+ array from a buffer.
+
+*******************************************************************************/
+
+#define JNI_SET_ARRAY_REGION(name, type, intern, intern2) \
+void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array, \
+ jsize start, jsize len, const type *buf) \
+{ \
+ java_##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 *************************************************/
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;
}
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';
}
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);
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);
jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env)
{
- java_objectheader *o;
+ java_handle_t *o;
STATISTICS(jniinvokation());
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;
/* 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 */
#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());
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");
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");
if (!threads_attach_current_thread(vm_aargs, false))
return JNI_ERR;
- if (!jni_init_localref_table())
+ if (!localref_table_init())
return JNI_ERR;
}
#endif
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 $
*/
#ifndef _JNI_H
#define _JNI_H
-/* forward typedefs ***********************************************************/
-
-typedef struct localref_table localref_table;
-
#include "vm/types.h"
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 */
};
/* 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 */
--- /dev/null
+/* 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 <assert.h>
+#include <stdint.h>
+
+#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:
+ */
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 $
*/
*******************************************************************************/
#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;
#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;
functionptr native_resolve_function(methodinfo *m)
{
- java_objectheader *cl;
+ classloader *cl;
utf *name;
utf *newname;
functionptr f;
#endif
#if defined(WITH_CLASSPATH_SUN)
methodinfo *method_findNative;
- java_objectheader *s;
+ java_handle_t *s;
#endif
cl = m->class->classloader;
*******************************************************************************/
-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");
}
-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");
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 $
*/
# 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 */
/* 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);
}
}
*/
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;
*/
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;
*/
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;
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 */
*/
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);
##
## 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
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 \
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 = \
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 $
*/
*/
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();
*/
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();
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 $
*/
*/
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();
*/
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();
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;
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 $
*/
{ "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 },
}
-#if 0
+#if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
/*
* Class: java/lang/VMClass
* Method: getDeclaredAnnotations
*/
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
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 $
*/
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/initialize.h"
+#include "vm/primitive.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
#include "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"
/* 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 */
*/
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 */
/* 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;
/* 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 */
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 $
*/
*/
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);
*/
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 */
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 $
*/
#include <stdint.h>
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_ThreadGroup.h"
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
*/
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);
}
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 $
*/
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/gnu_classpath_Pointer.h"
if (stc == NULL)
return NULL;
- o->vmData = (gnu_classpath_Pointer *) stc;
+ LLNI_field_set_ref(o, vmData, (gnu_classpath_Pointer *) stc);
return o;
}
/* 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);
/* 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;
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 $
*/
#include <assert.h>
#include <stdlib.h>
+#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"
#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"
/* 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
};
{
/* 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
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 $
*/
#include <stdint.h>
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_Boolean.h"
#include "native/include/java_lang_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"
{ "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
};
{
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)
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 */
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 */
{
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;
}
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;
* 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;
}
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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
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();
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();
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();
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();
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();
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();
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();
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();
/* 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;
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
*/
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;
}
+#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
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 $
*/
#include <assert.h>
+#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"
/* 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
};
{
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;
}
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);
{
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);
}
{
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);
}
{
/* 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);
}
*/
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;
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.
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
/* keep this order of the native includes */
#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
{
classinfo *c;
java_lang_String *s;
+ java_chararray *ca;
u4 i;
c = (classinfo *) 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;
#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);
/* 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;
*/
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))
for (i = 0; i < c->interfacescount; i++) {
ic = c->interfaces[i].cls;
- oa->data[i] = (java_objectheader *) ic;
+ oa->data[i] = ic;
}
return oa;
if (!link_class(inner))
return NULL;
- oa->data[pos++] = (java_objectheader *) inner;
+ oa->data[pos++] = inner;
}
}
/* store object into array */
- oa->data[pos++] = (java_objectheader *) rf;
+ oa->data[pos++] = rf;
}
}
/* store object into array */
- oa->data[pos++] = (java_objectheader *) rm;
+ oa->data[pos++] = rm;
}
}
/* store object into array */
- oa->data[pos++] = (java_objectheader *) rc;
+ oa->data[pos++] = rc;
}
}
*/
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
*/
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
*/
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;
#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
#include "vm/global.h" /* required by native headers */
#include "native/jni.h"
+#include "native/llni.h"
/* keep this order of the native includes */
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;
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
#if defined(WITH_CLASSPATH_GNU)
/* set ProtectionDomain */
- o->pd = pd;
+ LLNI_field_set_ref(o, pd, pd);
#endif
return o;
#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 */
*/
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;
}
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
}
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
}
#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)
*/
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);
* 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)
return 0;
}
- name = javastring_toutf((java_objectheader *) libname, false);
+ name = javastring_toutf((java_handle_t *) libname, false);
/* is the library already loaded? */
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)
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 $
*/
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_String.h"
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
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)) {
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
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 */
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 */
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
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();
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
#include "vm/types.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_Object.h"
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
/* 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);
}
_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;
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();
#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 */
{
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;
}
{
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;
}
*/
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 */
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;
#if defined(WITH_CLASSPATH_GNU)
/* set ProtectionDomain */
- o->pd = protectionDomain;
+ LLNI_field_set_ref(o, pd, protectionDomain);
#endif
return o;
*/
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);
}
#include "config.h"
#include <stddef.h>
+#include <stdint.h>
#include "vm/types.h"
#include "toolbox/avl.h"
-#include "vm/jit/asmpart.h"
-
/* the AVL tree containing the critical sections */
/* 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 ***************************************************************
void critical_init(void)
{
criticaltree = avl_create(&critical_comparator);
-
- critical_register_asm_critical_sections();
}
*******************************************************************************/
-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;
}
-/* 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
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 $
*/
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;
*******************************************************************************/
-static void lock_hashtable_remove(java_objectheader *o)
+static void lock_hashtable_remove(java_object_t *o)
{
ptrint lockword;
lock_record_t *lr;
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 */
*******************************************************************************/
-void lock_init_object_lock(java_objectheader *o)
+void lock_init_object_lock(java_object_t *o)
{
assert(o);
*******************************************************************************/
-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;
*******************************************************************************/
-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! */
*******************************************************************************/
-bool lock_monitor_exit(java_objectheader *o)
+bool lock_monitor_exit(java_object_t *o)
{
threadobject *t;
ptrint lockword;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-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;
*******************************************************************************/
-void lock_notify_object(java_objectheader *o)
+void lock_notify_object(java_object_t *o)
{
threadobject *thread;
*******************************************************************************/
-void lock_notify_all_object(java_objectheader *o)
+void lock_notify_all_object(java_object_t *o)
{
threadobject *thread;
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 $
*/
*******************************************************************************/
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 */
/* 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 */
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 $
*/
#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"
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;
/* 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.<init>(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);
/* call public Thread(String name) */
- o = (java_objectheader *) t;
+ o = (java_handle_t *) t;
(void) vm_call_method(method_thread_init, o, threadname);
#else
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 */
class_java_lang_ThreadGroup,
true);
- o = (java_objectheader *) threadgroup;
+ o = (java_handle_t *) threadgroup;
(void) vm_call_method(m, o, t);
sem_t *psem;
classinfo *c;
methodinfo *m;
- java_objectheader *o;
+ java_handle_t *o;
functionptr function;
#if defined(ENABLE_INTRP)
/* 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 */
#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
{
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
/* 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)
#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
/* get the main thread */
mainthread = threads_list_first();
- group = mainthread->object->group;
+ group = LLNI_field_direct(mainthread->object, group);
#endif
}
/* 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,
#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);
{
#if defined(ENABLE_JAVASE)
java_lang_ThreadGroup *group;
+ classinfo *c;
methodinfo *m;
- java_objectheader *o;
+ java_handle_t *o;
java_lang_Thread *t;
#endif
#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,
if (m == NULL)
return false;
- o = (java_objectheader *) group;
+ o = (java_handle_t *) group;
t = thread->object;
(void) vm_call_method(m, o, t);
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/localref.h"
#include "native/include/java_lang_Thread.h"
#include "threads/native/lock.h"
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 */
/* exception pointer **********************************************************/
-extern java_objectheader *_no_threads_exceptionptr;
+extern java_object_t *_no_threads_exceptionptr;
#define exceptionptr (&_no_threads_exceptionptr)
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <unistd.h>
#include "vm/types.h"
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/include/java_lang_Object.h"
#include "native/include/java_lang_String.h"
void threads_preinit(void)
{
threadobject *mainthread;
-#if defined(__LINUX__)
+#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
char *pathbuf;
size_t len;
#endif
void threads_thread_free(threadobject *t)
{
- s4 index;
+ int32_t index;
+ uint32_t state;
/* lock the threads-lists */
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 */
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;
/* 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 */
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
#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
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
/* 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; */
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)",
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 $
*/
#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
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 $
*/
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 */
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 $
*/
/* 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
/* 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
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 $
*/
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 */
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 $
*/
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;
Changes:
- $Id: util.c 5252 2006-08-18 13:07:21Z twisti $
+ $Id: util.c 8295 2007-08-11 17:57:24Z michi $
*/
#include "vm/types.h"
#include "mm/memory.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
#include "vm/vm.h"
## 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
initialize.c \
initialize.h \
jit_interface.h \
+ primitive.c \
+ primitive.h \
properties.c \
properties.h \
resolve.c \
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/include/java_lang_String.h"
#include "native/include/java_lang_Throwable.h"
#include "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)
*******************************************************************************/
-s4 builtin_instanceof(java_objectheader *o, classinfo *class)
+s4 builtin_instanceof(java_handle_t *o, classinfo *class)
{
if (o == NULL)
return 0;
*******************************************************************************/
-s4 builtin_checkcast(java_objectheader *o, classinfo *class)
+s4 builtin_checkcast(java_handle_t *o, classinfo *class)
{
if (o == NULL)
return 1;
*******************************************************************************/
-s4 builtin_arraycheckcast(java_objectheader *o, classinfo *targetclass)
+s4 builtin_arraycheckcast(java_handle_t *o, classinfo *targetclass)
{
arraydescriptor *desc;
}
-s4 builtin_arrayinstanceof(java_objectheader *o, classinfo *targetclass)
+s4 builtin_arrayinstanceof(java_handle_t *o, classinfo *targetclass)
{
if (o == NULL)
return 0;
*******************************************************************************/
-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;
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");
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 {
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);
*******************************************************************************/
-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;
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} */
/* 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):
*
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):
*
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;
}
*******************************************************************************/
-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
if (!ea)
return NULL;
- ((java_objectarray *) a)->data[i] = (java_objectheader *) ea;
+ ((java_objectarray *) a)->data[i] = (java_object_t *) ea;
}
return a;
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;
typedesc *paramtype, s8 value)
{
imm_union imu;
- java_objectheader *o;
+ java_handle_t *o;
classinfo *c;
utf *u;
u4 len;
/* 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 */
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;
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;
*******************************************************************************/
-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 */
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 $
*/
* 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
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)
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,
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/native.h"
#include "native/include/java_lang_String.h"
#include "threads/lock-common.h"
#include "threads/threads-common.h"
-#include "toolbox/logging.h"
#include "toolbox/util.h"
#include "vm/builtin.h"
#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"
/* for raising exceptions from native methods *********************************/
#if !defined(ENABLE_THREADS)
-java_objectheader *_no_threads_exceptionptr = NULL;
+java_object_t *_no_threads_exceptionptr = NULL;
#endif
*******************************************************************************/
-java_objectheader *exceptions_get_exception(void)
+java_handle_t *exceptions_get_exception(void)
{
/* return the exception */
*******************************************************************************/
-void exceptions_set_exception(java_objectheader *o)
+void exceptions_set_exception(java_handle_t *o)
{
/* set the exception */
*******************************************************************************/
-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 */
*******************************************************************************/
-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);
*******************************************************************************/
-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);
static void exceptions_throw_class(classinfo *c)
{
- java_objectheader *o;
+ java_handle_t *o;
o = exceptions_new_class(c);
*******************************************************************************/
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;
*******************************************************************************/
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);
*******************************************************************************/
-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;
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 */
*******************************************************************************/
-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);
*******************************************************************************/
-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);
*******************************************************************************/
-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);
static void exceptions_throw_class_utf(classinfo *c, utf *message)
{
- java_objectheader *o;
+ java_handle_t *o;
o = exceptions_new_class_utf(c, 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);
*******************************************************************************/
-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);
*******************************************************************************/
#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);
*******************************************************************************/
-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) */
*******************************************************************************/
-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);
*******************************************************************************/
-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);
}
*******************************************************************************/
-void exceptions_throw_exceptionininitializererror(java_objectheader *cause)
+void exceptions_throw_exceptionininitializererror(java_handle_t *cause)
{
exceptions_throw_utf_throwable(utf_java_lang_ExceptionInInitializerError,
cause);
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 */
*******************************************************************************/
-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);
*******************************************************************************/
-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 */
*******************************************************************************/
-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;
*******************************************************************************/
-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);
*******************************************************************************/
-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);
*******************************************************************************/
-void exceptions_throw_privilegedactionexception(java_objectheader *exception)
+void exceptions_throw_privilegedactionexception(java_handle_t *exception)
{
exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException,
exception);
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 */
/* 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 */
*******************************************************************************/
-java_objectheader *exceptions_fillinstacktrace(void)
+java_handle_t *exceptions_fillinstacktrace(void)
{
- java_objectheader *o;
- methodinfo *m;
+ java_handle_t *o;
+ methodinfo *m;
/* get exception */
}
-/* 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.
*******************************************************************************/
#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;
classref_or_classinfo cr;
classinfo *c;
#if defined(ENABLE_THREADS)
- java_objectheader *o;
+ java_object_t *o;
#endif
#ifdef __S390__
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);
*******************************************************************************/
-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;
}
#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);
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);
void exceptions_print_current_exception(void)
{
- java_objectheader *o;
+ java_handle_t *o;
o = exceptions_get_exception();
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 */
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 $
*/
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.
/* 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);
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);
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);
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 $
*/
/* global variables ***********************************************************/
#if defined(ENABLE_THREADS)
-static java_objectheader *lock_thread_finalizer;
+static java_object_t *lock_thread_finalizer;
#endif
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
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 */
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 $
*/
/* forward typedefs ***********************************************************/
-typedef struct java_objectheader java_objectheader;
+typedef struct java_object_t java_object_t;
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.
#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;
};
+#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
*/
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;
use the same machine code */
struct java_objectarray {
- java_arrayheader header;
- java_objectheader *data[1];
+ java_arrayheader header;
+ java_object_t *data[1];
};
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 $
*/
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 */
## 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
loop \
optimizing \
schedule \
- tools \
verify \
\
intrp \
SUBDIRS = \
optimizing \
- tools \
$(ARCH_DIR)
ARCH_LIB = \
## 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
## 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
LIBS =
-BUILT_SOURCES = offsets.h
-
-CLEANFILES = offsets.h
-
noinst_HEADERS = \
arch.h \
machine-instr.h \
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:
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 $
*/
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 4 /* bytes */
-#define REPLACEMENT_STUB_SIZE 5 /* words */
#endif /* _ARCH_H */
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 $
*/
#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"
.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
.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
.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.
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
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,
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,
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,
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 */
}
/* 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);
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);
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;
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);
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;
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 $
*/
#include "vm/types.h"
#include <assert.h>
+#include <stdint.h>
#include "md-abi.h"
}
-/* 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;
}
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
# include "threads/native/threads.h"
#endif
-#include "vm/exceptions.h"
#include "vm/signallocal.h"
#include "vm/jit/asmpart.h"
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;
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 */
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 */
/* 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;
}
}
#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
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 $
*/
#if defined(ENABLE_REPLACEMENT)
void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode)
{
- s4 disp;
u4 mcode;
if (index < 0) {
*(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;
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 $
*/
/* patch the field value's address */
- *((ptrint *) datap) = (ptrint) &(fi->value);
+ *((intptr_t *) datap) = (intptr_t) fi->value;
return true;
}
## 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
## 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
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 \
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:
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 $
*/
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 4 /* bytes */
-#define REPLACEMENT_STUB_SIZE 5 /* words */
#endif /* _ARCH_H */
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"
.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 **********************************************************
#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__)
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 $
*/
#include "mm/memory.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
basicblock *bptr;
instruction *iptr;
exception_entry *ex;
- s4 fieldtype;
- s4 varindex;
s4 spilledregs_num;
s4 savedregs_num;
unresolved_method *um;
builtintable_entry *bte;
methoddesc *md;
+ fieldinfo *fi;
+ unresolved_field *uf;
+ int fieldtype;
+ int varindex;
/* get required compiler data */
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);
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,
if (opt_showdisassemble)
M_NOP;
}
-
- disp = dseg_add_address(cd, &(fi->value));
}
M_DSEG_LOAD(REG_ITMP3, disp);
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);
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,
if (opt_showdisassemble)
M_NOP;
}
-
- disp = dseg_add_address(cd, &(fi->value));
}
M_DSEG_LOAD(REG_ITMP3, disp);
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;
}
#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) {
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;
}
}
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) {
/* 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 */
/* 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);
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 */
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);
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;
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));
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;
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
}
-/* 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;
}
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
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;
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 */
/* 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;
}
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;
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 */
/* 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;
}
}
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
/* patch the field value's address */
- *((ptrint *) datap) = (ptrint) &(fi->value);
+ *((intptr_t *) datap) = (intptr_t) fi->value;
return true;
}
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 $
*/
#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 */
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);
/* 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);
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 $
*/
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;
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__))
#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)
*******************************************************************************/
-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 */
*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 */
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 $
*/
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);
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 $
*/
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));
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
+#include "vm/jit/patcher-common.h"
#include "vmcore/options.h"
#include "vmcore/statistics.h"
}
+/* emit_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
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 $
*/
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);
## 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
## 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
LIBS =
-BUILT_SOURCES = offsets.h
-
-CLEANFILES = offsets.h
-
noinst_HEADERS = \
arch.h \
machine-instr.h
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:
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 $
*/
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 5 /* bytes */
-#define REPLACEMENT_STUB_SIZE (5+5+1) /* bytes */
#endif /* _ARCH_H */
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 $
*/
#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"
.globl asm_compare_and_swap
.globl asm_memory_barrier
- .globl asm_criticalsections
- .globl asm_getclassvalues_atomic
-
.globl asm_get_cycle_count
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.
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include "vm/types.h"
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
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);
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);
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);
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) {
/* 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;
}
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;
}
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:
}
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;
}
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);
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,
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,
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,
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,
/* 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
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 $
*/
#include <assert.h>
#include <signal.h>
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
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;
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 */
/* 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;
}
u1 *sp;
u1 *ra;
u1 *xpc;
- s4 type;
- ptrint val;
- java_objectheader *e;
+ int type;
+ intptr_t val;
+ void *p;
_uc = (ucontext_t *) _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;
}
}
+/* 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)
{
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 $
*/
}
+/* 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.
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 $
*/
#include "config.h"
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
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;
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 */
/* 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;
}
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;
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;
}
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 $
*/
#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! */
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;
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 <stdint.h>
+
#include "vm/types.h"
#include "vm/jit/i386/codegen.h"
*******************************************************************************/
-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 */
/* 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 */
/* patch the field value's address */
- *((ptrint *) (ra + 1)) = (ptrint) &(fi->value);
+ *((intptr_t *) (ra + 1)) = (intptr_t) fi->value;
return true;
}
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 $
*/
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;
-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)
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 = \
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:
-/* 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
.globl asm_patcher_wrapper
-.globl asm_getclassvalues_atomic
.globl asm_abstractmethoderror
-.globl asm_criticalsections
.globl asm_handle_exception
.globl asm_handle_nat_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:
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "md-abi.h"
#include "md-os.h"
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
/* 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)
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);
/* 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);
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);
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);
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;
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 */
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;
uint16_t opc;
uint32_t val, regval, off;
bool adrreg;
- java_objectheader *e;
+ void *p;
mcontext_t *_mc;
_mc = &_uc->uc_mcontext;
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 *******************************************
uint16_t opc;
uint32_t type;
uint32_t val, regval;
- java_objectheader *e;
+ void *p;
mcontext_t *_mc;
xpc = siginfo->si_addr;
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 ***************************************************
*/
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);
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
/* 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);
## 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
LIBS =
-BUILT_SOURCES = \
- offsets.h
-
-CLEANFILES = \
- offsets.h
-
noinst_HEADERS = \
arch.h \
machine-instr.h \
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:
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 $
*/
#define SUPPORT_COMBINE_INTEGER_REGISTERS
-#define SUPPORT_PASS_FLOATARGS_IN_INTREGS
#if defined(ENABLE_SOFT_FLOAT)
# define SUPPORT_PASS_FLOATARGS_IN_INTREGS
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE (2*4) /* bytes */
-#define REPLACEMENT_STUB_SIZE 6 /* words */
#endif /* _ARCH_H */
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 $
*/
#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"
.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
.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 *********************************************************
#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:
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 $
*/
#include "mm/memory.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
#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"
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);
}
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);
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);
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);
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;
#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:
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;
}
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 */
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;
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
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;
}
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 */
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;
}
/* 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);
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);
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);
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 {
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;
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);
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);
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);
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 {
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;
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 */
dseg_createlinenumbertable(cd);
- /* generate stubs */
+ /* generate traps */
- emit_patcher_stubs(jd);
+ emit_patcher_traps(jd);
/* everything's ok */
#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 */
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);
}
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 $
*/
/* 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)
#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"
}
-/* 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;
}
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 $
*/
#include <assert.h>
#include <signal.h>
+#include <stdint.h>
#include <sys/fpu.h>
#include "vm/types.h"
#include "mm/gc-common.h"
-#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/signallocal.h"
#include "vm/stringlocal.h"
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;
define is 0. */
addr = _mc->gregs[s1];
- type = (s4) addr;
+ type = (int) addr;
val = 0;
}
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;
+ }
}
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 $
*/
#include <assert.h>
#include <sgidefs.h> /* required for _MIPS_SIM_ABI* defines (before signal.h) */
#include <signal.h>
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
#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"
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;
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
+ }
}
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 $
*/
void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp,
u1 *savedmcode)
{
- s4 disp;
union {
u8 both;
u4 words[2];
/* 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;
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
#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"
#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 *******************************************************
*******************************************************************************/
-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 */
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;
}
*******************************************************************************/
-bool patcher_get_putfield(u1 *sp)
+bool patcher_get_putfield(patchref_t *pr)
{
u1 *ra;
unresolved_field *uf;
/* 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:
<patched call postition>
dfc4ff98 ld a0,-104(s8)
+ MULTIANEWARRAY:
+
+ <patched call position>
+ dfc5ff90 ld a1,-112(s8)
+ 03a03025 move a2,sp
+ dfd9ff88 ld t9,-120(s8)
+ 0320f809 jalr t9
+ 00000000 nop
+
+ ARRAYCHECKCAST:
+
+ <patched call position>
+ 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):
<patched call position>
- 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:
<patched call position>
- 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 ************************************************
******************************************************************************/
-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;
}
*******************************************************************************/
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
{
u1 *ra;
unresolved_method *um;
/* 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;
}
*******************************************************************************/
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
{
u1 *ra;
unresolved_method *um;
/* 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:
-
- <patched call position>
- 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;
}
*******************************************************************************/
-bool patcher_checkcast_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
{
u1 *ra;
constant_classref *cr;
/* 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;
}
*******************************************************************************/
-bool patcher_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
{
u1 *ra;
constant_classref *cr;
/* 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:
-
- <patched call position>
- 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:
-
- <patched call position>
-
-*******************************************************************************/
-
-#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) */
/*
/* 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 **************************************************************
{
/* 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);
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 $
*/
#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
/* 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);
## 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
## 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
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 = \
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:
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 $
*/
#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*/
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 4 /* bytes */
-#define REPLACEMENT_STUB_SIZE 6 /* words */
#endif /* _ARCH_H */
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 $
*/
#include "vm/jit/abi-asm.h"
#include "vm/jit/methodheader.h"
-#include "vm/jit/powerpc/offsets.h"
.text
.globl asm_compare_and_swap
.globl asm_memory_barrier
- .globl asm_criticalsections
- .globl asm_getclassvalues_atomic
-
/* asm_vm_call_method **********************************************************
* *
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 */
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:
#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__)
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.
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 */
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
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 $
*/
#include "mm/memory.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
/* 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;
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 */
/* 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
*/
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 */
}
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 */
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
}
}
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
}
}
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
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)
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,
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,
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;
}
}
/* 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;
}
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);
}
}
}
}
/* 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 */
}
/* 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);
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);
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;
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);
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;
/* 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 */
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) */
/* 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);
}
}
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);
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);
- }
}
}
}
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;
/* 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);
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;
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 */
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 <stdint.h>
#include "vm/jit/powerpc/darwin/md-abi.h"
/* 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,
"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 */
10, /* a7 */
};
-const s4 abi_registers_integer_saved[] = {
+const int abi_registers_integer_saved[] = {
14, /* s0 */
15, /* s1 */
24, /* s2 */
31, /* s9 */
};
-const s4 abi_registers_integer_temporary[] = {
+const int abi_registers_integer_temporary[] = {
2, /* t0 */
17, /* t1 */
18, /* t2 */
};
-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,
REG_END
};
-const s4 abi_registers_float_argument[] = {
+const int abi_registers_float_argument[] = {
1, /* fa0 */
2, /* fa1 */
3, /* fa2 */
13, /* fa12 */
};
-const s4 abi_registers_float_saved[] = {
+const int abi_registers_float_saved[] = {
14, /* fs0 */
15, /* fs1 */
24, /* fs2 */
31, /* fs9 */
};
-const s4 abi_registers_float_temporary[] = {
+const int abi_registers_float_temporary[] = {
17, /* ft5 */
18, /* ft6 */
19, /* ft7 */
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 */
}
-/* 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
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 $
*/
#define asm_cacheflush _asm_cacheflush
-#define asm_criticalsections _asm_criticalsections
-#define asm_getclassvalues_atomic _asm_getclassvalues_atomic
-
/* external defines ***********************************************************/
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 $
*/
#include <assert.h>
#include <signal.h>
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
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;
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 */
/* 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;
}
}
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;
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 */
/* 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;
}
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 $
*/
#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"
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;
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;
}
-/* 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;
}
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 $
*/
/* 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,
"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 */
10, /* a7 */
};
-const int32_t abi_registers_integer_saved[] = {
+const int abi_registers_integer_saved[] = {
14, /* s0 */
15, /* s1 */
24, /* s2 */
31, /* s9 */
};
-const int32_t abi_registers_integer_temporary[] = {
+const int abi_registers_integer_temporary[] = {
17, /* t0 */
18, /* t1 */
19, /* t2 */
};
-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,
};
-const int32_t abi_registers_float_argument[] = {
+const int abi_registers_float_argument[] = {
1, /* fa0 */
2, /* fa1 */
3, /* fa2 */
8, /* fa7 */
};
-const int32_t abi_registers_float_saved[] = {
+const int abi_registers_float_saved[] = {
14, /* fs0 */
15, /* fs1 */
24, /* fs2 */
31, /* fs9 */
};
-const int32_t abi_registers_float_temporary[] = {
+const int abi_registers_float_temporary[] = {
9, /* ft0 */
10, /* ft1 */
11, /* ft2 */
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 */
}
-/* 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
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
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;
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 */
/* 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;
}
}
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;
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 */
/* 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;
}
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 $
*/
#if defined(ENABLE_REPLACEMENT)
void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode)
{
- s4 disp;
u4 mcode;
if (index < 0) {
*(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;
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
/* patch the field value's address */
- *((ptrint *) datap) = (ptrint) &(fi->value);
+ *((intptr_t *) datap) = (intptr_t) fi->value;
/* synchronize data cache */
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);
}
}
## 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
## 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
LIBS =
-BUILT_SOURCES = offsets.h
-
-CLEANFILES = offsets.h
-
noinst_HEADERS = \
arch.h \
machine-instr.h
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:
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 $
*/
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 4 /* bytes */
-#define REPLACEMENT_STUB_SIZE 6 /* words */
#endif /* _ARCH_H */
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 $
*/
#include "vm/jit/abi-asm.h"
#include "vm/jit/methodheader.h"
-#include "vm/jit/powerpc64/offsets.h"
+
/* export functions ***********************************************************/
#endif
.globl asm_cacheflush
- .globl asm_criticalsections
- .globl asm_getclassvalues_atomic
+
/* asm_vm_call_method **********************************************************
* *
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 ********************************************************/
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include <signal.h>
#include "mm/memory.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
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);
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);
}
/* 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 */
}
/* 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);
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);
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;
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);
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;
}
+/* 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:
+ */
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <ucontext.h>
#include "vm/types.h"
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);
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;
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;
}
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 $
*/
#if defined(ENABLE_REPLACEMENT)
void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode)
{
- s4 disp;
u4 mcode;
if (index < 0) {
*(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;
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
/* patch the field value's address */
- *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+ *((intptr_t *) (pv + disp)) = (intptr_t) fi->value;
/* synchronize data cache */
}
-/* 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
/* 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
*******************************************************************************/
/* 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
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);
/* 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 */
#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);
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;
};
-## 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
## 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
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 = \
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:
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 $
*/
/* 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 */
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 $
*/
#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"
.globl asm_abstractmethoderror
- .globl asm_patcher_wrapper
-
.globl asm_replacement_out
.globl asm_replacement_in
.globl asm_builtin_d2i
.globl asm_builtin_d2l
- .globl asm_criticalsections
- .globl asm_getclassvalues_atomic
-
asm_abstractmethoderror:
.long 0
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
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
j L_asm_handle_nat_exception
-#if 0
/* asm_handle_exception ********************************************************
* *
* This function handles an exception. It does not use the usual calling *
* *
*******************************************************************************/
-#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
#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 *********************************************************
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.
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 $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
-#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"
#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 *********************************************************************
*******************************************************************************/
+/*
+
+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)
{
/* 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 */;
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
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
*/
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 */
/* 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 */
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;
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(
}
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);
}
}
} 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;
}
}
}
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
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);
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);
}
/* 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; */
/* 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;
}
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;
}
}
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;
* 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;
}
}
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) {
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 */
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 */
#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);
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;
}
}
/* 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;
}
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
/* 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;
}
/* 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;
*/
if (lm == NULL) {
- codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0);
+ patcher_add_patch_ref(jd, PATCHER_invokeinterface, um, 0);
s1 = 0;
s2 = 0;
}
/* 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);
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);
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);
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);
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);
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;
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);
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);
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);
}
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);
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);
}
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;
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);
}
/* generate stubs */
- emit_patcher_stubs(jd);
-#if defined(ENABLE_REPLACEMENT)
- REPLACEMENT_EMIT_STUBS(jd);
-#endif
+ emit_patcher_traps(jd);
/* everything's ok */
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 */
/* 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 */
/* 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))
#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 */
/* 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);
/* 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) {
}
} 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)) {
/* 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)) {
/* 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);
/* 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 */
/* generate patcher stubs */
- emit_patcher_stubs(jd);
+ emit_patcher_traps(jd);
}
s4 codegen_reg_of_dst_notzero(jitdata *jd, instruction *iptr, s4 tempregnum) {
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 $
*/
/* 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 ************************************************************/
#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)
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 <assert.h>
+#include <stdint.h>
-#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 *******************************************************************
*******************************************************************************/
-__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;
*******************************************************************************/
-__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;
*******************************************************************************/
-__PORTED__ void emit_copy(jitdata *jd, instruction *iptr)
+void emit_copy(jitdata *jd, instruction *iptr)
{
codegendata *cd;
varinfo *src;
}
}
+/* 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.
/* 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;
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)) {
iargctr += 1;
} else { /* passed on stack */
N_MVC(doff + 4, 4, REG_SP, aoff, REG_SP);
- aoff += 4;
+ aoff += 8;
}
}
}
*******************************************************************************/
-__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;
*******************************************************************************/
-__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;
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 $
*/
};
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
};
};
const s4 abi_registers_float_saved[] = {
- /* nothing */
- -1
+ 4, /* f4 */
+ 6 /* f6 */
};
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;
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;
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;
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;
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;
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);
}
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 $
*/
#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
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 $
*/
#define itmp3 %r14
#define v0 %r2
#define pv %r13
+#define ra %r14
#define mptr itmp2
#define xptr itmp1
-/* 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
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 <assert.h>
+#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
#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"
int i;
u1 *pv;
methodinfo *m;
-
+
union {
u8 l;
fpreg_t fr;
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)
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;
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;
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);
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;
(_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 */
_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;
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;
}
/* 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;
}
}
#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
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 <assert.h>
+#include <stdint.h>
#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 <assert.h>
-#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 *******************************************************
*******************************************************************************/
-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 */
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;
}
*******************************************************************************/
-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) */
*******************************************************************************/
-__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 */
/* 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 */
*******************************************************************************/
-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 */
/* 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 */
*******************************************************************************/
-__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;
}
*******************************************************************************/
-__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;
}
*******************************************************************************/
-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;
}
*******************************************************************************/
-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 */
/* 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 */
*******************************************************************************/
-__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 */
/* patch back original code */
- *((u4 *) ra) = mcode;
+ PATCH_BACK_ORIGINAL_MCODE;
return true;
}
*******************************************************************************/
#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 */
/* patch back original code */
- *((u4 *) ra) = mcode;
+ PATCH_BACK_ORIGINAL_MCODE;
return true;
}
*******************************************************************************/
#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
/* global variables ***********************************************************/
#if defined(ENABLE_THREADS) && !defined(NDEBUG)
-static java_objectheader *show_global_lock;
+static java_object_t *show_global_lock;
#endif
#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
if (stage >= SHOW_PARSE) { \
putchar('"'); \
utf_display_printable_ascii( \
- javastring_toutf((java_objectheader *)(val), false)); \
+ javastring_toutf((java_handle_t *)(val), false)); \
printf("\" "); \
} \
else { \
## 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
## 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
LIBS =
-BUILT_SOURCES = offsets.h
-
-CLEANFILES = offsets.h
-
noinst_HEADERS = \
arch.h \
machine-instr.h \
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:
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 4 /* bytes */
-#define REPLACEMENT_STUB_SIZE 5 /* words */ /* XXX adapt for sparc64 */
#endif /* _ARCH_H */
#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
.global asm_abstractmethoderror
- .global asm_criticalsections
- .global asm_getclassvalues_atomic
-
.global asm_store_fp_state_reg
.global 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__)
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include "vm/types.h"
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/localref.h"
#include "native/native.h"
#include "vm/builtin.h"
#include "vm/exceptions.h"
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;
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);
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);
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);
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 */
}
/* 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);
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);
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;
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);
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;
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;
}
#endif
- /* save float argument registers (into abi parameter slots) */
+ /* save float argument registers */
assert(ABIPARAMS_CNT >= FLT_ARG_CNT);
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 */
}
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);
}
}
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);
}
}
}
COUNT_WRITE_SPILLS(dst)
disp = JITSTACK + dst->vv.regoff;
-
+
switch(dst->type)
{
case TYPE_INT:
}
+/* 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.
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <signal.h>
#include "vm/types.h"
#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"
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;
/* 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 */
/* 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.
}
break;
}
+ assert(pd->regoff != 26);
}
/* Since O0 is used for passing return values, this */
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 */
case TYPE_LNG:
if (i < INT_NATARG_CNT) {
pd->inmemory = false;
- pd->regoff = reguse;
+ pd->regoff = nat_argintregs[reguse];
reguse++;
md->argintreguse = reguse;
pd->regoff = reguse * 8;
reguse++;
}
-
- if (i >= min_nat_regs)
- stacksize++;
break;
case TYPE_FLT:
case TYPE_DBL:
reguse++;
}
- if (i >= min_nat_regs)
- stacksize++;
break;
}
+
+ if (i >= min_nat_regs)
+ stacksize++;
}
/* Since O0 is used for passing return values, this */
-/* 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,
#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 */
*(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;
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
*******************************************************************************/
-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
#endif
functionptr f;
bool result;
- java_objectheader *e;
+ java_handle_t *e;
/* define the patcher function */
/* 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 */
/* patch the field value's address */
- *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+ *((intptr_t *) (pv + disp)) = (intptr_t) fi->value;
/* synchronize data cache */
/* 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
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 <assert.h>
+#include <stdint.h>
#include <ucontext.h>
/* work around name clash */
return val;
}
+
/* md_signal_handler_sigsegv ***************************************************
NullPointerException signal handler for hardware null pointer
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;
/* flush register windows? */
- val = md_get_reg_from_context(_mc, d);
+ val = md_get_reg_from_context(_mc, d);
/* check for special-load */
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 */
/* 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;
}
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 $
*/
#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)
continue;
}
- oa->data[i] = (java_objectheader *) ste->method->class;
+ oa->data[i] = (java_object_t *) ste->method->class;
}
/* release dump memory */
java_objectarray *classes;
java_objectarray *methodnames;
classinfo *c;
- java_objectheader *string;
+ java_handle_t *string;
s4 i;
s4 dumpsize;
CYCLES_STATS_DECLARE_AND_START
/* 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);
*******************************************************************************/
-void stacktrace_print_trace(java_objectheader *xptr)
+void stacktrace_print_trace(java_handle_t *xptr)
{
java_lang_Throwable *t;
#if defined(WITH_CLASSPATH_GNU)
/* 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
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 $
*/
#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) */
+++ /dev/null
-## 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:
+++ /dev/null
-/* 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 <stdio.h>
-
-#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:
- */
-
-
#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)
#include "vm/access.h"
#include "vm/builtin.h"
#include "vm/exceptions.h"
+#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/vm.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
#define TYPECHECK_NO_STATISTICS
#include <typecheck-common.h>
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 $
*/
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
+#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/jit/jit.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
#include <typecheck-common.h>
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 $
*/
#include "toolbox/logging.h"
#include "vm/exceptions.h"
+#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/jit/jit.h"
#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! */
## 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
SUBDIRS = $(OS_DIR)
-BUILT_SOURCES = \
- offsets.h
-
-CLEANFILES = \
- offsets.h
-
noinst_HEADERS = \
arch.h \
machine-instr.h \
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:
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 $
*/
/* replacement ****************************************************************/
#define REPLACEMENT_PATCH_SIZE 5 /* bytes */
-#define REPLACEMENT_STUB_SIZE (10+2+10+2+1) /* bytes */
#endif /* _ARCH_H */
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 $
*/
#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"
.globl asm_compare_and_swap
.globl asm_memory_barrier
- .globl asm_criticalsections
- .globl asm_getclassvalues_atomic
-
/********************* function asm_calljavafunction ***************************
* *
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__)
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/localref.h"
#include "native/native.h"
#include "threads/lock-common.h"
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)) {
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)) {
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)) {
}
/* 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;
}
/* 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);
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,
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,
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,
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,
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 $
*/
}
+/* 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.
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
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;
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 */
/* 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;
}
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;
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 */
/* 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;
}
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 $
*/
#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 */
#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! */
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;
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 <stdint.h>
+
#include "vm/types.h"
#include "vm/jit/x86_64/codegen.h"
*******************************************************************************/
-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 */
/* 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 */
/* patch the field value's address */
- *((ptrint *) (ra + 7 + disp)) = (ptrint) &(fi->value);
+ *((intptr_t *) (ra + 7 + disp)) = (intptr_t) fi->value;
return true;
}
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 */
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;
/* 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;
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 $
*/
*******************************************************************************/
-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 */
*******************************************************************************/
#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 */
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) */
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 $
*/
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 */
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 $
*/
#include "vm/access.h"
#include "vm/exceptions.h"
#include "vm/global.h"
+#include "vm/primitive.h"
#include "vm/resolve.h"
#include "vm/jit/jit.h"
#include "vmcore/linker.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
/******************************************************************************/
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 $
*/
#include <assert.h>
#include <errno.h>
#include <signal.h>
+#include <stdint.h>
#include <stdlib.h>
#if defined(__DARWIN__)
# include <sys/types.h>
#endif
-#include "vm/types.h"
-
#include "arch.h"
#include "mm/memory.h"
# 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)
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. */
/* 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)
}
#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)
#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__) */
}
+/* 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
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 $
*/
#include <signal.h>
-#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 */
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 $
*/
#include "mm/memory.h"
#include "native/jni.h"
+#include "native/llni.h"
#include "native/include/java_lang_String.h"
#include "vm/builtin.h"
#include "vm/exceptions.h"
+#include "vm/primitive.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
#include "vmcore/statistics.h"
#include "vmcore/utf8.h"
hashtable hashtable_string; /* hashtable for javastrings */
#if defined(ENABLE_THREADS)
-static java_objectheader *lock_hashtable_string;
+static java_object_t *lock_hashtable_string;
#endif
#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
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 */
*******************************************************************************/
-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;
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;
}
*******************************************************************************/
-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;
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;
}
*******************************************************************************/
-java_objectheader *javastring_new_from_utf_string(const char *utfstr)
+java_handle_t *javastring_new_from_utf_string(const char *utfstr)
{
assert(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) {
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;
}
*******************************************************************************/
-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;
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;
}
*******************************************************************************/
-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();
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;
}
*******************************************************************************/
-char *javastring_tochar(java_objectheader *so)
+char *javastring_tochar(java_handle_t *so)
{
java_lang_String *s = (java_lang_String *) so;
java_chararray *a;
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';
*******************************************************************************/
-utf *javastring_toutf(java_objectheader *string, bool isclassname)
+utf *javastring_toutf(java_handle_t *string, bool isclassname)
{
java_lang_String *s;
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);
}
*******************************************************************************/
-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 */
LOCK_MONITOR_EXIT(lock_hashtable_string);
- return (java_objectheader *) js;
+ return (java_object_t *) js;
}
nomatch:
#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 */
LOCK_MONITOR_EXIT(lock_hashtable_string);
- return (java_objectheader *) js;
+ return (java_object_t *) js;
}
*******************************************************************************/
-java_objectheader *literalstring_new(utf *u)
+java_object_t *literalstring_new(utf *u)
{
char *utf_ptr; /* pointer to current unicode character */
/* utf string */
*******************************************************************************/
-void literalstring_free(java_objectheader* string)
+void literalstring_free(java_object_t* string)
{
java_lang_String *s;
java_chararray *a;
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 $
*/
struct literalstring {
literalstring *hashlink; /* link for external hash chain */
- java_objectheader *string;
+ java_object_t *string;
};
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 */
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 $
*/
#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 */
#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"
#include "vmcore/classcache.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
#include "vmcore/statistics.h"
#include "vmcore/suck.h"
#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
else if (strcmp("jit", opt_arg) == 0) {
opt_verbose = true;
loadverbose = true;
- linkverbose = true;
initverbose = true;
compileverbose = true;
}
{
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;
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"));
#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;
#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;
}
-/* 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;
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
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;
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 */
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;
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;
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;
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;
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.
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 $
*/
#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);
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 */
LIBS =
if ENABLE_JAVASE
+if ENABLE_ANNOTATIONS
ANNOTATION_SOURCES = \
annotation.c \
annotation.h
+endif
STACKMAP_SOURCES = \
stackmap.c \
method.h \
options.c \
options.h \
- primitive.c \
- primitive.h \
+ primitivecore.c \
references.h \
$(RT_TIMING_SOURCES) \
$(STACKMAP_SOURCES) \
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 <assert.h>
+
#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 */
+ <quote cite="http://jcp.org/en/jsr/detail?id=202">
+ The RuntimeInvisibleParameterAnnotations attribute is similar to the
+ RuntimeVisibleParameterAnnotations attribute, except that the annotations
+ represented by a RuntimeInvisibleParameterAnnotations attribute must not be
+ made available for return by reflective APIs, unless the the JVM has
+ specifically been instructed to retain these annotations via some
+ implementation-specific mechanism such as a command line flag. In the
+ absence of such instructions, the JVM ignores this attribute.
+ </quote>
- 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
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: utf8.h 5920 2006-11-05 21:23:09Z twisti $
-
*/
/* 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 {
element_value_t *element_values;
};
-
/* element_value **************************************************************/
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 */
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 $
*/
#include "vmcore/class.h"
#include "vmcore/classcache.h"
+#include "vmcore/linker.h"
#include "vmcore/loader.h"
#include "vmcore/options.h"
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
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 */
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
}
bool class_isanysubclass(classinfo *sub, classinfo *super)
{
- castinfo classvalues;
- u4 diffval;
+ uint32_t diffval;
bool result;
/* This is the trivial case. */
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;
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 $
*/
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)
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 */
};
#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;
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 $
*/
hashtable hashtable_classcache;
#if defined(ENABLE_THREADS)
-static java_objectheader *lock_hashtable_classcache;
+static java_object_t *lock_hashtable_classcache;
#endif
#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
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 $
*/
#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"
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 $
*/
#include <stdint.h>
#include <stdio.h>
+#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"
{
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;
/* 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;
/* 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;
if (!(cl = class_getconstant(c, pindex, CONSTANT_Long)))
return false;
- f->value.l = cl->value;
+ f->value->l = cl->value;
}
break;
if (!(cf = class_getconstant(c, pindex, CONSTANT_Float)))
return false;
- f->value.f = cf->value;
+ f->value->f = cf->value;
}
break;
if (!(cd = class_getconstant(c, pindex, CONSTANT_Double)))
return false;
- f->value.d = cd->value;
+ f->value->d = cd->value;
}
break;
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)
if (!loader_load_attribute_signature(cb, &(f->signature)))
return false;
}
+
+#if defined(ENABLE_ANNOTATIONS)
+ else if (u == utf_RuntimeVisibleAnnotations) {
+ /* RuntimeVisibleAnnotations */
+ if (!annotation_load_field_attribute_runtimevisibleannotations(cb, f))
+ return false;
+ }
+ else if (u == utf_RuntimeInvisibleAnnotations) {
+ /* RuntimeInvisibleAnnotations */
+ if (!annotation_load_field_attribute_runtimeinvisibleannotations(cb, f))
+ return false;
+ }
+#endif
#endif
else {
/* unknown attribute */
}
+#if 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)
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 $
*/
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) */
};
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);
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 $
*/
#include "vm/access.h"
#include "vm/exceptions.h"
+#include "vm/primitive.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
#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" */
static s4 interfaceindex; /* sequential numbering of interfaces */
static s4 classvalue;
-java_objectheader *linker_classrenumber_lock;
+java_object_t *linker_classrenumber_lock;
/* private functions **********************************************************/
/* 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);
#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
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;
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
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)
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 $
*/
/* 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 ********************************************************/
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 $
*/
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/global.h"
+#include "vm/primitive.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
#include "vmcore/loader.h"
#include "vmcore/method.h"
#include "vmcore/options.h"
-#include "vmcore/primitive.h"
#include "vmcore/rt-timing.h"
#if defined(ENABLE_STATISTICS)
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;
}
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);
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;
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))
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);
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 $
*/
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 */
}
+/* 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
{
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;
if (!resolve_class_from_typedesc(¶mtypes[i], true, false, &c))
return NULL;
- oa->data[i] = (java_objectheader *) c;
+ oa->data[i] = c;
}
return oa;
if (c == NULL)
return NULL;
- oa->data[i] = (java_objectheader *) c;
+ oa->data[i] = c;
}
return oa;
}
+#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
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 $
*/
/* 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 */
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);
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);
+++ /dev/null
-/* 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 <assert.h>
-#include <stdint.h>
-
-#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:
- */
+++ /dev/null
-/* 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 <stdint.h>
-
-#include "vm/global.h"
-
-#include "vmcore/class.h"
-#include "vmcore/linker.h"
-#include "vmcore/utf8.h"
-
-
-/* primitive data types *******************************************************/
-
-/* These values are used in parsed descriptors and in some other
- places were the different types handled internally as TYPE_INT have
- to be distinguished. */
-
-#define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */
-
-/* CAUTION: Don't change the numerical values! These constants are
- used as indices into the primitive type table. */
-
-#define PRIMITIVETYPE_INT TYPE_INT
-#define PRIMITIVETYPE_LONG TYPE_LNG
-#define PRIMITIVETYPE_FLOAT TYPE_FLT
-#define PRIMITIVETYPE_DOUBLE TYPE_DBL
-#define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */
-#define PRIMITIVETYPE_BYTE 5
-#define PRIMITIVETYPE_CHAR 6
-#define PRIMITIVETYPE_SHORT 7
-#define PRIMITIVETYPE_BOOLEAN 8
-#define PRIMITIVETYPE_DUMMY2 9 /* not used! */
-#define PRIMITIVETYPE_VOID TYPE_VOID
-
-
-/* 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:
- */
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 $
*/
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;
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 $
*/
#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; /* <init> */
#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("<init>");
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 $
*/
#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;
+++ /dev/null
-gnu/java/net/protocol/file/Connection getInputStream ()Ljava/io/InputStream;
-java/lang/VMThrowable <init> ()V
-gnu/java/net/protocol/file/Handler <init> ()V
-gnu/java/locale/Calendar <init> ()V
-gnu/java/locale/Calendar_en <init> ()V
-gnu/java/locale/LocaleInformation <init> ()V
-gnu/java/locale/LocaleInformation_en_US <init> ()V
-gnu/java/lang/SystemClassLoader <clinit> ()V
+++ /dev/null
-java/lang/VMThrowable <init> ()V
-gnu/java/nio/channels/FileChannelImpl <init> (II)V
-java/lang/reflect/Constructor <init> ()V
-gnu/java/io/decode/Decoder8859_1 <init> (Ljava/io/InputStream;)V
-gnu/java/io/encode/Encoder8859_1 <init> (Ljava/io/OutputStream;)V
-gnu/java/net/protocol/file/Handler <init> ()V
-gnu/java/net/protocol/jar/Handler <init> ()V
-gnu/java/net/protocol/jar/Connection <init> (Ljava/net/URL;)V
-gnu/java/locale/Calendar <init> ()V
-gnu/java/locale/Calendar_en <init> ()V