Null pointer exception working again on darwin
authorstefan <none@none>
Fri, 11 Jun 2004 11:34:49 +0000 (11:34 +0000)
committerstefan <none@none>
Fri, 11 Jun 2004 11:34:49 +0000 (11:34 +0000)
jit/powerpc/codegen.c
mm/boehm-gc/include/private/gc_priv.h
mm/boehm-gc/misc.c
mm/boehm-gc/os_dep.c
src/boehm-gc/include/private/gc_priv.h
src/boehm-gc/misc.c
src/boehm-gc/os_dep.c
src/vm/jit/powerpc/codegen.c

index 2c47d668b6dfbf7deb9c55d651bd18e52b08eb1c..8b3830600664c1c8e24a05c577e86510a7787eac 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Stefan Ring
 
-   $Id: codegen.c 1138 2004-06-05 20:39:49Z twisti $
+   $Id: codegen.c 1156 2004-06-11 11:34:49Z stefan $
 
 */
 
@@ -267,6 +267,7 @@ static int reg_of_var(stackptr v, int tempregnum)
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 void thread_restartcriticalsection(void *u)
 {
+       /* XXX set pc to restart address */
 }
 #endif
 
@@ -282,6 +283,9 @@ int cacao_catch_Handler(mach_port_t thread)
        mach_msg_type_number_t thread_state_count = PPC_THREAD_STATE_COUNT;
        ppc_thread_state_t thread_state;
        kern_return_t r;
+       
+       if (checknull)
+               return 0;
 
        r = thread_get_state(thread, flavor,
                (natural_t*)&thread_state, &thread_state_count);
@@ -299,6 +303,7 @@ int cacao_catch_Handler(mach_port_t thread)
 
                regs[REG_ITMP2_XPC] = crashpc;
                regs[REG_ITMP1_XPTR] = (u4) xptr;
+               thread_state.srr0 = (u4) asm_handle_exception;
 
                r = thread_set_state(thread, flavor,
                        (natural_t*)&thread_state, thread_state_count);
@@ -314,6 +319,7 @@ int cacao_catch_Handler(mach_port_t thread)
 
 void init_exceptions(void)
 {
+       GC_dirty_init(1);
 }
 
 void adjust_argvars(stackptr s, int d, int *fa, int *ia)
