* src/vm/jit/optimizing/profile.c: Added.
authortwisti <none@none>
Tue, 31 Oct 2006 20:11:28 +0000 (20:11 +0000)
committertwisti <none@none>
Tue, 31 Oct 2006 20:11:28 +0000 (20:11 +0000)
* src/vm/jit/optimizing/profile.h: Likewise.
* src/vm/jit/optimizing/recompile.c: Likewise.
* src/vm/jit/optimizing/recompile.h: Likewise.

* src/vm/jit/optimizing/Makefile.am (INCLUDES): Added OS_DIR.
(PROFILE_SOURCES): Added.
(RECOMPILE_SOURCES): Added.
(SSA_SOURCES): Added.

* src/vm/jit/recompile.c: Removed.
* src/vm/jit/recompile.h: Likewise.
* src/vm/jit/profile: Likewise.

* src/vm/jit/Makefile.am (SUBDIRS): Added optimizing.
(PROFILE_LIB): Removed.
(RECOMPILE_SOURCES): Likewise.

* src/cacao/Makefile.am (GC_LIB): Removed.

* src/mm/Makefile.am (DIST_DUBDIRS): Added boehm-gc.
(GC_LIB): Added.

* src/Makefile.am (DIST_SUBDIRS): Removed boehm-gc.
(SUBDIRS): Likewise.
(BOEHM): Removed.

* src/threads/native/threads.c (boehm-gc/include/gc.h): Changed to
mm/boehm-gc/include/gc.h.

* src/cacaoh/Makefile.am (GC_LIB): Removed.

* configure.ac (AC_CONFIG_FILES): Removed src/vm/jit/profile/Makefile.
(AC_CONFIG_SUBDIRS): Changed src/boehm-gc to src/mm/boehm-gc.
* autogen.sh: Changed path to boehm-gc.

--HG--
rename : src/vm/jit/profile/profile.c => src/vm/jit/optimizing/profile.c
rename : src/vm/jit/profile/profile.h => src/vm/jit/optimizing/profile.h
rename : src/vm/jit/recompile.c => src/vm/jit/optimizing/recompile.c
rename : src/vm/jit/recompile.h => src/vm/jit/optimizing/recompile.h

19 files changed:
autogen.sh
configure.ac
src/Makefile.am
src/cacao/Makefile.am
src/cacaoh/Makefile.am
src/mm/Makefile.am
src/threads/native/threads.c
src/vm/jit/Makefile.am
src/vm/jit/optimizing/Makefile.am
src/vm/jit/optimizing/profile.c [new file with mode: 0644]
src/vm/jit/optimizing/profile.h [new file with mode: 0644]
src/vm/jit/optimizing/recompile.c [new file with mode: 0644]
src/vm/jit/optimizing/recompile.h [new file with mode: 0644]
src/vm/jit/profile/.cvsignore [deleted file]
src/vm/jit/profile/Makefile.am [deleted file]
src/vm/jit/profile/profile.c [deleted file]
src/vm/jit/profile/profile.h [deleted file]
src/vm/jit/recompile.c [deleted file]
src/vm/jit/recompile.h [deleted file]

index 21e7bc51760e3c65fdef7e88b70f30e37526bf7b..bc112236be1b7d10704a4eb44d20086b09aeb27f 100755 (executable)
@@ -136,4 +136,4 @@ export CACAO_AUTOHEADER
 export CACAO_AUTOMAKE
 export CACAO_AUTOCONF
 
