[kaffe] CVS kaffe (guilhem): Fixlets for Darwin.

Kaffe CVS cvs-commits at kaffe.org
Sat Feb 5 13:21:23 PST 2005


PatchSet 5474 
Date: 2005/02/05 21:15:39
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fixlets for Darwin.

        * kaffe/kaffevm/systems/unix-pthreads/signal.c
        (nullException): Better handling of stack overflows though we
        would need a stack switch here.

        * kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
        (jthread_exit): Awake the first thread and exits there.

        * test/regression/SystemLoaderTest.java
        (l, k): Use another name to avoid conflicts with ArrayForName.

        * test/regression/WaitTest.java: Synchronize then start the thread
        to be sure the notification is sent after the first thread is
        going into wait.

Members: 
	kaffe/kaffevm/systems/unix-pthreads/signal.c:1.18->1.19 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.69->1.70 
	test/regression/SystemLoaderTest.java:1.1->1.2 
	test/regression/WaitTest.java:1.1->1.2 

Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/signal.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/signal.c:1.18 kaffe/kaffe/kaffevm/systems/unix-pthreads/signal.c:1.19
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/signal.c:1.18	Sat Jan  1 09:03:50 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/signal.c	Sat Feb  5 21:15:39 2005
@@ -105,10 +105,17 @@
 #if defined(STACK_POINTER)
 	current_thread = jthread_current();
 	stackptr = (void *)STACK_POINTER(GET_SIGNAL_CONTEXT_POINTER(ctx));
+	/* Here we have a stupid heuristic which may not work rightfully
+	 * if kaffe allocates a big buffer using alloca (in that case we
+	 * will get an NPE). But it is better than the previous case which was
+	 * heating nearly all NPEs on Darwin.
+	 */
 #if defined(STACK_GROWS_UP)
-	if (current_thread != NULL && stackptr >= current_thread->stackMax)
+	if (current_thread != NULL && stackptr >= current_thread->stackMax &&
+	    stackptr <= (void *)((uintp)current_thread->stackMax+1024))
 #else
-	if (current_thread != NULL && stackptr <= current_thread->stackMin)
+	if (current_thread != NULL && stackptr <= current_thread->stackMin &&
+	    stackptr >= (void *)((uintp)current_thread->stackMax-1024))
 #endif
 	  stackOverflowHandler(EXCEPTIONFRAMEPTR);
 	else
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.69 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.70
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.69	Sat Feb  5 19:42:12 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	Sat Feb  5 21:15:40 2005
@@ -1068,6 +1068,7 @@
 	  if ( (cur != firstThread) && (firstThread->active == 0) ) {
 		/* if the firstThread has already been frozen, it's not in the cache list */
 		pthread_cancel( firstThread->tid);
+		repsem_post (&firstThread->sem);
 	  }
 
 	  unprotectThreadList(cur);
@@ -1102,6 +1103,11 @@
 	 * linux-threads "feature")
 	 */
 	repsem_wait( &cur->sem);
+
+	/* We put here a safe-guard in case the pthread_cancel has not managed
+	 * to do its job and that repsem_wait awakes.
+	 */
+	pthread_exit(NULL);
   }
   else {
 	/* flag that we soon will get a new cache entry (would be annoying to
Index: kaffe/test/regression/SystemLoaderTest.java
diff -u kaffe/test/regression/SystemLoaderTest.java:1.1 kaffe/test/regression/SystemLoaderTest.java:1.2
--- kaffe/test/regression/SystemLoaderTest.java:1.1	Wed Aug 30 19:38:13 2000
+++ kaffe/test/regression/SystemLoaderTest.java	Sat Feb  5 21:15:41 2005
@@ -2,22 +2,22 @@
  * Check that our system class loader doesn't initialize classes too early
  */
 
-class l {
+class SLTest_class1 {
 	static {
-		System.out.println("l.init invoked");
+		System.out.println("SLTest_class1.init invoked");
 	}
 }
 
-class k extends l {
+class SLTest_class2 extends SLTest_class1 {
 	static {
-		System.out.println("k.init invoked");
+		System.out.println("SLTest_class2.init invoked");
 	}
 }
 
 public class SystemLoaderTest extends ClassLoader {
 
     public static void main(String []av) throws Exception {
-	Class c = new SystemLoaderTest().loadClass("k");
+	Class c = new SystemLoaderTest().loadClass("SLTest_class2");
 	System.out.println("LOADED");
 	c.newInstance();
 	System.out.println("DONE");
@@ -26,8 +26,8 @@
 
 /* Expected Output:
 LOADED
-l.init invoked
-k.init invoked
+SLTest_class1.init invoked
+SLTest_class2.init invoked
 DONE
 */
 
Index: kaffe/test/regression/WaitTest.java
diff -u kaffe/test/regression/WaitTest.java:1.1 kaffe/test/regression/WaitTest.java:1.2
--- kaffe/test/regression/WaitTest.java:1.1	Fri Feb 21 09:51:11 2003
+++ kaffe/test/regression/WaitTest.java	Sat Feb  5 21:15:41 2005
@@ -45,11 +45,12 @@
 	    }
 	}
 
-	new Thread(new WaitTest(waiter)).start();
 	synchronized( waiter )
 	{
 	    final long time = 500;
 	    
+	    new Thread(new WaitTest(waiter)).start();
+
 	    start = System.currentTimeMillis();
 	    waiter.wait(Long.MAX_VALUE);
 	    end = System.currentTimeMillis();




More information about the kaffe mailing list