* src/threads/native/threads.c (mainthreadobj): Removed.
authortwisti <none@none>
Mon, 7 May 2007 21:29:55 +0000 (21:29 +0000)
committertwisti <none@none>
Mon, 7 May 2007 21:29:55 +0000 (21:29 +0000)
* src/threads/native/threads.h (mainthreadobj): Likewise.

* src/vm/jit/optimizing/profile.c (threads/native/threads.h):
Likewise.
(profile_thread): Rewritten thread iteration.

src/threads/native/threads.c
src/threads/native/threads.h
src/vm/jit/optimizing/profile.c

index 42b3365ccc2a9ccd4df91691a51925f981456e84..f6560ce01c6fad9f2710ca4b71da7364348340c7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.c 7875 2007-05-07 11:35:30Z twisti $
+   $Id: threads.c 7885 2007-05-07 21:29:55Z twisti $
 
 */
 
@@ -216,9 +216,6 @@ static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos)
 /* GLOBAL VARIABLES                                                           */
 /******************************************************************************/
 
-/* the main thread                                                            */
-threadobject *mainthreadobj;
-
 static methodinfo *method_thread_init;
 
 /* the thread object of the current thread                                    */
index 805a0e8cfac5ae3150c48fcdaf1238033a6345f9..e66295c1555b40e84e09bfe758b4b2db758d06d7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.h 7830 2007-04-26 11:14:39Z twisti $
+   $Id: threads.h 7885 2007-05-07 21:29:55Z twisti $
 
 */
 
@@ -153,11 +153,6 @@ struct threadobject {
 #define STACKFRAMEINFO    (THREADOBJECT->_stackframeinfo)
 
 
-/* variables ******************************************************************/
-
-extern threadobject *mainthreadobj;
-
-
 /* functions ******************************************************************/
 
 void threads_sem_init(sem_t *sem, bool shared, int value);
index 09d18803687d0b2f74c28c979a4ac87fe0a0df2d..9f0a43bf9681f9dd09a76f3b94e053f0577c5a30 100644 (file)
@@ -38,8 +38,6 @@
 
 #include "threads/threads-common.h"
 
-#include "threads/native/threads.h"
-
 #include "vm/builtin.h"
 #include "vm/stringlocal.h"
 
@@ -96,66 +94,71 @@ static void profile_thread(void)
                threads_sleep(0, nanos);
                runs++;
 
-               /* iterate over all started threads */
+               /* lock the threads table */
 
-               t = mainthreadobj;
+               threads_table_lock();
 
-               do {
+               /* iterate over all started threads */
+
+               for (t = threads_table_first(); t != NULL; t = threads_table_next(t)) {
                        /* is this a Java thread? */
 
-                       if (t->flags & THREAD_FLAG_JAVA) {
-                               /* send SIGUSR2 to thread to get the current PC */
+                       if (!(t->flags & THREAD_FLAG_JAVA))
+                               continue;
 
-                               pthread_kill(t->tid, SIGUSR2);
+                       /* send SIGUSR2 to thread to get the current PC */
 
-                               /* the thread object now contains the current thread PC */
+                       pthread_kill(t->tid, SIGUSR2);
 
-                               pc = t->pc;
+                       /* the thread object now contains the current thread PC */
 
-                               /* get the PV for the current PC */
+                       pc = t->pc;
 
-                               pv = codegen_get_pv_from_pc_nocheck(pc);
+                       /* get the PV for the current PC */
 
-                               /* get methodinfo pointer from data segment */
+                       pv = codegen_get_pv_from_pc_nocheck(pc);
 
-                               if (pv == NULL) {
-                                       misses++;
-                               }
-                               else {
-                                       code = *((codeinfo **) (pv + CodeinfoPointer));
+                       /* get methodinfo pointer from data segment */
 
-                                       /* For asm_vm_call_method the codeinfo pointer is
-                                          NULL (which is also in the method tree). */
+                       if (pv == NULL) {
+                               misses++;
+                       }
+                       else {
+                               code = *((codeinfo **) (pv + CodeinfoPointer));
 
-                                       if (code != NULL) {
-                                               m = code->m;
+                               /* For asm_vm_call_method the codeinfo pointer is NULL
+                                  (which is also in the method tree). */
 
-                                               /* native methods are never recompiled */
+                               if (code != NULL) {
+                                       m = code->m;
 
-                                               if (!(m->flags & ACC_NATIVE)) {
-                                                       /* increase the method incovation counter */
+                                       /* native methods are never recompiled */
 
-                                                       code->frequency++;
-                                                       hits++;
+                                       if (!(m->flags & ACC_NATIVE)) {
+                                               /* increase the method incovation counter */
 
-                                                       if (code->frequency > 500) {
-                                                               /* clear frequency count before
-                                                                  recompilation */
+                                               code->frequency++;
+                                               hits++;
 
-                                                               code->frequency = 0;
+                                               if (code->frequency > 500) {
+                                                       /* clear frequency count before
+                                                          recompilation */
 
-                                                               /* add this method to the method list
-                                                                  and start recompilation */
+                                                       code->frequency = 0;
 
-                                                               recompile_queue_method(m);
-                                                       }
+                                                       /* add this method to the method list and
+                                                          start recompilation */
+
+                                                       recompile_queue_method(m);
                                                }
                                        }
                                }
                        }
+               }
+
+               /* unlock the threads table */
 
-                       t = t->next;
-               } while ((t != NULL) && (t != mainthreadobj));
+               threads_table_unlock();
        }
 }
 #endif