[kaffe] CVS kaffe (dalibor): Refactored interpreter exception handling into separate functions

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Sun Sep 28 15:39:02 2003


PatchSet 4074 
Date: 2003/09/28 22:30:18
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Refactored interpreter exception handling into separate functions

Members: 
	ChangeLog:1.1669->1.1670 
	kaffe/kaffevm/exception.h:1.22->1.23 
	kaffe/kaffevm/support.c:1.60->1.61 
	kaffe/kaffevm/intrp/machine.c:1.32->1.33 
	kaffe/kaffevm/intrp/machine.h:1.8->1.9 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1669 kaffe/ChangeLog:1.1670
--- kaffe/ChangeLog:1.1669	Sun Sep 28 20:07:15 2003
+++ kaffe/ChangeLog	Sun Sep 28 22:30:18 2003
@@ -1,3 +1,22 @@
+2003-09-28  Dalibor Topic <robilad@kaffe.org>
+
+	* kaffe/kaffevm/exception.h:
+	{INTERPRETER] removed vmExcept_setIntrpFrame, moved to
+	intrp/machine.c and renamed to setFrame.
+
+	* kaffe/kaffevm/support.c:
+	(callMethodA, callMethodV)[INTERPRETER] Call new functions in
+	machine.c.
+	
+	* kaffe/kaffevm/intrp/machine.c:
+	(setFrame, setupExceptionHandling, cleanupExceptionHandling) New
+	functions.
+	(virtualMachine) Call the new functions.
+
+	* kaffe/kaffevm/intrp/machine.h:
+	Added prototypes for setupExceptionHandling,
+	cleanupExceptionHandling.
+
 2003-09-28  Guilhem Lavaux <guilhem@kaffe.org>
 
 	* libraries/javalib/java/nio/ByteBufferHelper.java: added missing
Index: kaffe/kaffe/kaffevm/exception.h
diff -u kaffe/kaffe/kaffevm/exception.h:1.22 kaffe/kaffe/kaffevm/exception.h:1.23
--- kaffe/kaffe/kaffevm/exception.h:1.22	Sun Jul 27 16:53:46 2003
+++ kaffe/kaffe/kaffevm/exception.h	Sun Sep 28 22:30:19 2003
@@ -33,6 +33,7 @@
 struct Hjava_lang_Class;
 struct Hjava_lang_Object;
 struct Hjava_lang_Throwable;
+
 struct _methods;
 struct _errorInfo;
 
@@ -146,19 +147,6 @@
 {
 	JTHREAD_LONGJMP(frame->jbuf, 1);
 }
-
-#if defined(INTERPRETER)
-static inline void 
-vmExcept_setIntrpFrame(VmExceptHandler* eh, u4 pc, struct _methods* meth, struct Hjava_lang_Object* syncobj)
-{
-	assert(eh);
-	assert(meth);
-	
-	eh->meth = meth;
-	eh->frame.intrp.pc = pc;
-	eh->frame.intrp.syncobj = syncobj;
-}
-#endif
 
 static inline void 
 vmExcept_setSyncObj(VmExceptHandler* eh, struct Hjava_lang_Object* syncobj)
Index: kaffe/kaffe/kaffevm/support.c
diff -u kaffe/kaffe/kaffevm/support.c:1.60 kaffe/kaffe/kaffevm/support.c:1.61
--- kaffe/kaffe/kaffevm/support.c:1.60	Sun Aug 31 22:09:02 2003
+++ kaffe/kaffe/kaffevm/support.c	Sun Sep 28 22:30:19 2003
@@ -623,11 +623,7 @@
 			lockObject(syncobj);
 		}
 
-		vmExcept_setIntrpFrame(&mjbuf, 0, meth, syncobj);
-		if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
-			mjbuf.prev = (VmExceptHandler*)unhand(tid)->exceptPtr;
-			unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)&mjbuf;
-		}
+		setupExceptionHandling(&mjbuf, meth, syncobj, tid);
 
 		/* Make the call - system dependent */
 		sysdepCallMethod(&call);
@@ -636,9 +632,7 @@
 			unlockObject(syncobj);
 		}
 
-		if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
-			unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)mjbuf.prev;
-		}
+		cleanupExceptionHandling(&mjbuf, tid);
 	}
 #endif
 	if (!promoted && call.retsize == 1) {
@@ -843,11 +837,7 @@
 			lockObject(syncobj);
 		}
 
