[kaffe] CVS kaffe (hkraemer): moved handling of trampolines into engine specific files

Kaffe CVS cvs-commits at kaffe.org
Thu Aug 19 12:32:58 PDT 2004


PatchSet 5083 
Date: 2004/08/19 19:29:00
Author: hkraemer
Branch: HEAD
Tag: (none) 
Log:
moved handling of trampolines into engine specific files

Members: 
	ChangeLog:1.2641->1.2642 
	include/errors.h:1.11->1.12 
	kaffe/kaffevm/classMethod.c:1.121->1.122 
	kaffe/kaffevm/classMethod.h:1.67->1.68 
	kaffe/kaffevm/code.c:1.15->1.16 
	kaffe/kaffevm/external.c:1.67->1.68 
	kaffe/kaffevm/external.h:1.7->1.8 
	kaffe/kaffevm/kaffe.def:1.33->1.34 
	kaffe/kaffevm/lookup.c:1.38->1.39 
	kaffe/kaffevm/soft.c:1.65->1.66 
	kaffe/kaffevm/soft.h:1.16->1.17 
	kaffe/kaffevm/support.c:1.71->1.72 
	kaffe/kaffevm/support.h:1.32->1.33 
	kaffe/kaffevm/intrp/Makefile.am:1.10->1.11 
	kaffe/kaffevm/intrp/Makefile.in:1.116->1.117 
	kaffe/kaffevm/intrp/icode.h:1.20->1.21 
	kaffe/kaffevm/intrp/methodcalls.c:INITIAL->1.1 
	kaffe/kaffevm/intrp/methodcalls.h:INITIAL->1.1 
	kaffe/kaffevm/intrp/native-wrapper.c:1.2->1.3 
	kaffe/kaffevm/jit/Makefile.am:1.16->1.17 
	kaffe/kaffevm/jit/Makefile.in:1.122->1.123 
	kaffe/kaffevm/jit/funcs.c:1.4->1.5 
	kaffe/kaffevm/jit/icode.c:1.27->1.28 
	kaffe/kaffevm/jit/machine.c:1.68->1.69 
	kaffe/kaffevm/jit/methodcalls.c:INITIAL->1.1 
	kaffe/kaffevm/jit/methodcalls.h:INITIAL->1.1 
	kaffe/kaffevm/jit3/Makefile.am:1.11->1.12 
	kaffe/kaffevm/jit3/Makefile.in:1.93->1.94 
	kaffe/kaffevm/jit3/codeproto.h:1.15->1.16 
	kaffe/kaffevm/jit3/icode.c:1.44->1.45 
	kaffe/kaffevm/jit3/machine.c:1.55->1.56 
	kaffe/kaffevm/jit3/methodcalls.c:INITIAL->1.1 
	kaffe/kaffevm/jit3/methodcalls.h:INITIAL->1.1 
	kaffe/kaffevm/jni/jni-callmethod.c:1.2->1.3 
	kaffe/kaffevm/jni/jni.c:1.6->1.7 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2641 kaffe/ChangeLog:1.2642
--- kaffe/ChangeLog:1.2641	Thu Aug 19 09:50:57 2004
+++ kaffe/ChangeLog	Thu Aug 19 19:29:00 2004
@@ -1,3 +1,58 @@
+2004-08-19  Helmer Kraemer  <hkraemer at freenet.de>
+
+	* kaffe/kaffevm/jit3/methodcalls.c, kaffe/kaffevm/jit3/methodcalls.h
+	kaffe/kaffevm/jit/methodcalls.c, kaffe/kaffevm/jit/methodcalls.h
+	kaffe/kaffevm/intrp/methodcalls.c, kaffe/kaffevm/intrp/methodcalls.h:
+	new files
+
+	* kaffe/kaffevm/jit3/Makefile.am, kaffe/kaffevm/jit/Makefile.am,
+	kaffe/kaffevm/intrp/Makefile.am: added new files
+
+	* kaffe/kaffevm/jit3/Makefile.in, kaffe/kaffevm/jit/Makefile.in,
+	kaffe/kaffevm/intrp/Makefile.in: regenerated
+
+	* kaffe/kaffevm/classMethod.h: removed METHOD_INDIRECTMETHOD macro,
+	use only one definition of METHOD_NATIVECODE for all engines
+
+	* kaffe/kaffevm/classMethod.c (processClass): replace METHOD_INDIRECTMETHOD
+	with METHOD_NATIVECODE
+	(methodNeedsTrampoline, buildTrampoline): moved to jit/methodcalls.c
+	(buildDispatchTable, buildInterfaceDispatchTable, prepareInterface):
+	use new engine_buildTrampoline method
+	
+	* kaffe/kaffevm/jni/jni.c, kaffe/kaffevm/jni/jni-callmethod.c:
+	replaced METHOD_INDIRECTMETHOD with METHOD_NATIVECODE
+
+	* kaffe/kaffevm/external.c (error_stub): removed
+	(Kaffe_JNI_native, native): return address of native function or NULL,
+	don't create wrappers for native functions
+
+	* kaffe/kaffevm/kaffe.def (INVOKEVIRTUAL, INVOKESPECIAL): throw
+	AbstractMethodError if necessary
+
+	* kaffe/kaffevm/lookup.c (throwAbstractMethodError): removed
+	(findMethodLocal): don't modify METHOD_NATIVECODE when method is abstract
+
+	* kaffe/kaffevm/soft.c (soft_abstractmethod): new method
+	(soft_fixup_trampoline): moved into jit/methodcalls.c
+
+	* kaffe/kaffevm/support.c (do_execute_java_method_v, do_execute_java_class_method_v,
+	execute_java_constructor_v): replaced METHOD_INDIRECTMETHOD with METHOD_NATIVECODE
+	(callMethodA, callMethodV): allocate call.args, call.callsize and call.calltype
+	dynamically. Moved engine specific part into new engine_callMethod function.
+
+	* kaffe/kaffevm/intrp/native-wrapper.c (engine_create_wrapper): use
+	METHOD_CODE_START to store address of native function
+
+	* kaffe/kaffevm/intrp/icode.h, kaffe/kaffevm/jit/icode.c,
+	kaffe/kaffevm/jit3/codeproto.h, kaffe/kaffevm/jit3/icode.c:
+	added softcall_abstractmethod
+
+	* kaffe/kaffevm/jit/machine.c, kaffe/kaffevm/jit3/machine.c
+	(translate): adapted to changes to external.c
+
+	* include/errors.h (AbstractMethodError): pass String to constructor
+	
 2004-08-19  Guilhem Lavaux <guilhem at kaffe.org>
 
 	* kaffe/kaffevm/systems/unix-pthreads/syscalls.c