index ea2c684b088ccea8189a50cd725f117b5ac1ad8a..eecbb6321e13c563250e2df935ebf40582dd1f4a 100644 (file)
@@ -1758,7 +1758,7 @@ void GC_remove_protection GC_PROTO((struct hblk *h, word nblocks,
                        /* that it's not write protected by the virtual     */
                        /* dirty bit implementation.                        */
                        
-void GC_dirty_init GC_PROTO((void));
+void GC_dirty_init GC_PROTO((int gc_external));
   
 /* Slow/general mark bit manipulation: */
 GC_API GC_bool GC_is_marked GC_PROTO((ptr_t p));
index 814fa41ab2497189bc801856831b73833eae2313..f7d14b122d784bb593bbd23dbd55a39b91461500 100644 (file)
@@ -643,7 +643,7 @@ void GC_init_inner()
 #   endif
 #   ifdef GC_SOLARIS_THREADS
        /* We need dirty bits in order to find live stack sections.     */
-        GC_dirty_init();
+        GC_dirty_init(0);
 #   endif
 #   if !defined(THREADS) || defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \
        || defined(GC_SOLARIS_THREADS)
@@ -746,7 +746,7 @@ void GC_init_inner()
        GC_ASSERT(!GC_incremental);
         GC_setpagesize();
 #       ifndef GC_SOLARIS_THREADS
-          GC_dirty_init();
+          GC_dirty_init(0);
 #       endif
         GC_ASSERT(GC_words_allocd == 0)
        GC_incremental = TRUE;
@@ -790,7 +790,7 @@ void GC_enable_incremental GC_PROTO(())
     if (GC_no_win32_dlls) goto out;
 #   ifndef GC_SOLARIS_THREADS 
       maybe_install_looping_handler();  /* Before write fault handler! */
-      GC_dirty_init();
+      GC_dirty_init(0);
 #   endif
     if (!GC_is_initialized) {
         GC_init_inner();
index c70b678833d6e0d7ec9194b68b2aede269f20139..178e80fda7025ea99fbb7e82b854499dc0bd4303 100644 (file)
@@ -2027,7 +2027,7 @@ GC_bool GC_dirty_maintained = FALSE;
 /* written.                                                            */
 
 /* Initialize virtual dirty bit implementation.                        */
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
 #   ifdef PRINTSTATS
       GC_printf0("Initializing DEFAULT_VDB...\n");
@@ -2593,7 +2593,7 @@ GC_bool is_ptrfree;
 }
 
 #if !defined(DARWIN)
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
 #   if defined(SUNOS5SIGS) || defined(IRIX5) || defined(LINUX) || \
        defined(OSF1) || defined(HURD)
@@ -3009,7 +3009,7 @@ page_hash_table pht1, pht2;
 
 int GC_proc_fd;
 
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
     int fd;
     char buf[30];
@@ -3217,7 +3217,7 @@ PCR_VD_DB  GC_grungy_bits[NPAGES];
 ptr_t GC_vd_base;      /* Address corresponding to GC_grungy_bits[0]   */
                        /* HBLKSIZE aligned.                            */
 
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
     GC_dirty_maintained = TRUE;
     /* For the time being, we assume the heap generally grows up */
@@ -3535,13 +3535,14 @@ static void GC_darwin_sigbus(int num,siginfo_t *sip,void *context) {
 }
 #endif /* BROKEN_EXCEPTION_HANDLING */
 
-void GC_dirty_init() {
+void GC_dirty_init(int gc_external) {
     kern_return_t r;
     mach_port_t me;
     pthread_t thread;
     pthread_attr_t attr;
     exception_mask_t mask;
     
+       if (!gc_external) {
 #   ifdef PRINTSTATS
         GC_printf0("Inititalizing mach/darwin mprotect virtual dirty bit "
             "implementation\n");
@@ -3555,6 +3556,8 @@ void GC_dirty_init() {
         GC_err_printf0("Page size not multiple of HBLKSIZE\n");
         ABORT("Page size not multiple of HBLKSIZE");
     }
+
+       } else {
     
     GC_task_self = me = mach_task_self();
     
@@ -3620,6 +3623,7 @@ void GC_dirty_init() {
         }
     }
     #endif /* BROKEN_EXCEPTION_HANDLING  */
+       }
 }
  
 /* The source code for Apple's GDB was used as a reference for the exception
index ea2c684b088ccea8189a50cd725f117b5ac1ad8a..eecbb6321e13c563250e2df935ebf40582dd1f4a 100644 (file)
@@ -1758,7 +1758,7 @@ void GC_remove_protection GC_PROTO((struct hblk *h, word nblocks,
                        /* that it's not write protected by the virtual     */
                        /* dirty bit implementation.                        */
                        
-void GC_dirty_init GC_PROTO((void));
+void GC_dirty_init GC_PROTO((int gc_external));
   
 /* Slow/general mark bit manipulation: */
 GC_API GC_bool GC_is_marked GC_PROTO((ptr_t p));
index 814fa41ab2497189bc801856831b73833eae2313..f7d14b122d784bb593bbd23dbd55a39b91461500 100644 (file)
@@ -643,7 +643,7 @@ void GC_init_inner()
 #   endif
 #   ifdef GC_SOLARIS_THREADS
        /* We need dirty bits in order to find live stack sections.     */
-        GC_dirty_init();
+        GC_dirty_init(0);
 #   endif
 #   if !defined(THREADS) || defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \
        || defined(GC_SOLARIS_THREADS)
@@ -746,7 +746,7 @@ void GC_init_inner()
        GC_ASSERT(!GC_incremental);
         GC_setpagesize();
 #       ifndef GC_SOLARIS_THREADS
-          GC_dirty_init();
+          GC_dirty_init(0);
 #       endif
         GC_ASSERT(GC_words_allocd == 0)
        GC_incremental = TRUE;
@@ -790,7 +790,7 @@ void GC_enable_incremental GC_PROTO(())
     if (GC_no_win32_dlls) goto out;
 #   ifndef GC_SOLARIS_THREADS 
       maybe_install_looping_handler();  /* Before write fault handler! */
-      GC_dirty_init();
+      GC_dirty_init(0);
 #   endif
     if (!GC_is_initialized) {
         GC_init_inner();
index c70b678833d6e0d7ec9194b68b2aede269f20139..178e80fda7025ea99fbb7e82b854499dc0bd4303 100644 (file)
@@ -2027,7 +2027,7 @@ GC_bool GC_dirty_maintained = FALSE;
 /* written.                                                            */
 
 /* Initialize virtual dirty bit implementation.                        */
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
 #   ifdef PRINTSTATS
       GC_printf0("Initializing DEFAULT_VDB...\n");
@@ -2593,7 +2593,7 @@ GC_bool is_ptrfree;
 }
 
 #if !defined(DARWIN)
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
 #   if defined(SUNOS5SIGS) || defined(IRIX5) || defined(LINUX) || \
        defined(OSF1) || defined(HURD)
@@ -3009,7 +3009,7 @@ page_hash_table pht1, pht2;
 
 int GC_proc_fd;
 
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
     int fd;
     char buf[30];
@@ -3217,7 +3217,7 @@ PCR_VD_DB  GC_grungy_bits[NPAGES];
 ptr_t GC_vd_base;      /* Address corresponding to GC_grungy_bits[0]   */
                        /* HBLKSIZE aligned.                            */
 
-void GC_dirty_init()
+void GC_dirty_init(int gc_external)
 {
     GC_dirty_maintained = TRUE;
     /* For the time being, we assume the heap generally grows up */
@@ -3535,13 +3535,14 @@ static void GC_darwin_sigbus(int num,siginfo_t *sip,void *context) {
 }
 #endif /* BROKEN_EXCEPTION_HANDLING */
 
-void GC_dirty_init() {
+void GC_dirty_init(int gc_external) {
     kern_return_t r;
     mach_port_t me;
     pthread_t thread;
     pthread_attr_t attr;
     exception_mask_t mask;
     
+       if (!gc_external) {
 #   ifdef PRINTSTATS
         GC_printf0("Inititalizing mach/darwin mprotect virtual dirty bit "
             "implementation\n");
@@ -3555,6 +3556,8 @@ void GC_dirty_init() {
         GC_err_printf0("Page size not multiple of HBLKSIZE\n");
         ABORT("Page size not multiple of HBLKSIZE");
     }
+
+       } else {
     
     GC_task_self = me = mach_task_self();
     
@@ -3620,6 +3623,7 @@ void GC_dirty_init() {
         }
     }
     #endif /* BROKEN_EXCEPTION_HANDLING  */
+       }
 }
  
 /* The source code for Apple's GDB was used as a reference for the exception
index 2c47d668b6dfbf7deb9c55d651bd18e52b08eb1c..8b3830600664c1c8e24a05c577e86510a7787eac 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Stefan Ring
 
-   $Id: codegen.c 1138 2004-06-05 20:39:49Z twisti $
+   $Id: codegen.c 1156 2004-06-11 11:34:49Z stefan $
 
 */
 
@@ -267,6 +267,7 @@ static int reg_of_var(stackptr v, int tempregnum)
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 void thread_restartcriticalsection(void *u)
 {
+       /* XXX set pc to restart address */
 }
 #endif
 
@@ -282,6 +283,9 @@ int cacao_catch_Handler(mach_port_t thread)
        mach_msg_type_number_t thread_state_count = PPC_THREAD_STATE_COUNT;
        ppc_thread_state_t thread_state;
        kern_return_t r;
+       
+       if (checknull)
+               return 0;
 
        r = thread_get_state(thread, flavor,
                (natural_t*)&thread_state, &thread_state_count);
@@ -299,6 +303,7 @@ int cacao_catch_Handler(mach_port_t thread)
 
                regs[REG_ITMP2_XPC] = crashpc;
                regs[REG_ITMP1_XPTR] = (u4) xptr;
+               thread_state.srr0 = (u4) asm_handle_exception;
 
                r = thread_set_state(thread, flavor,
                        (natural_t*)&thread_state, thread_state_count);
@@ -314,6 +319,7 @@ int cacao_catch_Handler(mach_port_t thread)
 
 void init_exceptions(void)
 {
+       GC_dirty_init(1);
 }
 
 void adjust_argvars(stackptr s, int d, int *fa, int *ia)