* src/vm/jit/profile/profile.c (profile_init): New method.
authortwisti <none@none>
Mon, 6 Feb 2006 18:48:50 +0000 (18:48 +0000)
committertwisti <none@none>
Mon, 6 Feb 2006 18:48:50 +0000 (18:48 +0000)
(profile_thread): Likewise.
(profile_start_thread): Likewise.
* src/vm/jit/profile/profile.h (profile_init): Added.
(profile_start_thread): Likewise.
* src/vm/jit/profile/Makefile.am: New file.
* src/vm/jit/profile/.cvsignore: Likewise.

src/vm/jit/profile/.cvsignore [new file with mode: 0644]
src/vm/jit/profile/Makefile.am [new file with mode: 0644]
src/vm/jit/profile/profile.c
src/vm/jit/profile/profile.h

diff --git a/src/vm/jit/profile/.cvsignore b/src/vm/jit/profile/.cvsignore
new file mode 100644 (file)
index 0000000..8f719f9
--- /dev/null
@@ -0,0 +1,9 @@
+*.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
new file mode 100644 (file)
index 0000000..c95fbd1
--- /dev/null
@@ -0,0 +1,51 @@
+## 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)
+
+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:
index b974e341d86f04cf904500dad9b4aa00b9d71913..a410a432ab0e3d7149548074fa2ddcb857904de2 100644 (file)
 #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(USE_THREADS)
+# if defined(NATIVE_THREADS)
+#  include "threads/native/threads.h"
+# else
+#  include "threads/green/threads.h"
+# endif
+#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"
 
 
 /* list_method_entry **********************************************************/
@@ -56,6 +70,103 @@ struct list_method_entry {
 };
 
 
+/* global variables ***********************************************************/
+
+#if defined(USE_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
+
+*******************************************************************************/
+
+#if defined(USE_THREADS)
+static void profile_thread(void)
+{
+       s4 i = 0;
+
+       while (true) {
+               /* sleep thread for 100 nanos */
+
+               thread_sleep(0, 100);
+
+#if 0
+               /* get the lock on the finalizer lock object, so we can call wait */
+
+               builtin_monitorenter(lock_profile_thread);
+
+               /* wait 1 ms */
+       
+               wait_cond_for_object(lock_profile_thread, 0, 100);
+
+               /* leave the lock */
+
+               builtin_monitorexit(lock_profile_thread);
+#endif
+
+/*             if ((i++ % 1000) == 0) */
+/*                     printf("profile_thread: %d\n", i); */
+       }
+}
+#endif
+
+
+/* profile_start_thread ********************************************************
+
+   Starts the profile sampling thread.
+
+*******************************************************************************/
+
+#if defined(USE_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)
+               return false;
+
+       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
+
+       t->vmThread = profile_vmthread;
+       t->name     = javastring_new_char("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.
index 09ed7ba29fa3fa973439e75e2d9be32186e12166..24290ca9f0a6af30e0604da9262e177b57329364 100644 (file)
@@ -42,6 +42,9 @@
 
 /* function prototypes ********************************************************/
 
+bool profile_init(void);
+bool profile_start_thread(void);
+
 #if !defined(NDEBUG)
 void profile_printstats(void);
 #endif