Index: kaffe/include/errors.h
diff -u kaffe/include/errors.h:1.11 kaffe/include/errors.h:1.12
--- kaffe/include/errors.h:1.11	Mon Mar 29 20:24:29 2004
+++ kaffe/include/errors.h	Thu Aug 19 19:29:02 2004
@@ -101,7 +101,7 @@
 #define ArrayIndexOutOfBoundsException NEW_LANG_EXCEPTION(ArrayIndexOutOfBoundsException)
 #define ArrayStoreException NEW_LANG_EXCEPTION(ArrayStoreException)
 #define ArithmeticException NEW_LANG_EXCEPTION(ArithmeticException)
-#define AbstractMethodError NEW_LANG_EXCEPTION(AbstractMethodError)
+#define AbstractMethodError(M) NEW_LANG_EXCEPTION_MESSAGE(AbstractMethodError, M)
 #define ThreadDeath NEW_LANG_EXCEPTION(ThreadDeath)
 #define StackOverflowError NEW_LANG_EXCEPTION(StackOverflowError)
 #define IllegalThreadStateException NEW_LANG_EXCEPTION(IllegalThreadStateException)
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.121 kaffe/kaffe/kaffevm/classMethod.c:1.122
--- kaffe/kaffe/kaffevm/classMethod.c:1.121	Sat Jul 17 07:57:13 2004
+++ kaffe/kaffe/kaffevm/classMethod.c	Thu Aug 19 19:29:02 2004
@@ -47,6 +47,7 @@
 #include "debugFile.h"
 #include "jvmpi_kaffe.h"
 #include "kaffe/jmalloc.h"
+#include "methodcalls.h"
 
 #if 0
 #define	METHOD_TRUE_NCODE(METH)			(METH)->c.ncode.ncode_start
@@ -567,7 +568,7 @@
 DBG(STATICINIT,
 			dprintf("using callMethodA\n");
     )
-			callMethodA(meth, METHOD_INDIRECTMETHOD(meth), 0, 0, 0, 1);
+			callMethodA(meth, METHOD_NATIVECODE(meth), 0, 0, 0, 1);
 		}
 
 		lockClass(class);
@@ -1931,112 +1932,6 @@
 	return true;
 }
 
