Changes: Joseph Wenninger, Martin Platter
- $Id: jni.c 1801 2004-12-21 20:19:19Z jowenn $
+ $Id: jni.c 1807 2004-12-22 10:47:13Z twisti $
*/
c = class_new(utf_new_char_classname((char *) name));
+#if defined(USE_THREADS)
/* enter a monitor on the class */
builtin_monitorenter((java_objectheader *) c);
+#endif
/* measure time */
if (getloadingtime)
if (getloadingtime)
loadingtime_stop();
+#if defined(USE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) c);
+#endif
/* XXX link the class here? */
/* if (class_link(c)) */
/******************************* monitor operations ********************************/
-jint MonitorEnter (JNIEnv* env, jobject obj)
+jint MonitorEnter(JNIEnv* env, jobject obj)
{
+#if defined(USE_THREADS)
builtin_monitorenter(obj);
+#endif
+
return 0;
}
-jint MonitorExit (JNIEnv* env, jobject obj)
+jint MonitorExit(JNIEnv* env, jobject obj)
{
+#if defined(USE_THREADS)
builtin_monitorexit(obj);
+#endif
+
return 0;
}
calls instead of machine instructions, using the C calling
convention.
- $Id: builtin.c 1774 2004-12-20 20:16:57Z jowenn $
+ $Id: builtin.c 1807 2004-12-22 10:47:13Z twisti $
*/
if (m->flags & ACC_NATIVE) {
printf(",NATIVE");
#if POINTERSIZE == 8
- printf(")(0x%016lx) at position %p\n", (s8) m->entrypoint, pos);
+ printf(")(0x%016lx) at position 0x%016lx\n", (ptrint) m->entrypoint, (ptrint) pos);
#else
- printf(")(0x%08lx) at position %p\n", (s4) m->entrypoint, pos);
+ printf(")(0x%08x) at position 0x%08x\n", (ptrint) m->entrypoint, (ptrint) pos);
#endif
} else {
#if POINTERSIZE == 8
- printf(")(0x%016lx) at position %p (", (s8) m->entrypoint, pos);
+ printf(")(0x%016lx) at position 0x%016lx (", (ptrint) m->entrypoint, (ptrint) pos);
#else
- printf(")(0x%08lx) at position %p (", (s4) m->entrypoint, pos);
+ printf(")(0x%08x) at position 0x%08x (", (ptrint) m->entrypoint, (ptrint) pos);
#endif
if (m->class->sourcefile == NULL) {
printf("<NO CLASSFILE INFORMATION>");
SYNCHRONIZATION FUNCTIONS
*****************************************************************************/
+#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
/*
* Lock the mutex of an object.
*/
void internal_lock_mutex_for_object(java_objectheader *object)
{
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
mutexHashEntry *entry;
int hashValue;
entry->object = object;
internal_lock_mutex(&entry->mutex);
-#endif
}
+#endif
+#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
/*
* Unlocks the mutex of an object.
*/
void internal_unlock_mutex_for_object (java_objectheader *object)
{
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
int hashValue;
mutexHashEntry *entry;
firstFreeOverflowEntry = unlinked;
}
}
-#endif
}
+#endif
+#if defined(USE_THREADS)
void builtin_monitorenter(java_objectheader *o)
{
-#if defined(USE_THREADS)
#if !defined(NATIVE_THREADS)
int hashValue;
#else
monitorEnter((threadobject *) THREADOBJECT, o);
#endif
+}
#endif
-}
+#if defined(USE_THREADS)
/*
* Locks the class object - needed for static synchronized methods.
* The use_class_as_object call is needed in order to circumvent a
use_class_as_object(c);
builtin_monitorenter(&c->header);
}
+#endif
+#if defined(USE_THREADS)
void *builtin_monitorexit(java_objectheader *o)
{
-#if defined(USE_THREADS)
#if !defined(NATIVE_THREADS)
int hashValue;
monitorExit((threadobject *) THREADOBJECT, o);
return o;
#endif
-#endif
}
+#endif
/*****************************************************************************
Changes: Edwin Steiner
- $Id: builtin.h 1793 2004-12-21 10:14:35Z twisti $
+ $Id: builtin.h 1807 2004-12-22 10:47:13Z twisti $
*/
void builtin_displaymethodstop(methodinfo *m, s8 l, double d, float f);
/* NOT AN OP */
+#if defined(USE_THREADS)
void builtin_monitorenter(java_objectheader *o);
/* NOT AN OP */
void builtin_staticmonitorenter(classinfo *c);
/* NOT AN OP */
void *asm_builtin_monitorexit(java_objectheader *o);
#define BUILTIN_monitorexit (functionptr) asm_builtin_monitorexit
+#endif
s4 builtin_idiv(s4 a, s4 b);
/* NOT AN OP */
Changes: Edwin Steiner
- $Id: jit.c 1801 2004-12-21 20:19:19Z jowenn $
+ $Id: jit.c 1807 2004-12-22 10:47:13Z twisti $
*/
{255,BUILTIN_newarray_short ,ICMD_BUILTIN1,TYPE_INT ,TYPE_VOID ,TYPE_VOID ,TYPE_ADR ,0,0,"newarray_short"},
{255,BUILTIN_newarray_int ,ICMD_BUILTIN1,TYPE_INT ,TYPE_VOID ,TYPE_VOID ,TYPE_ADR ,0,0,"newarray_int"},
{255,BUILTIN_newarray_long ,ICMD_BUILTIN1,TYPE_INT ,TYPE_VOID ,TYPE_VOID ,TYPE_ADR ,0,0,"newarray_long"},
+#if defined(USE_THREADS)
{255,BUILTIN_monitorenter ,ICMD_BUILTIN1,TYPE_ADR ,TYPE_VOID ,TYPE_VOID ,TYPE_VOID ,0,0,"monitorenter"},
{255,BUILTIN_monitorexit ,ICMD_BUILTIN1,TYPE_ADR ,TYPE_VOID ,TYPE_VOID ,TYPE_VOID ,0,0,"monitorexit"},
+#endif
#if !SUPPORT_DIVISION
{255,BUILTIN_idiv ,ICMD_BUILTIN2,TYPE_INT ,TYPE_INT ,TYPE_VOID ,TYPE_INT ,0,0,"idiv"},
{255,BUILTIN_irem ,ICMD_BUILTIN2,TYPE_INT ,TYPE_INT ,TYPE_VOID ,TYPE_INT ,0,0,"irem"},
if (opt_stat)
count_jit_calls++;
+#if defined(USE_THREADS)
/* enter a monitor on the method */
builtin_monitorenter((java_objectheader *) m);
+#endif
/* if method has been already compiled return immediately */
if (m->entrypoint) {
+#if defined(USE_THREADS)
builtin_monitorexit((java_objectheader *) m);
+#endif
return m->entrypoint;
}
useinlining = false;
#endif
+#if defined(USE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) m );
+#endif
if (r) {
if (compileverbose)
Edwin Steiner
Christian Thalinger
- $Id: loader.c 1801 2004-12-21 20:19:19Z jowenn $
+ $Id: loader.c 1807 2004-12-22 10:47:13Z twisti $
*/
classbuffer *cb;
classinfo *r;
+#if defined(USE_THREADS)
/* enter a monitor on the class */
builtin_monitorenter((java_objectheader *) c);
+#endif
/* maybe the class is already loaded */
if (c->loaded) {
+#if defined(USE_THREADS)
builtin_monitorexit((java_objectheader *) c);
+#endif
return c;
}
new_exception_utfmessage(string_java_lang_NoClassDefFoundError,
c->name);
+#if defined(USE_THREADS)
builtin_monitorexit((java_objectheader *) c);
+#endif
return NULL;
}
if (getcompilingtime)
compilingtime_start();
+#if defined(USE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) c);
+#endif
return r;
}
{
classinfo *r;
+#if defined(USE_THREADS)
/* enter a monitor on the class */
builtin_monitorenter((java_objectheader *) c);
+#endif
/* maybe the class is already linked */
if (c->linked) {
+#if defined(USE_THREADS)
builtin_monitorexit((java_objectheader *) c);
+#endif
return c;
}
if (getcompilingtime)
compilingtime_start();
+#if defined(USE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) c);
+#endif
return r;
}
if (!makeinitializations)
return c;
+#if defined(USE_THREADS)
/* enter a monitor on the class */
builtin_monitorenter((java_objectheader *) c);
+#endif
/* maybe the class is already initalized or the current thread, which can
pass the monitor, is currently initalizing this class */
*/
if (c->initialized || c->initializing) {
+#if defined(USE_THREADS)
builtin_monitorexit((java_objectheader *) c);
+#endif
return c;
}
/* this initalizing run is done */
c->initializing = false;
+#if defined(USE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) c);
+#endif
return r;
}