* src/vm/jit/codegen-common.cpp (codegen_emit): New generic version of the
[cacao.git] / src / vm / jit / optimizing / profile.c
index 1f988b702a17348fb05af75bd0bdb7520f49452f..5268c8d75db6ab52a9f728ddef26b8b0e79c0672 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/optimizing/profile.c - runtime profiling
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -22,8 +20,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: profile.c 7952 2007-05-23 17:53:13Z twisti $
-
 */
 
 
 
 #include "vm/types.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
-#include "threads/threads-common.h"
+#include "threads/threadlist.hpp"
+#include "threads/thread.hpp"
 
-#include "vm/builtin.h"
-#include "vm/stringlocal.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/classcache.hpp"
+#include "vm/method.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
 
-#include "vm/jit/jit.h"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/methodheader.h"
-#include "vm/jit/optimizing/recompile.h"
+#include "vm/jit/methodtree.h"
 
-#include "vmcore/class.h"
-#include "vmcore/classcache.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
+#include "vm/jit/optimizing/recompiler.hpp"
 
 
 /* profile_init ****************************************************************
@@ -94,13 +92,13 @@ static void profile_thread(void)
                threads_sleep(0, nanos);
                runs++;
 
-               /* lock the threads lists */
-
-               threads_list_lock();
+               // Lock the thread lists.
+               ThreadList_lock();
 
+#if 0
                /* iterate over all started threads */
 
-               for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+               for (t = ThreadList_first(); t != NULL; t = ThreadList_next(t)) {
                        /* is this a Java thread? */
 
                        if (!(t->flags & THREAD_FLAG_JAVA))
@@ -115,9 +113,9 @@ static void profile_thread(void)
 
                        pc = t->pc;
 
-                       /* get the PV for the current PC */
+                       /* Get the PV for the current PC. */
 
-                       pv = codegen_get_pv_from_pc_nocheck(pc);
+                       pv = methodtree_find_nocheck(pc);
 
                        /* get methodinfo pointer from data segment */
 
@@ -150,16 +148,16 @@ static void profile_thread(void)
                                                        /* add this method to the method list and
                                                           start recompilation */
 
-                                                       recompile_queue_method(m);
+                                                       Recompiler_queue_method(m);
                                                }
                                        }
                                }
                        }
                }
+#endif
 
-               /* unlock the threads lists */
-
-               threads_list_unlock();
+               // Unlock the thread lists.
+               ThreadList_unlock();
        }
 }
 #endif
@@ -197,9 +195,6 @@ bool profile_start_thread(void)
 #if !defined(NDEBUG)
 void profile_printstats(void)
 {
-       list_t                 *l;
-       list_method_entry      *lme;
-       list_method_entry      *tlme;
        classinfo              *c;
        methodinfo             *m;
        codeinfo               *code;
@@ -214,9 +209,10 @@ void profile_printstats(void)
        frequency = 0;
        cycles    = 0;
 
+#if 0
        /* create new method list */
-
-       l = list_create(OFFSET(list_method_entry, linkage));
+       // TODO Use a sorted container.
+       List* l = List_new();
 
        /* iterate through all classes and methods */
 
@@ -247,15 +243,10 @@ void profile_printstats(void)
                                                frequency += code->frequency;
                                                cycles    += code->cycles;
 
-                                               /* create new list entry */
-
-                                               lme = NEW(list_method_entry);
-                                               lme->m = m;
-
                                                /* sort the new entry into the list */
                                                
-                                               if ((tlme = list_first(l)) == NULL) {
-                                                       list_add_first(l, lme);
+                                               if (List_empty(l) == NULL) {
+                                                       List_push_back(l, m);
                                                }
                                                else {
                                                        for (; tlme != NULL; tlme = list_next(l, tlme)) {
@@ -309,6 +300,7 @@ void profile_printstats(void)
                                           j, code->bbfrequency[j]);
                }
        }
+#endif
 
        printf("-----------           -------------- \n");
        printf("%10d             %12ld\n", frequency, (long) cycles);