-#if defined(TRANSLATOR)
-/*
- * When do we need a trampoline?
- *
- * NB: this method is invoked for *all* methods a class defines or
- * inherits.
- */
-static bool
-methodNeedsTrampoline(Method *meth)
-{
- 	/* A gcj class's native virtual methods always need a trampoline
-	 * since the gcj trampoline doesn't work for them.  By using a
-	 * trampoline, we can fix the vtable the first time it is invoked.
-	 *
-	 * NB: If we'll ever support CNI, revisit this.
-	 */
-	if (CLASS_GCJ((meth)->class) && (meth->accflags & ACC_NATIVE) &&
-		meth->idx != -1)
-		return (true);
-
-	/* If the method hasn't been translated, we need a trampoline
-	 * NB: we assume the TRANSLATED flag for abstract methods produced
-	 * by gcj is cleared.
-	 */
-	if (!METHOD_TRANSLATED(meth))
-		return (true);
-
-	/* We also need one if it's a static method and the class
-	 * hasn't been initialized, because such method invocation
-	 * would constitute a first active use, requiring the initializer
-	 * to be run.
-	 */
-	if ((meth->accflags & ACC_STATIC)
-		&& meth->class->state < CSTATE_DOING_INIT)
-	{
-		/* Exception: gcj's classes don't need trampolines for two
-		 * reasons:
- 		 *   a) call _Jv_InitClass before invoking any static method.
-		 *   b) they're not compiled as indirect invocations anyway
-		 */
-		if (!CLASS_GCJ(meth->class)) {
-			return (true);
-		}
-	}
-	return (false);
-}
-#endif /* TRANSLATOR */
-
-
-
-/*
- * Build a trampoline if necessary, return the address of the native code
- * to either the trampoline or the translated or native code.
- *
- * Sets *where to the address of the native code.
- *
- * Return the address of the native code or 0 on failure
- */
-static void *
-/* ARGSUSED */
-buildTrampoline(Method *meth, void **where, errorInfo *einfo)
-{
-	void *ret;
-
-#if defined(TRANSLATOR)
-	methodTrampoline *tramp;
-
-	if (methodNeedsTrampoline(meth)) {
-		/* XXX don't forget to pick those up at class gc time */
-		tramp = (methodTrampoline*)gc_malloc(sizeof(methodTrampoline), KGC_ALLOC_TRAMPOLINE);
-		if (tramp == 0) {
-			postOutOfMemory(einfo);
-			return (0);
-		}
-		FILL_IN_TRAMPOLINE(tramp, meth, where);
-
-		/* a disadvantage of building trampolines individually---as
-		 * opposed to allocating them in a contiguous region---is that
-		 * we have flush the dcache individually for each trampoline
-		 */
-		FLUSH_DCACHE(tramp, tramp+1);
-
-		/* for native gcj methods, we do override their
-		 * anchors so we can patch them up before they're invoked.
-		 */
-		if (!(CLASS_GCJ((meth)->class)
-			&& (meth->accflags & ACC_NATIVE)))
-		{
-			assert(*where == 0 ||
-				!!!"Cannot override trampoline anchor");
-		}
-		ret = tramp;
-	} else {
-		if (CLASS_GCJ((meth)->class)) {
-			METHOD_NATIVECODE(meth) = meth->ncode;
-		}
-		assert(METHOD_NATIVECODE(meth) != 0);
-		ret = METHOD_NATIVECODE(meth);
-	}
-#else
-	ret = meth;
-#endif
-	*where = ret;
-	return (ret);
-}
-
 /*
  * Check whether there exists a method with the same name and signature
  * ``meth'' in class ``clazz'' or any of its superclasses.
@@ -2136,7 +2031,7 @@
 		 * point to this trampoline.
 		 */
 		where = (void**)PMETHOD_NATIVECODE(meth);
-		if (buildTrampoline(meth, where, einfo) == 0) {
+		if (engine_buildTrampoline(meth, where, einfo) == 0) {
 			return (false);
 		}
 	}
@@ -2159,7 +2054,7 @@
 			 * but do not update METHOD_NATIVECODE.
 			 */
 			where = &mtab[meth->idx];
-			if (buildTrampoline(meth, where, einfo) == 0) {
+			if (engine_buildTrampoline(meth, where, einfo) == 0) {
 				return (false);
 			}
 		}
