* src/vm/signal.c (signal_init): Added dummy allocation to install
authortwisti <none@none>
Fri, 20 Oct 2006 13:09:54 +0000 (13:09 +0000)
committertwisti <none@none>
Fri, 20 Oct 2006 13:09:54 +0000 (13:09 +0000)
Boehm's signal handlers.
* src/threads/native/threads.c (threads_preinit): Removed dummy
allocation.

* src/vm/vm.c (vm_create): Call threads_preinit before gc_init.
* src/cacaoh/cacaoh.c (main): Likewise.

src/cacaoh/cacaoh.c
src/threads/native/threads.c
src/vm/signal.c
src/vm/vm.c

index 03d4994a7d8a65593ae914b90d02a3bfbed02171..21fd436e8d5685c1be669524b9e5bab48e3024eb 100644 (file)
@@ -30,7 +30,7 @@
             Philipp Tomsich
             Christian Thalinger
 
-   $Id: cacaoh.c 5577 2006-09-29 10:38:58Z twisti $
+   $Id: cacaoh.c 5809 2006-10-20 13:09:54Z twisti $
 
 */
 
@@ -284,14 +284,17 @@ int main(int argc, char **argv)
                log_text("Java - header-generator started"); 
        }
        
-       /* initialize the garbage collector */
-
-       gc_init(heapmaxsize, heapstartsize);
-
 #if defined(ENABLE_THREADS)
+       /* pre-initialize some core thread stuff, like the stopworldlock,
+          thus this has to happen _before_ gc_init()!!! */
+
        threads_preinit();
 #endif
 
+       /* initialize the garbage collector */
+
+       gc_init(heapmaxsize, heapstartsize);
+
        /* initialize the string hashtable stuff: lock (must be done
           _after_ threads_preinit) */
 
index 64fb1f63a0708615a769039b6a6d61275993b018..316b36ec68960c88355ef6e6cb52a7991de8848d 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Christian Thalinger
                        Edwin Steiner
 
-   $Id: threads.c 5806 2006-10-19 10:10:23Z twisti $
+   $Id: threads.c 5809 2006-10-20 13:09:54Z twisti $
 
 */
 
@@ -682,6 +682,9 @@ threadobject *threads_get_current_threadobject(void)
 
    Do some early initialization of stuff required.
 
+   ATTENTION: Do NOT use any Java heap allocation here, as gc_init()
+   is called AFTER this function!
+
 *******************************************************************************/
 
 void threads_preinit(void)
@@ -699,13 +702,9 @@ void threads_preinit(void)
        pthread_mutex_init(&threadlistlock, NULL);
        pthread_mutex_init(&stopworldlock, NULL);
 
-       /* Allocate something so the garbage collector's signal handlers
-          are installed. */
-       heap_allocate(1, false, NULL);
-
        mainthreadobj = NEW(threadobject);
-       mainthreadobj->tid = pthread_self();
-       mainthreadobj->index = 1;
+       mainthreadobj->tid      = pthread_self();
+       mainthreadobj->index    = 1;
        mainthreadobj->thinlock = lock_pre_compute_thinlock(mainthreadobj->index);
        
 #if !defined(HAVE___THREAD)
index ac9b1b90750687e25181f9ece04a3988e9323c82..9831fc5ac41f52fff2b2c3f2fa4a62005dec64b6 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: signal.c 5806 2006-10-19 10:10:23Z twisti $
+   $Id: signal.c 5809 2006-10-20 13:09:54Z twisti $
 
 */
 
@@ -68,6 +68,11 @@ void signal_init(void)
 #if !defined(__CYGWIN__)
        struct sigaction act;
 
+       /* Allocate something so the garbage collector's signal handlers
+          are installed. */
+
+       (void) GCNEW(u1);
+
        /* install signal handlers we need to convert to exceptions */
 
        sigemptyset(&act.sa_mask);
index 5d3003641b5529c054fe0c7742109e5e415273d3..1c012c74eaa7bc2ceb9df6aa3046b0909b0de95a 100644 (file)
@@ -1285,6 +1285,13 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
        vm_initializing = true;
 
+#if defined(ENABLE_THREADS)
+       /* pre-initialize some core thread stuff, like the stopworldlock,
+          thus this has to happen _before_ gc_init()!!! */
+
+       threads_preinit();
+#endif
+
        /* initialize the garbage collector */
 
        gc_init(opt_heapmaxsize, opt_heapstartsize);
@@ -1298,10 +1305,6 @@ bool vm_create(JavaVMInitArgs *vm_args)
        }
 #endif
 
-#if defined(ENABLE_THREADS)
-       threads_preinit();
-#endif
-
        /* initialize the string hashtable stuff: lock (must be done
           _after_ threads_preinit) */