/* src/vm/initialize.c - static class initializer functions
- Copyright (C) 1996-2005 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
+ 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.
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., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
- Contact: cacao@complang.tuwien.ac.at
+ Contact: cacao@cacaojvm.org
Authors: Reinhard Grafl
Andreas Krall
Christian Thalinger
- $Id: initialize.c 4145 2006-01-12 21:06:07Z twisti $
+ $Id: initialize.c 5123 2006-07-12 21:45:34Z twisti $
*/
#include "vm/types.h"
+#if defined(ENABLE_THREADS)
+# include "threads/native/lock.h"
+#else
+# include "threads/none/lock.h"
+#endif
+
#include "vm/global.h"
#include "vm/initialize.h"
#include "vm/builtin.h"
#include "vm/options.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
if (!makeinitializations)
return true;
-#if defined(USE_THREADS)
- /* enter a monitor on the class */
-
- builtin_monitorenter((java_objectheader *) c);
-#endif
+ LOCK_MONITOR_ENTER(c);
/* maybe the class is already initalized or the current thread, which can
pass the monitor, is currently initalizing this class */
- if ((c->state & CLASS_INITIALIZING) || (c->state & CLASS_INITIALIZED)) {
-#if defined(USE_THREADS)
- builtin_monitorexit((java_objectheader *) c);
-#endif
+ if (CLASS_IS_OR_ALMOST_INITIALIZED(c)) {
+ LOCK_MONITOR_EXIT(c);
return true;
}
if (c->state & CLASS_ERROR) {
*exceptionptr = new_noclassdeffounderror(c->name);
-#if defined(USE_THREADS)
- builtin_monitorexit((java_objectheader *) c);
-#endif
+ LOCK_MONITOR_EXIT(c);
/* ...but return true, this is ok (mauve test) */
c->state &= ~CLASS_INITIALIZING;
-#if defined(USE_THREADS)
- /* leave the monitor */
-
- builtin_monitorexit((java_objectheader *) c);
-#endif
+ LOCK_MONITOR_EXIT(c);
return r;
}
{
methodinfo *m;
java_objectheader *xptr;
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- int b;
-#endif
/* maybe the class is not already linked */
log_message_class("Starting static class initializer for class: ", c);
#endif
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- b = blockInts;
- blockInts = 0;
-#endif
-
/* now call the initializer */
- ASM_CALLJAVAFUNCTION(m, NULL, NULL, NULL, NULL);
-
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- assert(blockInts == 0);
- blockInts = b;
-#endif
+ (void) vm_call_method(m, NULL);
/* we have an exception or error */