@@ -2269,7 +2164,7 @@
 			if (cmeth == 0) {
 				class->itable2dtable[j] = (void *)-1;
 			} else {
-				if (buildTrampoline(cmeth,
+				if (engine_buildTrampoline(cmeth,
 					    class->itable2dtable + j,
 					    einfo) == 0)
 				{
@@ -2473,17 +2368,15 @@
 	for (i = 0; i < CLASS_NMETHODS(class); i++, meth++) {
 		if (meth->accflags & ACC_STATIC) {
 			meth->idx = -1;
-#if defined(TRANSLATOR)
 			/* Handle <clinit> */
 			if (utf8ConstEqual(meth->name, init_name)) {
 				void **where;
 				where = (void**)PMETHOD_NATIVECODE(meth);
 
-				if (buildTrampoline(meth, where, einfo) == 0) {
+				if (engine_buildTrampoline(meth, where, einfo) == 0) {
 					return (false);
 				}
 			}
-#endif
 		}
 		else {
 			meth->idx = class->msize++;
Index: kaffe/kaffe/kaffevm/classMethod.h
diff -u kaffe/kaffe/kaffevm/classMethod.h:1.67 kaffe/kaffe/kaffevm/classMethod.h:1.68
--- kaffe/kaffe/kaffevm/classMethod.h:1.67	Mon Aug  2 10:44:56 2004
+++ kaffe/kaffe/kaffevm/classMethod.h	Thu Aug 19 19:29:02 2004
@@ -184,14 +184,9 @@
 #define METHOD_TRANSLATED(M)		((M)->accflags & ACC_TRANSLATED)
 #define METHOD_JITTED(M)		((M)->accflags & ACC_JITTED)
 
-#if defined(TRANSLATOR)
 #define	METHOD_NATIVECODE(M)		(((M)->idx == -1) ? \
 		((M)->ncode) : \
 		((M)->class->vtable->method[(M)->idx]))
-#else
-/* INTERPRETER */
-#define	METHOD_NATIVECODE(M)		((M)->ncode)
-#endif
 
 /* Like METHOD_NATIVECODE, except we take the address ---
  * gcc doesn't compile &( ? : ) expressions for some reason
@@ -205,12 +200,6 @@
 					(M)->accflags |= ACC_TRANSLATED
 #define	SET_METHOD_JITCODE(M, C)	METHOD_NATIVECODE(M) = (C); \
 					(M)->accflags |= ACC_TRANSLATED|ACC_JITTED
-
-#if defined(TRANSLATOR)
-#define	METHOD_INDIRECTMETHOD(M)	METHOD_NATIVECODE(M)
-#else
-#define	METHOD_INDIRECTMETHOD(M)	(M)
-#endif
 
 /*
  * Stats for the nameMapping object.
Index: kaffe/kaffe/kaffevm/code.c
diff -u kaffe/kaffe/kaffevm/code.c:1.15 kaffe/kaffe/kaffevm/code.c:1.16
--- kaffe/kaffe/kaffevm/code.c:1.15	Sat Jul 17 07:57:13 2004
+++ kaffe/kaffe/kaffevm/code.c	Thu Aug 19 19:29:02 2004
@@ -22,7 +22,6 @@
 #include "object.h"
 #include "classMethod.h"
 #include "readClass.h"
-#include "slots.h"
 #include "exception.h"
 
 bool
Index: kaffe/kaffe/kaffevm/external.c
diff -u kaffe/kaffe/kaffevm/external.c:1.67 kaffe/kaffe/kaffevm/external.c:1.68
--- kaffe/kaffe/kaffevm/external.c:1.67	Sun Jul 25 06:37:22 2004
+++ kaffe/kaffe/kaffevm/external.c	Thu Aug 19 19:29:02 2004
@@ -40,7 +40,6 @@
 #include "jthread.h"
 #include "jsignal.h"
 #include "stats.h"
-#include "native-wrapper.h"
 #if defined(KAFFE_FEEDBACK)
 #include "feedback.h"
 #endif
@@ -106,17 +105,6 @@
 
 extern JavaVM Kaffe_JavaVM;
 
-/*
- * Error stub function.  Point unresolved link errors here to avoid
- * problems.
- */
-static
-void*
-error_stub(void)
-{
-	return (0);
-}
-
 #ifdef ENABLE_BINRELOC
 static
 const char *discoverLibraryHome()
@@ -476,7 +464,7 @@
 /*
  * Look up a native function using the JNI interface system.
  */
-static jint
+static nativecode*
 Kaffe_JNI_native(Method* meth)
 {
 	char name[1024];
@@ -500,21 +488,21 @@
 		strcat(name, "__");
 		strcatJNI(name, METHOD_SIGD(meth));
 		func = loadNativeLibrarySym(name);
-		if (func == 0) {
-			return (JNI_FALSE);
-		}
 	}
 
-	meth->accflags |= ACC_JNI;
-
-	/* Wrap the function in a calling wrapper */
-	engine_create_wrapper(meth, func);
+	if (func != NULL) {
+		meth->accflags |= ACC_JNI;
+	}
 
-	return (JNI_TRUE);
+	return (func);
 }
 
-
-bool
+/**
+ * Try to find the native implementation of a java method.
+ *
+ * 
+ */
+nativecode*
 native(Method* m, errorInfo *einfo)
 {
 	char stub[MAXSTUBLEN];
@@ -546,34 +534,24 @@
 
 	/* Find the native method */
 	func = loadNativeLibrarySym(stub);
-	if (func != 0) {
-		/* Fill it in */
-		engine_create_wrapper(m, func);
-		return (true);
+	if (func != NULL) {
+		return (func);
 	}
 
 	/* Try to locate the nature function using the JNI interface */
-        if (Kaffe_JNI_native(m)) {
-                return (true);
+	func = Kaffe_JNI_native(m);
+        if (func != NULL) {
+                return (func);
         }
 
 DBG(NATIVELIB,
 	dprintf("Failed to locate native function:\n\t%s.%s%s\n",
 		m->class->name->data, m->name->data, METHOD_SIGD(m));
     )
-#if defined(TRANSLATOR)
-	{
-		/* Work around for KFREE() ? : bug in gcc 2.7.2 */
-		void *nc = METHOD_NATIVECODE(m);
-		KFREE(nc);
-	}
-#endif
-	SET_METHOD_NATIVECODE(m, (void*)error_stub);
-
 	postExceptionMessage(einfo, JAVA_LANG(UnsatisfiedLinkError),
 		"Failed to locate native function:\t%s.%s%s",
 		m->class->name->data, m->name->data, METHOD_SIGD(m));
-	return (false);
+	return (NULL);
 }
 
 /*
Index: kaffe/kaffe/kaffevm/external.h
diff -u kaffe/kaffe/kaffevm/external.h:1.7 kaffe/kaffe/kaffevm/external.h:1.8
--- kaffe/kaffe/kaffevm/external.h:1.7	Sat Apr  3 02:57:43 2004
+++ kaffe/kaffe/kaffevm/external.h	Thu Aug 19 19:29:02 2004
@@ -30,7 +30,7 @@
 int	loadNativeLibrary2(char*, int, char*, size_t);
 void	unloadNativeLibrary(int);
 void*	loadNativeLibrarySym(const char*);
-bool	native(struct _methods*, struct _errorInfo*);
+nativecode*	native(struct _methods*, struct _errorInfo*);
 void	addNativeFunc(char*, void*);
 char*	getLibraryPath(void);
 
Index: kaffe/kaffe/kaffevm/kaffe.def
diff -u kaffe/kaffe/kaffevm/kaffe.def:1.33 kaffe/kaffe/kaffevm/kaffe.def:1.34
--- kaffe/kaffe/kaffevm/kaffe.def:1.33	Fri Jul 30 13:57:34 2004
+++ kaffe/kaffe/kaffevm/kaffe.def	Thu Aug 19 19:29:02 2004
@@ -2703,6 +2703,13 @@
 		pop(method_nargs() + 1);
 		METHOD_RETURN_VALUE();
 	}
+	else if ( (method_method()->accflags & ACC_ABSTRACT) != 0 &&
+		  (method_class()->accflags & ACC_ABSTRACT) == 0 ) {
+		softcall_abstractmethod(method_classname(), method_name());
+		low = method_returntype();
+		pop(method_nargs() + 1);
+		METHOD_RETURN_VALUE();
+	}
 	else if (!checkMethodAccess(current_class(),
 				    method_class(),
 				    method_method())) {
@@ -2828,6 +2835,13 @@
 	}
 	else if (method_method()->accflags & ACC_STATIC) {
 		softcall_incompatibleclasschange(method_classname(), method_name());
+		low = method_returntype();
+		pop(method_nargs() + 1);
+		METHOD_RETURN_VALUE();
+	}
+	else if ( (method_method()->accflags & ACC_ABSTRACT) != 0 &&
+		  (method_class()->accflags & ACC_ABSTRACT) == 0 ) {
+		softcall_abstractmethod(method_classname(), method_name());
 		low = method_returntype();
 		pop(method_nargs() + 1);
 		METHOD_RETURN_VALUE();
Index: kaffe/kaffe/kaffevm/lookup.c
diff -u kaffe/kaffe/kaffevm/lookup.c:1.38 kaffe/kaffe/kaffevm/lookup.c:1.39
--- kaffe/kaffe/kaffevm/lookup.c:1.38	Sun Jul 25 16:33:49 2004
+++ kaffe/kaffe/kaffevm/lookup.c	Thu Aug 19 19:29:02 2004
@@ -29,8 +29,6 @@
 #include "locks.h"
 #include "soft.h"
 
-static void throwAbstractMethodError(void);
-
 /*
  * Lookup a method reference and get the various interesting bits.
  *
@@ -320,20 +318,6 @@
 	n = CLASS_NMETHODS(class);
 	for (mptr = CLASS_METHODS(class); --n >= 0; ++mptr) {
 		if (utf8ConstEqual (name, mptr->name) && utf8ConstEqual (signature, METHOD_SIG(mptr))) {
-			if ((mptr->accflags & ACC_ABSTRACT) != 0 && !CLASS_IS_INTERFACE(mptr->class)) {
-#if defined(TRANSLATOR)
-				if(KGC_getObjectIndex(main_collector,
-						     METHOD_NATIVECODE(mptr))
-				   == KGC_ALLOC_DISPATCHTABLE) {
-					/* 'nc' is workaround for GCC 2.7.2 ?: bug */
-					void *nc;
-					nc = METHOD_NATIVECODE(mptr);
-					KFREE(nc);
-				}
-#endif
-				SET_METHOD_NATIVECODE(mptr, (void*)throwAbstractMethodError);
-				mptr->accflags |= ACC_NATIVE;
-			}
 DBG(MLOOKUP,
 			dprintf("findMethodLocal(%s,%s,%s) -> %p\n",
 				class->name->data, name->data, signature->data, mptr); )
@@ -378,12 +362,4 @@
 	}
 	postExceptionMessage(einfo, JAVA_LANG(NoSuchMethodError), "%s", name->data);
 	return (0);
-}
-
-static
-void
-NONRETURNING
-throwAbstractMethodError(void)
-{
-	throwException(AbstractMethodError);
 }
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.65 kaffe/kaffe/kaffevm/soft.c:1.66
--- kaffe/kaffe/kaffevm/soft.c:1.65	Sun Jul 25 16:33:49 2004
+++ kaffe/kaffe/kaffevm/soft.c	Thu Aug 19 19:29:02 2004
@@ -12,8 +12,6 @@
 #include <stdarg.h>
 
 #include "debug.h"
-#define	TDBG(s)
-
 #include "config.h"
 #include "config-std.h"
 #include "config-math.h"
@@ -553,6 +551,18 @@
 }
 
 /*
+ * soft_abstractmethod.
+ */
+void
+soft_abstractmethod(Utf8Const *c, Utf8Const* n)
+{
+	char buf[256];
+
+	sprintf(buf, "%.100s.%.100s", c->data, n->data);
+	throwException(AbstractMethodError(buf));
+}
+
+/*
  * soft_initialise_class.
  */
 void
@@ -567,88 +577,6 @@
 	}
 }
 
