/* 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
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Christian Thalinger
-
- $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
-
*/
#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 "threads/lock-common.h"
+#include "threads/thread.h"
#include "toolbox/list.h"
+
#include "vm/builtin.h"
-#include "vm/classcache.h"
#include "vm/exceptions.h"
#include "vm/stringlocal.h"
+
+#include "vm/jit/code.h"
+#include "vm/jit/jit.h"
+
#include "vm/jit/optimizing/recompile.h"
+#include "vmcore/classcache.h"
+#include "vmcore/options.h"
+
/* global variables ***********************************************************/
-static threadobject *thread_recompile;
-static java_objectheader *lock_thread_recompile;
-static list *list_recompile_methods;
+static java_object_t *lock_thread_recompile;
+static list_t *list_recompile_methods;
/* recompile_init **************************************************************
bool recompile_init(void)
{
+ TRACESUBSYSTEMINITIALIZATION("recompile_init");
+
/* initialize the recompile lock object */
- lock_thread_recompile = NEW(java_objectheader);
+ lock_thread_recompile = NEW(java_object_t);
- lock_init_object_lock(lock_thread_recompile);
+ LOCK_INIT_OBJECT_LOCK(lock_thread_recompile);
/* create method list */
while (true) {
/* get the lock on the recompile lock object, so we can call wait */
- lock_monitor_enter(lock_thread_recompile);
+ LOCK_MONITOR_ENTER(lock_thread_recompile);
- /* wait forever (0, 0) on that object till we are signaled */
+ /* wait forever on that object till we are signaled */
- lock_wait_for_object(lock_thread_recompile, 0, 0);
+ LOCK_WAIT_FOREVER(lock_thread_recompile);
/* leave the lock */
- lock_monitor_exit(lock_thread_recompile);
+ LOCK_MONITOR_EXIT(lock_thread_recompile);
/* get the next method and recompile it */
else {
/* XXX what is the right-thing(tm) to do here? */
- exceptions_print_exception(*exceptionptr);
+ exceptions_print_current_exception();
}
/* remove the compiled method */
bool recompile_start_thread(void)
{
-#if defined(WITH_CLASSPATH_GNU)
- java_lang_VMThread *vmt;
-#endif
-
- /* create the profile object */
+ utf *name;
- thread_recompile = (threadobject *) builtin_new(class_java_lang_Thread);
+ name = utf_new_char("Recompiler");
- if (thread_recompile == NULL)
+ if (!threads_thread_start_internal(name, recompile_thread))
return false;
-#if defined(WITH_CLASSPATH_GNU)
- vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
-
- vmt->thread = (java_lang_Thread *) thread_recompile;
-
- thread_recompile->o.vmThread = vmt;
-#endif
-
- thread_recompile->o.name = javastring_new_from_ascii("Recompiler");
- thread_recompile->o.daemon = true;
- thread_recompile->o.priority = 5;
-
- /* actually start the recompilation thread */
-
- threads_start_thread(thread_recompile, recompile_thread);
-
/* everything's ok */
return true;
/* get the lock on the recompile lock object, so we can call notify */
- lock_monitor_enter(lock_thread_recompile);
+ LOCK_MONITOR_ENTER(lock_thread_recompile);
/* signal the recompiler thread */
- lock_notify_object(lock_thread_recompile);
+ LOCK_NOTIFY(lock_thread_recompile);
/* leave the lock */
- lock_monitor_exit(lock_thread_recompile);
+ LOCK_MONITOR_EXIT(lock_thread_recompile);
}