-		vmExcept_setIntrpFrame(&mjbuf, 0, meth, syncobj);
-		if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
-			mjbuf.prev = (VmExceptHandler*)unhand(tid)->exceptPtr;
-			unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)&mjbuf;
-		}
+		setupExceptionHandling(&mjbuf, meth, syncobj, tid);
 
 		/* Make the call - system dependent */
 		sysdepCallMethod(&call);
@@ -856,9 +846,7 @@
 			unlockObject(syncobj);
 		}
 
-		if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
-			unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)mjbuf.prev;
-		}
+		cleanupExceptionHandling(&mjbuf, tid);
 	}
 #endif
 }
Index: kaffe/kaffe/kaffevm/intrp/machine.c
diff -u kaffe/kaffe/kaffevm/intrp/machine.c:1.32 kaffe/kaffe/kaffevm/intrp/machine.c:1.33
--- kaffe/kaffe/kaffevm/intrp/machine.c:1.32	Sun Jul 27 16:53:47 2003
+++ kaffe/kaffe/kaffevm/intrp/machine.c	Sun Sep 28 22:30:20 2003
@@ -168,11 +168,7 @@
 	/* If we have any exception handlers we must prepare to catch them.
 	 * We also need to catch if we are synchronised (so we can release it).
 	 */
-	vmExcept_setIntrpFrame(&mjbuf, 0, meth, mobj);
-	if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
-		mjbuf.prev = (VmExceptHandler*)unhand(tid)->exceptPtr;
-		unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)&mjbuf;
-	}
+	setupExceptionHandling(&mjbuf, meth, mobj, tid);
 
 	if (meth->exception_table != 0) {
 		if (JTHREAD_SETJMP(mjbuf.jbuf) != 0) {
@@ -235,9 +231,8 @@
 	if (mobj != 0) {
 		locks_internal_unlockMutex(&mobj->lock, &mjbuf, 0); 
 	}
-	if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
-		unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)mjbuf.prev;
-	}
+
+	cleanupExceptionHandling(&mjbuf, tid);
 
 RDBG(	dprintf("Returning from method %s%s.\n", meth->name->data, METHOD_SIGD(meth)); )
 }
@@ -290,4 +285,39 @@
 getEngine()
 {
 	return "kaffe.intr";
+}
+
+static inline void 
+setFrame(VmExceptHandler* eh,
+	 struct _methods* meth,
+	 struct Hjava_lang_Object* syncobj)
+{
+	assert(eh);
+	assert(meth);
+	
+	eh->meth = meth;
+	eh->frame.intrp.pc = 0;
+	eh->frame.intrp.syncobj = syncobj;
+}
+
+void
+setupExceptionHandling(VmExceptHandler* eh,
+		       struct _methods* meth,
+		       struct Hjava_lang_Object* syncobj,
+		       struct Hjava_lang_Thread* tid)
+{
+  setFrame(eh, meth, syncobj);
+  if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
+    eh->prev = (VmExceptHandler*)unhand(tid)->exceptPtr;
+    unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)eh;
+  }
+}
+
+void
+cleanupExceptionHandling(VmExceptHandler* eh,
+			 struct Hjava_lang_Thread* tid)
+{
+  if (tid != NULL && unhand(tid)->PrivateInfo != 0) {
+    unhand(tid)->exceptPtr = (struct Hkaffe_util_Ptr*)eh->prev;
+  }
 }
Index: kaffe/kaffe/kaffevm/intrp/machine.h
diff -u kaffe/kaffe/kaffevm/intrp/machine.h:1.8 kaffe/kaffe/kaffevm/intrp/machine.h:1.9
--- kaffe/kaffe/kaffevm/intrp/machine.h:1.8	Thu Aug 15 11:11:11 2002
+++ kaffe/kaffe/kaffevm/intrp/machine.h	Sun Sep 28 22:30:20 2003
@@ -110,5 +110,7 @@
 struct _slots;
 struct Hjava_lang_Thread;
 void virtualMachine(struct _methods*, struct _slots*, struct _slots*, struct Hjava_lang_Thread*);
+void setupExceptionHandling(VmExceptHandler* eh, struct _methods* meth, struct Hjava_lang_Object* syncobj, struct Hjava_lang_Thread* tid);
+void cleanupExceptionHandling(VmExceptHandler* eh, struct Hjava_lang_Thread* tid);
 
 #endif