-#if defined(TRANSLATOR)
-/*
- * Trampolines come in here - do the translation and replace the trampoline.
- */
-nativecode*
-soft_fixup_trampoline(FIXUP_TRAMPOLINE_DECL)
-{
-	Method* meth;
-	void **where;
-	void *tramp;
-	errorInfo info;
-
-	/* FIXUP_TRAMPOLINE_INIT sets tramp and where */
-	FIXUP_TRAMPOLINE_INIT;
-	tramp = *where;
-
-DBG(MOREJIT,
-	dprintf("soft_fixup_trampoline(): meth %p, where %p\n",
-		meth, where);
-    );
-
-	/* If this class needs initializing, do it now.  */
-	if (meth->class->state < CSTATE_USABLE &&
-		processClass(meth->class, CSTATE_COMPLETE, &info) == false) {
-		throwError(&info);
-	}
-
-	/* Generate code on demand.  */
-	if (!METHOD_TRANSLATED(meth)) {
-		if (translate(meth, &info) == false) {
-			throwError(&info);
-		}
-	}
-
-	/*
-	 * Update the origin of the trampoline and free it if necessary. 
-	 * Another thread might have jumped through the same trampoline
-	 * while we were translating the method, so we have to make this
-	 * atomic.
-	 */
-#if defined(COMPARE_AND_EXCHANGE)
-	if (COMPARE_AND_EXCHANGE(where, tramp, METHOD_NATIVECODE(meth))) {
-		gc_free(tramp);
-	}
-#elif defined(ATOMIC_EXCHANGE)
-	{
-		void *tmp = METHOD_NATIVECODE(meth); 
-
-		ATOMIC_EXCHANGE(where, tmp);
-
-		if (tmp == tramp) {
-			gc_free(tramp);
-		}
-	}
-#else
-#error "You have to define either COMPARE_AND_EXCHANGE or ATOMIC_EXCHANGE"
-#endif
-
-#if 0
-	if (METHOD_PRE_COMPILED(meth)) {
-		nativecode* ncode = METHOD_TRUE_NCODE(meth);
-		nativecode* ocode = METHOD_NATIVECODE(meth);
-		METHOD_NATIVECODE(meth) = ncode;
-		/* Update the dtable entries for all classes if this isn't a
-	   	   static method.  */
-		if (meth->idx >= 0 && ocode != ncode) {
-			meth->class->dtable->method[meth->idx] = ncode;
-		}
-		SET_METHOD_PRE_COMPILED(meth, 0);
-	}
-#endif
-
-TDBG(	dprintf("Calling %s:%s%s @ %p\n", meth->class->name->data, meth->name->data, METHOD_SIGD(meth), METHOD_NATIVECODE(meth));	)
-
-DBG(MOREJIT,
-	dprintf("soft_fixup_trampoline(): return %p\n",
-		METHOD_NATIVECODE(meth));
-    );
-
-	return (METHOD_NATIVECODE(meth));
-}
-#endif
 
 /*
  * Check we can store 'obj' into the 'array'.
Index: kaffe/kaffe/kaffevm/soft.h
diff -u kaffe/kaffe/kaffevm/soft.h:1.16 kaffe/kaffe/kaffevm/soft.h:1.17
--- kaffe/kaffe/kaffevm/soft.h:1.16	Sat Apr  3 02:57:43 2004
+++ kaffe/kaffe/kaffevm/soft.h	Thu Aug 19 19:29:02 2004
@@ -39,6 +39,7 @@
 void	soft_linkage(Utf8Const*, Utf8Const*) NONRETURNING;
 void	soft_illegalaccess(Utf8Const*, Utf8Const*) NONRETURNING;
 void	soft_incompatibleclasschange(Utf8Const*, Utf8Const*) NONRETURNING;
+void	soft_abstractmethod(Utf8Const*, Utf8Const*) NONRETURNING;
 void	soft_stackoverflow(void) NONRETURNING;
 void	soft_checkarraystore(struct Hjava_lang_Object*, struct Hjava_lang_Object*);
 void	soft_addreference(void*, void*);
Index: kaffe/kaffe/kaffevm/support.c
diff -u kaffe/kaffe/kaffevm/support.c:1.71 kaffe/kaffe/kaffevm/support.c:1.72
--- kaffe/kaffe/kaffevm/support.c:1.71	Mon Aug  2 10:44:56 2004
+++ kaffe/kaffe/kaffevm/support.c	Thu Aug 19 19:29:02 2004
@@ -39,6 +39,8 @@
 #include "thread.h"
 #include "jthread.h"
 #include "locks.h"
+#include "methodcalls.h"
+#include "native.h"
 
 #if !defined(HAVE_GETTIMEOFDAY)
 #include <sys/timeb.h>
@@ -152,7 +154,7 @@
 		throwException(NoSuchMethodError(method_name));
 	}
 
-	callMethodV(mb, METHOD_INDIRECTMETHOD(mb), obj, argptr, &retval);
+	callMethodV(mb, METHOD_NATIVECODE(mb), obj, argptr, &retval);
 
 	return (retval);
 }
@@ -228,7 +230,7 @@
 	}
 
 	/* Make the call */
-	callMethodV(mb, METHOD_INDIRECTMETHOD(mb), 0, argptr, &retval);
+	callMethodV(mb, METHOD_NATIVECODE(mb), 0, argptr, &retval);
 
 	return (retval);
 }
@@ -317,7 +319,7 @@
 	assert(obj != 0);
 
 	/* Make the call */
-	callMethodV(mb, METHOD_INDIRECTMETHOD(mb), obj, argptr, &retval);
+	callMethodV(mb, METHOD_NATIVECODE(mb), obj, argptr, &retval);
 
 	return (obj);
 }
@@ -434,54 +436,18 @@
 	int i;
 	int j;
 	int s;
-	/* XXX call.callsize and call.calltype arrays are statically sized 
-	   and are not checked for running out of bounds */
 	callMethodInfo call;	
-	jvalue in[MAXMARGS];
 	jvalue tmp;
 
 	if (ret == 0) {
 		ret = &tmp;
 	}
-	i = 0;
+	i = engine_reservedArgs(meth);
 	s = 0;
-
-#if defined(INTERPRETER)
-	/*
-	 * If the method is native, we must find it so that we know whether
-	 * it is a JNI method or not.  If it is one, ACC_JNI will be set
-	 * upon return from native and we will add additional parameters 
-	 * according to the JNI calling convention.
-	 */
-	meth = (Method*)func;
-	if (meth->accflags & ACC_NATIVE) {
-		if (!METHOD_TRANSLATED(meth)) {
-			errorInfo info;
-			if (native(meth, &info) == false) {
-				throwError(&info);
-			}
-		}
-		call.function = METHOD_NATIVECODE(meth);
-	}
-
-	/* Insert the JNI environment */
-	if (meth->accflags & ACC_JNI) {
-		call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
-		call.calltype[i] = 'L';
-		in[i].l = THREAD_JNIENV(); 
-		s += call.callsize[i];
-		i++;
-
-		/* If method is static we must insert the class as an argument */
-		if (meth->accflags & ACC_STATIC) {
-			call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
-			s += call.callsize[i];
-			call.calltype[i] = 'L';
-			in[i].l = meth->class;
-			i++;
-		}
-	} 
-#endif
+	
+	call.args = (jvalue *)alloca((METHOD_NARGS(meth)+engine_reservedArgs(meth)+2)*(sizeof(jvalue)+2));
+	call.callsize = (char *)&call.args[METHOD_NARGS(meth)+engine_reservedArgs(meth)+2];
+	call.calltype = (char *)&call.callsize[METHOD_NARGS(meth)+engine_reservedArgs(meth)+2];
 
 	/* If this method isn't static, we must insert the object as
 	 * an argument.
@@ -490,7 +456,7 @@
 		call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
 		s += call.callsize[i];
 		call.calltype[i] = 'L';
-		in[i].l = obj;
+		call.args[i].l = obj;
 		i++;
 	}
 
@@ -500,30 +466,30 @@
 		case 'Z':
 			if (promoted) goto use_int;
 			call.callsize[i] = 1;
-			in[i].PROM_i = args[j].z;
+			call.args[i].PROM_i = args[j].z;
 			break;
 
 		case 'S':
 			if (promoted) goto use_int;
 			call.callsize[i] = 1;
-			in[i].PROM_i = args[j].s;
+			call.args[i].PROM_i = args[j].s;
 			break;
 
 		case 'B':
 			if (promoted) goto use_int;
 			call.callsize[i] = 1;
-			in[i].PROM_i = args[j].b;
+			call.args[i].PROM_i = args[j].b;
 			break;
 
 		case 'C':
 			if (promoted) goto use_int;
 			call.callsize[i] = 1;
-			in[i].PROM_i = args[j].c;
+			call.args[i].PROM_i = args[j].c;
 			break;
 
 		case 'F':
 			call.callsize[i] = 1;
-			in[i].PROM_f = args[j].f;
+			call.args[i].PROM_f = args[j].f;
 			if (PROMOTE_jfloat2jdouble) {
 				call.calltype[i] = 'D';
 			}
@@ -531,19 +497,19 @@
 		case 'I':
 		use_int:
 			call.callsize[i] = 1;
-			in[i].PROM_i = args[j].i;
+			call.args[i].PROM_i = args[j].i;
 			break;
 		case 'D':
 		case 'J':
 			call.callsize[i] = 2;
 			ENSURE_ALIGN64({});
-			in[i] = args[j];
+			call.args[i] = args[j];
 			if (promoted) { /* compensate for the second array element by incrementing args */
 			  args++;
 			}
 			if (! NO_HOLES) {
 				s += call.callsize[i];
-				in[i+1].i = (&in[i].i)[1];
+				call.args[i+1].i = (&call.args[i].i)[1];
 				i++; 
 				call.calltype[i] = 0;
 				call.callsize[i] = 0;
@@ -554,7 +520,7 @@
 			/* fall through */
 		case 'L':
 			call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
-			in[i] = args[j];
+			call.args[i] = args[j];
 			break;
 		default:
 			ABORT();
@@ -565,7 +531,7 @@
 #if defined(STACK_LIMIT)
 	call.calltype[i] = 'L';
 	call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
-	in[i].l = jthread_stacklimit();
+	call.args[i].l = jthread_stacklimit();
 	s += PTR_TYPE_SIZE / SIZEOF_INT;
 	i++;
 #endif
@@ -594,11 +560,7 @@
 	/* Call info and arguments */
 	call.nrargs = i;
 	call.argsize = s;
-	call.args = in;
 	call.ret = ret;
-
-
-#if defined(TRANSLATOR)
 	call.function = func;
 
 	/* GCDIAG wipes free memory with 0xf4... */
@@ -606,82 +568,7 @@
 	assert(*(uint32*)(call.function) != 0xf4f4f4f4);
 
 	/* Make the call - system dependent */
-	sysdepCallMethod(&call);
-#endif
-#if defined(INTERPRETER)
-	if ((meth->accflags & ACC_NATIVE) == 0) {
-		virtualMachine(meth, (slots*)call.args, (slots*)call.ret, THREAD_DATA()); 
-	}
-	else {
-		Hjava_lang_Object* syncobj = 0;
-		VmExceptHandler mjbuf;
-		threadData* thread_data = THREAD_DATA(); 
-		struct Hjava_lang_Throwable *save_except = NULL;
-
-		if (meth->accflags & ACC_SYNCHRONISED) {
-			if (meth->accflags & ACC_STATIC) {
-				syncobj = &meth->class->head;
-			}
-			else {
-				syncobj = (Hjava_lang_Object*)call.args[0].l;
-			}
-			lockObject(syncobj);
-		}
-
-		setupExceptionHandling(&mjbuf, meth, syncobj, thread_data);
-
-		/* This exception has yet been handled by the VM creator.
-		 * We are putting it in stand by until it is cleared. For
-		 * that JNI call we're cleaning up the pointer and we will
-		 * put it again to the value afterward.
-		 */
-		if ((meth->accflags & ACC_JNI) != 0) {
-			if (thread_data->exceptObj != NULL)
-				save_except = thread_data->exceptObj;
-			else
-				save_except = NULL;
-			thread_data->exceptObj = NULL;
-		}
-			
-		/* Make the call - system dependent */
-		sysdepCallMethod(&call);
-
-		if (syncobj != 0) {
-			unlockObject(syncobj);
-		}
-
-		/* If we have a pending exception and this is JNI, throw it */
-		if ((meth->accflags & ACC_JNI) != 0) {
-			struct Hjava_lang_Throwable *eobj;
-			
-			eobj = thread_data->exceptObj;
-			if (eobj != 0) {
-				thread_data->exceptObj = 0;
-				throwExternalException(eobj);
-			}
-			thread_data->exceptObj = save_except;
-		}
-
-		cleanupExceptionHandling(&mjbuf, thread_data);
-
-	}
-#endif
-	if (!promoted && call.retsize == 1) {
-		switch (call.rettype) {
-		case 'Z':
-			ret->z = ret->i;
-			break;
-		case 'S':
-			ret->s = ret->i;
-			break;
-		case 'B':
-			ret->b = ret->i;
-			break;
-		case 'C':
-			ret->c = ret->i;
-			break;
-		}
-	}
+	engine_callMethod(&call);
 }
 
 /**
@@ -700,50 +587,18 @@
 	int i;
 	int s;
 	int j;
-	/* XXX call.callsize and call.calltype arrays are statically sized 
-	   and are not checked for running out of bounds */
 	callMethodInfo call;
-	jvalue in[MAXMARGS];
 	jvalue tmp;
 
 	if (ret == 0) {
 		ret = &tmp;
 	}
-	i = 0;
+	i = engine_reservedArgs(meth);
 	s = 0;
 
-#if defined(INTERPRETER)
-	meth = (Method*)func;
-	if (meth->accflags & ACC_NATIVE) {
-                if (METHOD_NATIVECODE(meth) == 0) {
-			errorInfo info;
-			if (native(meth, &info) == false) {
-				throwError(&info);
-			}
-                }
-		call.function = METHOD_NATIVECODE(meth);
-	}
-
-	/* Insert the JNI environment */
-	if (meth->accflags & ACC_JNI) {
-		call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
-		call.calltype[i] = 'L';
-		in[i].l = THREAD_JNIENV(); 
-		s += call.callsize[i];
-		i++;

*** Patch too long, truncated ***




More information about the kaffe mailing list