-cd src/boehm-gc && ./autogen.sh && cd ../..
+cd src/mm/boehm-gc && ./autogen.sh && cd ../..
index e28cf255323f84c6a763908d82fb4142d344b7f5..41e2eba31361d855ac82806a3a3a0182fc6acfb4 100644 (file)
@@ -888,7 +888,6 @@ AC_CONFIG_FILES([Makefile]
                [src/vm/jit/powerpc/netbsd/Makefile]
                [src/vm/jit/powerpc64/Makefile]
                [src/vm/jit/powerpc64/linux/Makefile]
-               [src/vm/jit/profile/Makefile]
                [src/vm/jit/schedule/Makefile]
                [src/vm/jit/sparc64/Makefile]
                [src/vm/jit/sparc64/linux/Makefile]
@@ -905,7 +904,7 @@ AC_CONFIG_FILES([Makefile]
 dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
 export OPT_CFLAGS
 export ARCH_CFLAGS
-AC_CONFIG_SUBDIRS(src/boehm-gc)
+AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
 
 
 AC_OUTPUT
index 70577a975aa4187c374319a5b42b9bfc02e179c1..50883b51b6c17a4f3d8a8b17ff86cd1f94976795 100644 (file)
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $
+## $Id: Makefile.am 5884 2006-10-31 20:11:28Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
 DIST_SUBDIRS = \
-       boehm-gc \
        lib \
        fdlibm \
        mm \
@@ -45,16 +44,9 @@ DIST_SUBDIRS = \
        cacao \
        scripts
 
-if DISABLE_GC
-BOEHM =
-else
-BOEHM = boehm-gc
-endif
-
 # Keep this order!!!
 
 SUBDIRS = \
-       $(BOEHM) \
        lib \
        fdlibm \
        mm \
index a35d863b3367cc220165025b827c70a13457fffa..51c3f728ae7c648a6960a8b98bebe9576fa2b945 100644 (file)
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 5579 2006-09-29 11:37:12Z twisti $
+## $Id: Makefile.am 5884 2006-10-31 20:11:28Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
 
-if DISABLE_GC
-GC_LIB =
-else
-GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la
-endif
-
 if ENABLE_THREADS
-THREAD_LIB = $(top_builddir)/src/threads/native/libthreads.la
+THREAD_LIB = \
+       $(top_builddir)/src/threads/native/libthreads.la
 endif
 
 if ENABLE_STATICVM
index 7649ad83f0387bd4f77e9eb682e92613dad95db1..85b18f932c9c4e596363465d32553fffc8ac7df9 100644 (file)
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4921 2006-05-15 14:24:36Z twisti $
+## $Id: Makefile.am 5884 2006-10-31 20:11:28Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
 
-if DISABLE_GC
-GC_LIB =
-else
-GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la
-endif
-
 if ENABLE_THREADS
-THREAD_LIB = $(top_builddir)/src/threads/native/libthreads.la
+THREAD_LIB = \
+       $(top_builddir)/src/threads/native/libthreads.la
 endif
 
 if ENABLE_RT_TIMING
 cacaoh_LDFLAGS = -lrt
 endif
 
-noinst_LTLIBRARIES = libcacaoh.la
+noinst_LTLIBRARIES = \
+       libcacaoh.la
 
 libcacaoh_la_SOURCES = \
        headers.c \
index f43b5c12584eb50bb9a762792037eaa2467afa1c..ac7c5d20fc73d5fc62209105ed923f69d790e907 100644 (file)
@@ -28,7 +28,7 @@
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4627 2006-03-16 12:53:32Z twisti $
+## $Id: Makefile.am 5884 2006-10-31 20:11:28Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -36,13 +36,25 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top
 
 LIBS =
 
+DIST_SUBDIRS = \
+       boehm-gc
+
 if DISABLE_GC
-GC_FILE = nogc.c
+GC_FILE = \
+       nogc.c
 else
-GC_FILE = boehm.c
+SUBDIRS = \
+       boehm-gc
+
+GC_FILE = \
+       boehm.c
+
+GC_LIB = \
+       $(top_builddir)/src/mm/boehm-gc/libgc.la
 endif
 
-noinst_LTLIBRARIES = libmm.la
+noinst_LTLIBRARIES = \
+       libmm.la
 
 libmm_la_SOURCES = \
        $(GC_FILE) \
@@ -50,6 +62,9 @@ libmm_la_SOURCES = \
        memory.c \
        memory.h
 
+libmm_la_LIBADD = \
+       $(GC_LIB)
+
 
 ## Local variables:
 ## mode: Makefile
index 1c1284a0caaaf4da1a5ab0b618627bebaaac1946..e68b5a792cb8d3e94d2cd9039e7f3d105631c259 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Christian Thalinger
                        Edwin Steiner
 
-   $Id: threads.c 5870 2006-10-30 12:27:59Z twisti $
+   $Id: threads.c 5884 2006-10-31 20:11:28Z twisti $
 
 */
 
@@ -87,7 +87,7 @@
 #  define GC_IRIX_THREADS
 # endif
 # include <semaphore.h>
-# include "boehm-gc/include/gc.h"
+# include "mm/boehm-gc/include/gc.h"
 #endif
 
 #if defined(ENABLE_JVMTI)
index cd8d3df1d9883feebc2d4432cd732f0aa59b0dfe..13974da4a0521764f1eaa4f8637f06e43658be8e 100644 (file)
@@ -28,7 +28,7 @@
 ##
 ## Changes: Edwin Steiner
 ##
-## $Id: Makefile.am 5814 2006-10-20 14:53:27Z twisti $
+## $Id: Makefile.am 5884 2006-10-31 20:11:28Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -42,7 +42,6 @@ DIST_SUBDIRS = \
        inline \
        loop \
        optimizing \
-       profile \
        schedule \
        tools \
        verify \
@@ -57,6 +56,7 @@ DIST_SUBDIRS = \
        x86_64
 
 SUBDIRS = \
+       optimizing \
        tools \
        verify
 
@@ -67,6 +67,9 @@ SUBDIRS += \
 
 ARCH_LIB = \
        $(ARCH_DIR)/libarch.la
+
+OPTIMIZING_LIB = \
+       optimizing/liboptimizing.la
 endif
 
 if ENABLE_INTRP
@@ -101,14 +104,6 @@ LOOP_LIB = \
        loop/libloop.la
 endif
 
-if ENABLE_PROFILING
-SUBDIRS += \
-       profile
-
-PROFILE_LIB = \
-       profile/libprofile.la
-endif
-
 if USE_SCHEDULER
 SUBDIRS += \
        schedule
@@ -117,20 +112,6 @@ SCHEDULE_LIB = \
        schedule/libschedule.la
 endif
 
-if ENABLE_SSA
-SUBDIRS += \
-       optimizing
-
-OPTIMIZING_LIB = \
-       optimizing/liboptimizing.la
-endif
-
-if ENABLE_THREADS
-RECOMPILE_SOURCES = \
-       recompile.c \
-       recompile.h
-endif
-
 if ENABLE_JIT
 REG_SOURCES = \
        reg.c \
index 85d351282ebbf8a3b33a4180961750376a5c26c0..0ceb201aabe4e35ba97e8e177bf32b6ac6e4352e 100644 (file)
@@ -1,6 +1,6 @@
 ## src/vm/jit/loop/Makefile.am
 ##
-## Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+## Copyright (C) 1996-2005, 2006 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,
 ## Institut f. Computersprachen - TU Wien
 
 ## Process this file with automake to produce Makefile.in
 
-INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit -I$(top_srcdir)/src/vm/jit/@ARCH_DIR@
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
 
-noinst_LTLIBRARIES = liboptimizing.la
+if ENABLE_PROFILING
+PROFILE_SOURCES = \
+       profile.c \
+       profile.h
+endif
 
-liboptimizing_la_SOURCES = \
+if ENABLE_THREADS
+RECOMPILE_SOURCES = \
+       recompile.c \
+       recompile.h
+endif
+
+if ENABLE_SSA
+SSA_SOURCES = \
        lsra.c \
        lsra.h \
        ssa.c \
@@ -47,6 +58,15 @@ liboptimizing_la_SOURCES = \
        dominators.h \
        lifetimes.c \
        lifetimes.h
+endif
+
+noinst_LTLIBRARIES = \
+       liboptimizing.la
+
+liboptimizing_la_SOURCES = \
+       $(PROFILE_SOURCES) \
+       $(RECOMPILE_SOURCES) \
+       $(SSA_SOURCES)
 
 
 ## Local variables:
diff --git a/src/vm/jit/optimizing/profile.c b/src/vm/jit/optimizing/profile.c
new file mode 100644 (file)
index 0000000..cf5771c
--- /dev/null
@@ -0,0 +1,360 @@
+/* src/vm/jit/optimizing/profile.c - runtime profiling
+
+   Copyright (C) 1996-2005, 2006 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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+#include "native/jni.h"
+#include "native/include/java_lang_Thread.h"
+#include "native/include/java_lang_VMThread.h"
+
+#if defined(ENABLE_THREADS)
+# include "threads/native/threads.h"
+#endif
+
+#include "vm/builtin.h"
+#include "vm/class.h"
+#include "vm/classcache.h"
+#include "vm/method.h"
+#include "vm/options.h"
+#include "vm/stringlocal.h"
+#include "vm/jit/jit.h"
+#include "vm/jit/methodheader.h"
+#include "vm/jit/optimizing/recompile.h"
+
+
+/* global variables ***********************************************************/
+
+#if defined(ENABLE_THREADS)
+static java_lang_VMThread *profile_vmthread;
+#endif
+
+
+/* profile_init ****************************************************************
+
+   Initializes the profile global lock.
+
+*******************************************************************************/
+
+bool profile_init(void)
+{
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* profile_thread **************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+static s4 runs = 0;
+static s4 hits = 0;
+static s4 misses = 0;
+
+#if defined(ENABLE_THREADS)
+static void profile_thread(void)
+{
+       threadobject *t;
+       s4            nanos;
+       u1           *pc;
+       u1           *pv;
+       methodinfo   *m;
+       codeinfo     *code;
+
+       while (true) {
+               /* sleep thread for 0.5-1.0 ms */
+
+               nanos = 500 + (int) (500.0 * (rand() / (RAND_MAX + 1.0)));
+/*             fprintf(stderr, "%d\n", nanos); */
+
+               threads_sleep(0, nanos);
+               runs++;
+
+               /* iterate over all started threads */
+
+               t = mainthreadobj;
+
+               do {
+                       /* is this a Java thread? */
+
+                       if (t->flags & THREAD_FLAG_JAVA) {
+                               /* send SIGUSR2 to thread to get the current PC */
+
+                               pthread_kill(t->tid, SIGUSR2);
+
+                               /* the thread object now contains the current thread PC */
+
+                               pc = t->pc;
+
+                               /* get the PV for the current PC */
+
+                               pv = codegen_get_pv_from_pc_nocheck(pc);
+
+                               /* get methodinfo pointer from data segment */
+
+                               if (pv == NULL) {
+                                       misses++;
+                               }
+                               else {
+                                       code = *((codeinfo **) (pv + CodeinfoPointer));
+
+                                       /* For asm_vm_call_method the codeinfo pointer is
+                                          NULL (which is also in the method tree). */
+
+                                       if (code != NULL) {
+                                               m = code->m;
+
+                                               /* native methods are never recompiled */
+
+                                               if (!(m->flags & ACC_NATIVE)) {
+                                                       /* increase the method incovation counter */
+
+                                                       code->frequency++;
+                                                       hits++;
+
+                                                       if (code->frequency > 500) {
+                                                               /* clear frequency count before
+                                                                  recompilation */
+
+                                                               code->frequency = 0;
+
+                                                               /* add this method to the method list
+                                                                  and start recompilation */
+
+                                                               recompile_queue_method(m);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
+                       t = t->next;
+               } while ((t != NULL) && (t != mainthreadobj));
+       }
+}
+#endif
+
+
+/* profile_start_thread ********************************************************
+
+   Starts the profile sampling thread.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS)
+bool profile_start_thread(void)
+{
+       java_lang_Thread *t;
+
+       /* create the profile object */
+
+       profile_vmthread =
+               (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
+
+       if (profile_vmthread == NULL)
+               return false;
+
+       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
+
+       t->vmThread = profile_vmthread;
+       t->name     = javastring_new_from_ascii("Profiling Sampler");
+       t->daemon   = true;
+       t->priority = 5;
+
+       profile_vmthread->thread = t;
+
+       /* actually start the profile sampling thread */
+
+       threads_start_thread(t, profile_thread);
+
+       /* everything's ok */
+
+       return true;
+}
+#endif
+
+
+/* profile_printstats **********************************************************
+
+   Prints profiling statistics gathered during runtime.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void profile_printstats(void)
+{
+       list                   *l;
+       list_method_entry      *lme;
+       list_method_entry      *tlme;
+       classinfo              *c;
+       methodinfo             *m;
+       codeinfo               *code;
+       u4                      slot;
+       classcache_name_entry  *nmen;
+       classcache_class_entry *clsen;
+       s4                      i;
+       s4                      j;
+       u4                      frequency;
+       s8                      cycles;
+
+       frequency = 0;
+       cycles    = 0;
+
+       /* create new method list */
+
+       l = list_create(OFFSET(list_method_entry, linkage));
+
+       /* iterate through all classes and methods */
+
+       for (slot = 0; slot < hashtable_classcache.size; slot++) {
+               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+
+               for (; nmen; nmen = nmen->hashlink) {
+                       /* iterate over all class entries */
+
+                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
+                               c = clsen->classobj;
+
+                               if (c == NULL)
+                                       continue;
+
+                               /* interate over all class methods */
+
+                               for (i = 0; i < c->methodscount; i++) {
+                                       m = &(c->methods[i]);
+
+                                       code = m->code;
+
+                                       /* was this method actually called? */
+
+                                       if ((code != NULL) && (code->frequency > 0)) {
+                                               /* add to overall stats */
+
+                                               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);
+                                               }
+                                               else {
+                                                       for (; tlme != NULL; tlme = list_next(l, tlme)) {
+                                                               /* check the frequency */
+
+                                                               if (code->frequency > tlme->m->code->frequency) {
+                                                                       list_add_before(l, tlme, lme);
+                                                                       break;
+                                                               }
+                                                       }
+
+                                                       /* if we are at the end of the list, add
+                                                          it as last entry */
+
+                                                       if (tlme == NULL)
+                                                               list_add_last(l, lme);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* print all methods sorted */
+
+       printf(" frequency     ratio         cycles     ratio   method name\n");
+       printf("----------- --------- -------------- --------- -------------\n");
+
+       /* now iterate through the list and print it */
+
+       for (lme = list_first(l); lme != NULL; lme = list_next(l, lme)) {
+               /* get method of the list element */
+
+               m = lme->m;
+
+               code = m->code;
+
+               printf("%10d   %.5f   %12ld   %.5f   ",
+                          code->frequency,
+                          (double) code->frequency / (double) frequency,
+                          (long) code->cycles,
+                          (double) code->cycles / (double) cycles);
+
+               method_println(m);
+
+               /* print basic block frequencies */
+
+               if (opt_prof_bb) {
+                       for (j = 0; j < code->basicblockcount; j++)
+                               printf("                                                    L%03d: %10d\n",
+                                          j, code->bbfrequency[j]);
+               }
+       }
+
+       printf("-----------           -------------- \n");
+       printf("%10d             %12ld\n", frequency, (long) cycles);
+
+       printf("\nruns  : %10d\n", runs);
+       printf("hits  : %10d\n", hits);
+       printf("misses: %10d\n", misses);
+}
+#endif /* !defined(NDEBUG) */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/optimizing/profile.h b/src/vm/jit/optimizing/profile.h
new file mode 100644 (file)
index 0000000..ee427a8
--- /dev/null
@@ -0,0 +1,68 @@
+/* src/vm/jit/profile.h - runtime profiling
+
+   Copyright (C) 1996-2005, 2006 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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#ifndef _PROFILE_H
+#define _PROFILE_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+
+/* function prototypes ********************************************************/
+
+bool profile_init(void);
+bool profile_start_thread(void);
+
+#if !defined(NDEBUG)
+void profile_printstats(void);
+#endif
+
+#endif /* _PROFILE_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/optimizing/recompile.c b/src/vm/jit/optimizing/recompile.c
new file mode 100644 (file)
index 0000000..5ada79b
--- /dev/null
@@ -0,0 +1,295 @@
+/* src/vm/jit/optimizing/recompile.c - recompilation system
+
+   Copyright (C) 1996-2005, 2006 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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+#include "native/jni.h"
+#include "native/include/java_lang_Thread.h"
+#include "native/include/java_lang_VMThread.h"
+
+#if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
+# include "threads/native/threads.h"
+#endif
+
+#include "toolbox/list.h"
+#include "vm/builtin.h"
+#include "vm/classcache.h"
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+#include "vm/jit/optimizing/recompile.h"
+
+
+/* global variables ***********************************************************/
+
+static java_lang_VMThread *recompile_vmthread;
+static java_objectheader *lock_recompile_thread;
+static list *list_recompile_methods;
+
+
+/* recompile_init **************************************************************
+
+   Initializes the recompilation system.
+
+*******************************************************************************/
+
+bool recompile_init(void)
+{
+       /* initialize the recompile lock object */
+
+       lock_recompile_thread = NEW(java_objectheader);
+
+       lock_init_object_lock(lock_recompile_thread);
+
+       /* create method list */
+
+       list_recompile_methods = list_create(OFFSET(list_method_entry, linkage));
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* recompile_replace_vftbl *****************************************************
+
+   XXX
+
+*******************************************************************************/
+
+static void recompile_replace_vftbl(methodinfo *m)
+{
+       codeinfo               *code;
+       codeinfo               *pcode;
+       u4                      slot;
+       classcache_name_entry  *nmen;
+       classcache_class_entry *clsen;
+       classinfo              *c;
+       vftbl_t                *vftbl;
+       s4                      i;
+
+       /* get current and previous codeinfo structure */
+
+       code  = m->code;
+       pcode = code->prev;
+
+       assert(pcode);
+
+       /* iterate over all classes */
+
+       for (slot = 0; slot < hashtable_classcache.size; slot++) {
+               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
+
+               for (; nmen; nmen = nmen->hashlink) {
+                       /* iterate over all class entries */
+
+                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
+                               c = clsen->classobj;
+
+                               if (c == NULL)
+                                       continue;
+
+                               /* Search for entrypoint of the previous codeinfo in
+                                  the vftbl and replace it with the current one. */
+
+                               vftbl = c->vftbl;
+
+                               /* Is the class linked? Means, is the vftbl finished? */
+
+                               if (!(c->state & CLASS_LINKED))
+                                       continue;
+
+                               /* Does the class have a vftbl? Some internal classes
+                                  (e.g. $NEW$) are linked, but do not have a
+                                  vftbl. */
+
+                               if (vftbl == NULL)
+                                       continue;
+
+                               for (i = 0; i < vftbl->vftbllength; i++) {
+                                       if (vftbl->table[i] == pcode->entrypoint) {
+#if !defined(NDEBUG)
+                                               printf("replacing vftbl in: ");
+                                               class_println(c);
+#endif
+                                               vftbl->table[i] = code->entrypoint;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+
+/* recompile_thread ************************************************************
+
+   XXX
+
+*******************************************************************************/
+
+static void recompile_thread(void)
+{
+       list_method_entry *lme;
+
+       while (true) {
+               /* get the lock on the recompile lock object, so we can call wait */
+
+               lock_monitor_enter(lock_recompile_thread);
+
+               /* wait forever (0, 0) on that object till we are signaled */
+       
+               lock_wait_for_object(lock_recompile_thread, 0, 0);
+
+               /* leave the lock */
+
+               lock_monitor_exit(lock_recompile_thread);
+
+               /* get the next method and recompile it */
+
+               while ((lme = list_first(list_recompile_methods)) != NULL) {
+                       /* recompile this method */
+
+                       if (jit_recompile(lme->m) != NULL) {
+                               /* replace in vftbl's */
+
+                               recompile_replace_vftbl(lme->m);
+                       }
+                       else {
+                               /* XXX what is the right-thing(tm) to do here? */
+
+                               exceptions_print_exception(*exceptionptr);
+                       }
+
+                       /* remove the compiled method */
+
+                       list_remove(list_recompile_methods, lme);
+
+                       /* free the entry */
+
+                       FREE(lme, list_method_entry);
+               }
+       }
+}
+
+
+/* recompile_start_thread ******************************************************
+
+   Starts the recompilation thread.
+
+*******************************************************************************/
+
+bool recompile_start_thread(void)
+{
+       java_lang_Thread *t;
+
+       /* create the profile object */
+
+       recompile_vmthread =
+               (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
+
+       if (recompile_vmthread == NULL)
+               return false;
+
+       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
+
+       t->vmThread = recompile_vmthread;
+       t->name     = javastring_new_from_ascii("Recompiler");
+       t->daemon   = true;
+       t->priority = 5;
+
+       recompile_vmthread->thread = t;
+
+       /* actually start the recompilation thread */
+
+       threads_start_thread(t, recompile_thread);
+
+       /* everything's ok */
+
+       return true;
+}
+
+
+/* recompile_queue_method ******************************************************
+
+   Adds a method to the recompilation list and signal the
+   recompilation thread that there is some work to do.
+
+*******************************************************************************/
+
+void recompile_queue_method(methodinfo *m)
+{
+       list_method_entry *lme;
+
+       /* create a method entry */
+
+       lme = NEW(list_method_entry);
+       lme->m = m;
+
+       /* and add it to the list */
+
+       list_add_last(list_recompile_methods, lme);
+
+       /* get the lock on the recompile lock object, so we can call notify */
+
+       lock_monitor_enter(lock_recompile_thread);
+
+       /* signal the recompiler thread */
+       
+       lock_notify_object(lock_recompile_thread);
+
+       /* leave the lock */
+
+       lock_monitor_exit(lock_recompile_thread);
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/optimizing/recompile.h b/src/vm/jit/optimizing/recompile.h
new file mode 100644 (file)
index 0000000..73cec30
--- /dev/null
@@ -0,0 +1,76 @@
+/* src/vm/jit/recompile.h - recompilation system
+
+   Copyright (C) 1996-2005, 2006 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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#ifndef _RECOMPILE_H
+#define _RECOMPILE_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+
+/* list_method_entry **********************************************************/
+
+typedef struct list_method_entry list_method_entry;
+
+struct list_method_entry {
+       methodinfo *m;
+       listnode    linkage;
+};
+
+
+/* function prototypes ********************************************************/
+
+bool recompile_init(void);
+bool recompile_start_thread(void);
+
+void recompile_queue_method(methodinfo *m);
+
+#endif /* _PROFILE_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/profile/.cvsignore b/src/vm/jit/profile/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/profile/Makefile.am b/src/vm/jit/profile/Makefile.am
deleted file mode 100644 (file)
index 537be7d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-## src/vm/jit/profile/Makefile.am
-##
-## Copyright (C) 1996-2005, 2006 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, Institut f. Computersprachen - TU Wien
-##
-## This file is part of CACAO.
-##
-## This program is free software; you can redistribute it and/or
-## modify it under the terms of the GNU General Public License as
-## published by the Free Software Foundation; either version 2, or (at
-## your option) any later version.
-##
-## This program is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-## 02110-1301, USA.
-##
-## Contact: cacao@cacaojvm.org
-##
-## Authors: Christian Thalinger
-##
-## Changes:
-##
-## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $
-
-## Process this file with automake to produce Makefile.in
-
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
-
-LIBS =
-
-noinst_LTLIBRARIES = \
-       libprofile.la
-
-libprofile_la_SOURCES = \
-       profile.c \
-       profile.h
-
-
-## Local variables:
-## mode: Makefile
-## indent-tabs-mode: t
-## c-basic-offset: 4
-## tab-width: 8
-## compile-command: "automake --add-missing"
-## End:
diff --git a/src/vm/jit/profile/profile.c b/src/vm/jit/profile/profile.c
deleted file mode 100644 (file)
index 44387cc..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/* src/vm/jit/profile.c - runtime profiling
-
-   Copyright (C) 1996-2005, 2006 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
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-#include "native/jni.h"
-#include "native/include/java_lang_Thread.h"
-#include "native/include/java_lang_VMThread.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
-
-#include "vm/builtin.h"
-#include "vm/class.h"
-#include "vm/classcache.h"
-#include "vm/method.h"
-#include "vm/options.h"
-#include "vm/stringlocal.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/methodheader.h"
-#include "vm/jit/recompile.h"
-
-
-/* global variables ***********************************************************/
-
-#if defined(ENABLE_THREADS)
-static java_lang_VMThread *profile_vmthread;
-#endif
-
-
-/* profile_init ****************************************************************
-
-   Initializes the profile global lock.
-
-*******************************************************************************/
-
-bool profile_init(void)
-{
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* profile_thread **************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static s4 runs = 0;
-static s4 hits = 0;
-static s4 misses = 0;
-
-#if defined(ENABLE_THREADS)
-static void profile_thread(void)
-{
-       threadobject *t;
-       s4            nanos;
-       u1           *pc;
-       u1           *pv;
-       methodinfo   *m;
-       codeinfo     *code;
-
-       while (true) {
-               /* sleep thread for 0.5-1.0 ms */
-
-               nanos = 500 + (int) (500.0 * (rand() / (RAND_MAX + 1.0)));
-/*             fprintf(stderr, "%d\n", nanos); */
-
-               threads_sleep(0, nanos);
-               runs++;
-
-               /* iterate over all started threads */
-
-               t = mainthreadobj;
-
-               do {
-                       /* is this a Java thread? */
-
-                       if (t->flags & THREAD_FLAG_JAVA) {
-                               /* send SIGUSR2 to thread to get the current PC */
-
-                               pthread_kill(t->tid, SIGUSR2);
-
-                               /* the thread object now contains the current thread PC */
-
-                               pc = t->pc;
-
-                               /* get the PV for the current PC */
-
-                               pv = codegen_get_pv_from_pc_nocheck(pc);
-
-                               /* get methodinfo pointer from data segment */
-
-                               if (pv == NULL) {
-                                       misses++;
-                               }
-                               else {
-                                       code = *((codeinfo **) (pv + CodeinfoPointer));
-
-                                       /* For asm_vm_call_method the codeinfo pointer is
-                                          NULL (which is also in the method tree). */
-
-                                       if (code != NULL) {
-                                               m = code->m;
-
-                                               /* native methods are never recompiled */
-
-                                               if (!(m->flags & ACC_NATIVE)) {
-                                                       /* increase the method incovation counter */
-
-                                                       code->frequency++;
-                                                       hits++;
-
-                                                       if (code->frequency > 500) {
-                                                               /* clear frequency count before
-                                                                  recompilation */
-
-                                                               code->frequency = 0;
-
-                                                               /* add this method to the method list
-                                                                  and start recompilation */
-
-                                                               recompile_queue_method(m);
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-
-                       t = t->next;
-               } while ((t != NULL) && (t != mainthreadobj));
-       }
-}
-#endif
-
-
-/* profile_start_thread ********************************************************
-
-   Starts the profile sampling thread.
-
-*******************************************************************************/
-
-#if defined(ENABLE_THREADS)
-bool profile_start_thread(void)
-{
-       java_lang_Thread *t;
-
-       /* create the profile object */
-
-       profile_vmthread =
-               (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
-
-       if (profile_vmthread == NULL)
-               return false;
-
-       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
-
-       t->vmThread = profile_vmthread;
-       t->name     = javastring_new_from_ascii("Profiling Sampler");
-       t->daemon   = true;
-       t->priority = 5;
-
-       profile_vmthread->thread = t;
-
-       /* actually start the profile sampling thread */
-
-       threads_start_thread(t, profile_thread);
-
-       /* everything's ok */
-
-       return true;
-}
-#endif
-
-
-/* profile_printstats **********************************************************
-
-   Prints profiling statistics gathered during runtime.
-
-*******************************************************************************/
-
-#if !defined(NDEBUG)
-void profile_printstats(void)
-{
-       list                   *l;
-       list_method_entry      *lme;
-       list_method_entry      *tlme;
-       classinfo              *c;
-       methodinfo             *m;
-       codeinfo               *code;
-       u4                      slot;
-       classcache_name_entry  *nmen;
-       classcache_class_entry *clsen;
-       s4                      i;
-       s4                      j;
-       u4                      frequency;
-       s8                      cycles;
-
-       frequency = 0;
-       cycles    = 0;
-
-       /* create new method list */
-
-       l = list_create(OFFSET(list_method_entry, linkage));
-
-       /* iterate through all classes and methods */
-
-       for (slot = 0; slot < hashtable_classcache.size; slot++) {
-               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-
-               for (; nmen; nmen = nmen->hashlink) {
-                       /* iterate over all class entries */
-
-                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
-                               c = clsen->classobj;
-
-                               if (c == NULL)
-                                       continue;
-
-                               /* interate over all class methods */
-
-                               for (i = 0; i < c->methodscount; i++) {
-                                       m = &(c->methods[i]);
-
-                                       code = m->code;
-
-                                       /* was this method actually called? */
-
-                                       if ((code != NULL) && (code->frequency > 0)) {
-                                               /* add to overall stats */
-
-                                               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);
-                                               }
-                                               else {
-                                                       for (; tlme != NULL; tlme = list_next(l, tlme)) {
-                                                               /* check the frequency */
-
-                                                               if (code->frequency > tlme->m->code->frequency) {
-                                                                       list_add_before(l, tlme, lme);
-                                                                       break;
-                                                               }
-                                                       }
-
-                                                       /* if we are at the end of the list, add
-                                                          it as last entry */
-
-                                                       if (tlme == NULL)
-                                                               list_add_last(l, lme);
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /* print all methods sorted */
-
-       printf(" frequency     ratio         cycles     ratio   method name\n");
-       printf("----------- --------- -------------- --------- -------------\n");
-
-       /* now iterate through the list and print it */
-
-       for (lme = list_first(l); lme != NULL; lme = list_next(l, lme)) {
-               /* get method of the list element */
-
-               m = lme->m;
-
-               code = m->code;
-
-               printf("%10d   %.5f   %12ld   %.5f   ",
-                          code->frequency,
-                          (double) code->frequency / (double) frequency,
-                          (long) code->cycles,
-                          (double) code->cycles / (double) cycles);
-
-               method_println(m);
-
-               /* print basic block frequencies */
-
-               if (opt_prof_bb) {
-                       for (j = 0; j < code->basicblockcount; j++)
-                               printf("                                                    L%03d: %10d\n",
-                                          j, code->bbfrequency[j]);
-               }
-       }
-
-       printf("-----------           -------------- \n");
-       printf("%10d             %12ld\n", frequency, (long) cycles);
-
-       printf("\nruns  : %10d\n", runs);
-       printf("hits  : %10d\n", hits);
-       printf("misses: %10d\n", misses);
-}
-#endif /* !defined(NDEBUG) */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/vm/jit/profile/profile.h b/src/vm/jit/profile/profile.h
deleted file mode 100644 (file)
index ee427a8..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* src/vm/jit/profile.h - runtime profiling
-
-   Copyright (C) 1996-2005, 2006 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
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
-
-*/
-
-
-#ifndef _PROFILE_H
-#define _PROFILE_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-bool profile_init(void);
-bool profile_start_thread(void);
-
-#if !defined(NDEBUG)
-void profile_printstats(void);
-#endif
-
-#endif /* _PROFILE_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/vm/jit/recompile.c b/src/vm/jit/recompile.c
deleted file mode 100644 (file)
index b47ad8b..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/* src/vm/jit/recompile.c - recompilation system
-
-   Copyright (C) 1996-2005, 2006 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
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
-
-*/
-
-
-#include "config.h"
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "vm/types.h"
-
-#include "mm/memory.h"
-#include "native/jni.h"
-#include "native/include/java_lang_Thread.h"
-#include "native/include/java_lang_VMThread.h"
-
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-# include "threads/native/threads.h"
-#endif
-
-#include "toolbox/list.h"
-#include "vm/builtin.h"
-#include "vm/classcache.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/jit/recompile.h"
-
-
-/* global variables ***********************************************************/
-
-static java_lang_VMThread *recompile_vmthread;
-static java_objectheader *lock_recompile_thread;
-static list *list_recompile_methods;
-
-
-/* recompile_init **************************************************************
-
-   Initializes the recompilation system.
-
-*******************************************************************************/
-
-bool recompile_init(void)
-{
-       /* initialize the recompile lock object */
-
-       lock_recompile_thread = NEW(java_objectheader);
-
-       lock_init_object_lock(lock_recompile_thread);
-
-       /* create method list */
-
-       list_recompile_methods = list_create(OFFSET(list_method_entry, linkage));
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* recompile_replace_vftbl *****************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static void recompile_replace_vftbl(methodinfo *m)
-{
-       codeinfo               *code;
-       codeinfo               *pcode;
-       u4                      slot;
-       classcache_name_entry  *nmen;
-       classcache_class_entry *clsen;
-       classinfo              *c;
-       vftbl_t                *vftbl;
-       s4                      i;
-
-       /* get current and previous codeinfo structure */
-
-       code  = m->code;
-       pcode = code->prev;
-
-       assert(pcode);
-
-       /* iterate over all classes */
-
-       for (slot = 0; slot < hashtable_classcache.size; slot++) {
-               nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
-
-               for (; nmen; nmen = nmen->hashlink) {
-                       /* iterate over all class entries */
-
-                       for (clsen = nmen->classes; clsen; clsen = clsen->next) {
-                               c = clsen->classobj;
-
-                               if (c == NULL)
-                                       continue;
-
-                               /* Search for entrypoint of the previous codeinfo in
-                                  the vftbl and replace it with the current one. */
-
-                               vftbl = c->vftbl;
-
-                               /* Is the class linked? Means, is the vftbl finished? */
-
-                               if (!(c->state & CLASS_LINKED))
-                                       continue;
-
-                               /* Does the class have a vftbl? Some internal classes
-                                  (e.g. $NEW$) are linked, but do not have a
-                                  vftbl. */
-
-                               if (vftbl == NULL)
-                                       continue;
-
-                               for (i = 0; i < vftbl->vftbllength; i++) {
-                                       if (vftbl->table[i] == pcode->entrypoint) {
-#if !defined(NDEBUG)
-                                               printf("replacing vftbl in: ");
-                                               class_println(c);
-#endif
-                                               vftbl->table[i] = code->entrypoint;
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-
-/* recompile_thread ************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static void recompile_thread(void)
-{
-       list_method_entry *lme;
-
-       while (true) {
-               /* get the lock on the recompile lock object, so we can call wait */
-
-               lock_monitor_enter(lock_recompile_thread);
-
-               /* wait forever (0, 0) on that object till we are signaled */
-       
-               lock_wait_for_object(lock_recompile_thread, 0, 0);
-
-               /* leave the lock */
-
-               lock_monitor_exit(lock_recompile_thread);
-
-               /* get the next method and recompile it */
-
-               while ((lme = list_first(list_recompile_methods)) != NULL) {
-                       /* recompile this method */
-
-                       if (jit_recompile(lme->m) != NULL) {
-                               /* replace in vftbl's */
-
-                               recompile_replace_vftbl(lme->m);
-                       }
-                       else {
-                               /* XXX what is the right-thing(tm) to do here? */
-
-                               exceptions_print_exception(*exceptionptr);
-                       }
-
-                       /* remove the compiled method */
-
-                       list_remove(list_recompile_methods, lme);
-
-                       /* free the entry */
-
-                       FREE(lme, list_method_entry);
-               }
-       }
-}
-
-
-/* recompile_start_thread ******************************************************
-
-   Starts the recompilation thread.
-
-*******************************************************************************/
-
-bool recompile_start_thread(void)
-{
-       java_lang_Thread *t;
-
-       /* create the profile object */
-
-       recompile_vmthread =
-               (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
-
-       if (recompile_vmthread == NULL)
-               return false;
-
-       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
-
-       t->vmThread = recompile_vmthread;
-       t->name     = javastring_new_from_ascii("Recompiler");
-       t->daemon   = true;
-       t->priority = 5;
-
-       recompile_vmthread->thread = t;
-
-       /* actually start the recompilation thread */
-
-       threads_start_thread(t, recompile_thread);
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* recompile_queue_method ******************************************************
-
-   Adds a method to the recompilation list and signal the
-   recompilation thread that there is some work to do.
-
-*******************************************************************************/
-
-void recompile_queue_method(methodinfo *m)
-{
-       list_method_entry *lme;
-
-       /* create a method entry */
-
-       lme = NEW(list_method_entry);
-       lme->m = m;
-
-       /* and add it to the list */
-
-       list_add_last(list_recompile_methods, lme);
-
-       /* get the lock on the recompile lock object, so we can call notify */
-
-       lock_monitor_enter(lock_recompile_thread);
-
-       /* signal the recompiler thread */
-       
-       lock_notify_object(lock_recompile_thread);
-
-       /* leave the lock */
-
-       lock_monitor_exit(lock_recompile_thread);
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/src/vm/jit/recompile.h b/src/vm/jit/recompile.h
deleted file mode 100644 (file)
index 73cec30..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* src/vm/jit/recompile.h - recompilation system
-
-   Copyright (C) 1996-2005, 2006 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
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
-
-*/
-
-
-#ifndef _RECOMPILE_H
-#define _RECOMPILE_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/global.h"
-
-
-/* list_method_entry **********************************************************/
-
-typedef struct list_method_entry list_method_entry;
-
-struct list_method_entry {
-       methodinfo *m;
-       listnode    linkage;
-};
-
-
-/* function prototypes ********************************************************/
-
-bool recompile_init(void);
-bool recompile_start_thread(void);
-
-void recompile_queue_method(methodinfo *m);
-
-#endif /* _PROFILE_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */