[kaffe] CVS kaffe (guilhem): Fix for Gump / JNI References fix.

Kaffe CVS cvs-commits at kaffe.org
Sat Feb 5 09:16:31 PST 2005


PatchSet 5975 
Date: 2005/02/05 17:12:07
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fix for Gump / JNI References fix.

        * kaffe/kaffevm/jni/jni.c
        (Kaffe_ExceptionOccured): Do not add the exception to the local
        reference pool if it is NULL.
        (KaffeJNI_EnsureLocalCapacity): Ensure the local JNI frame has
        sufficient capacity.
        (KaffeJNI_addJNIref): Call FatalError with a right JNI
        environment.

        * kaffe/kaffe/main.c
        (checkException): Delete the local reference to the retrieved
        exception.

        * libraries/clib/native/UNIXProcess.c
        (forkAndExec): Delete local references to the elements in the
        array.

        * kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:
        Removed spurious jthread_get_stack_limits.

Members: 
	kaffe/kaffe/main.c:1.75->1.76 
	kaffe/kaffevm/jni/jni.c:1.17->1.18 
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.32->1.33 
	libraries/clib/native/UNIXProcess.c:1.31->1.32 

Index: kaffe/kaffe/kaffe/main.c
diff -u kaffe/kaffe/kaffe/main.c:1.75 kaffe/kaffe/kaffe/main.c:1.76
--- kaffe/kaffe/kaffe/main.c:1.75	Wed Feb  2 13:03:02 2005
+++ kaffe/kaffe/kaffe/main.c	Sat Feb  5 17:12:07 2005
@@ -326,6 +326,7 @@
 	/* Display exception stack trace */
 	if ((e = (*global_env)->ExceptionOccurred(global_env)) == NULL)
 		return (0);
+	(*global_env)->DeleteLocalRef(global_env, e);
 	(*global_env)->ExceptionDescribe(global_env);
 	(*global_env)->ExceptionClear(global_env);
 
Index: kaffe/kaffe/kaffevm/jni/jni.c
diff -u kaffe/kaffe/kaffevm/jni/jni.c:1.17 kaffe/kaffe/kaffevm/jni/jni.c:1.18
--- kaffe/kaffe/kaffevm/jni/jni.c:1.17	Fri Feb  4 10:36:15 2005
+++ kaffe/kaffe/kaffevm/jni/jni.c	Sat Feb  5 17:12:07 2005
@@ -61,7 +61,7 @@
 	table = THREAD_DATA()->jnireferences;
 
 	if (table->used == table->frameSize) {
-	  Kaffe_FatalError(NULL, "No more room for local references");
+	  Kaffe_FatalError(THREAD_DATA()->jniEnv, "No more room for local references");
 	}
 
 	idx = table->next;
@@ -105,7 +105,7 @@
 Kaffe_FatalError(JNIEnv* env UNUSED, const char* mess)
 {
 	kprintf(stderr, "FATAL ERROR: %s\n", mess);
-	exit(1);
+	exit(-1);
 }
 
 static void
@@ -181,14 +181,6 @@
 }
 
 static jint
-KaffeJNI_EnsureLocalCapacity(JNIEnv* env UNUSED, jint capacity)
-{
-  BEGIN_EXCEPTION_HANDLING(-1);
-
-  END_EXCEPTION_HANDLING();
-}
-
-static jint
 KaffeJNI_PushLocalFrame(JNIEnv* env UNUSED, jint capacity)
 {
   jnirefs *table;
@@ -220,6 +212,22 @@
   return 0;
 }
 
+static jint
+KaffeJNI_EnsureLocalCapacity(JNIEnv* env, jint capacity)
+{
+  jint ret;
+
+  BEGIN_EXCEPTION_HANDLING(-1);
+
+  if (thread_data->jnireferences->used+capacity > 
+      thread_data->jnireferences->frameSize)
+    ret = KaffeJNI_PushLocalFrame(env, capacity);
+
+  END_EXCEPTION_HANDLING();
+
+  return ret;
+}
+
 static jobject
 KaffeJNI_PopLocalFrame(JNIEnv* env UNUSED, jobject obj)
 {
@@ -404,7 +412,8 @@
 
 	obj = thread_data->exceptObj;
 
-	ADD_REF(obj);
+	if (obj != NULL)
+	  ADD_REF(obj);
 	END_EXCEPTION_HANDLING();
 	return (obj);
 }
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.32 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.33
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.32	Sun Jan 30 12:42:44 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h	Sat Feb  5 17:12:08 2005
@@ -257,13 +257,6 @@
 #endif
 }
 
-static inline
-void jthread_get_stack_limits(jthread_t t, void **smin, void **smax)
-{
-	*smin = t->stackMin;
-	*smax = t->stackMax;
-}
-
 /*
  * Get the current stack limit.
  */
Index: kaffe/libraries/clib/native/UNIXProcess.c
diff -u kaffe/libraries/clib/native/UNIXProcess.c:1.31 kaffe/libraries/clib/native/UNIXProcess.c:1.32
--- kaffe/libraries/clib/native/UNIXProcess.c:1.31	Tue Jul  6 17:16:28 2004
+++ kaffe/libraries/clib/native/UNIXProcess.c	Sat Feb  5 17:12:08 2005
@@ -139,6 +139,7 @@
 	  strcpy(argv[i], argichars);
 	}
       (*env)->ReleaseStringUTFChars(env, argi, argichars);
+      (*env)->DeleteLocalRef(env, argi);
 
       if (!argv[i])
 	{
@@ -177,6 +178,7 @@
 	  strcpy(arge[i], envichars);
 	}
       (*env)->ReleaseStringUTFChars(env, envi, envichars);
+      (*env)->DeleteLocalRef(env, envi);
       if (!arge[i])
 	{
 	  errorInfo info;



More information about the kaffe mailing list