#include "tables.h"
#include "native.h"
#include "loader.h"
+#include "toolbox/memory.h"
-static classinfo *class_java_lang_IllegalMonitorStateException;
+
+#if !defined(NATIVE_THREADS)
extern thread* currentThread;
int i;
mutexHashTableSize = MUTEX_HASH_TABLE_SIZE;
- mutexHashTable = (mutexHashEntry*)malloc(sizeof(mutexHashEntry) * mutexHashTableSize);
+ mutexHashTable = MNEW(mutexHashEntry, mutexHashTableSize);
mutexHashMask = (mutexHashTableSize - 1) << 3;
for (i = 0; i < mutexHashTableSize; ++i)
}
mutexOverflowTableSize = MUTEX_OVERFLOW_TABLE_SIZE;
- mutexOverflowTable = (mutexHashEntry*)malloc(sizeof(mutexHashEntry)
- * mutexOverflowTableSize);
+ mutexOverflowTable = MNEW(mutexHashEntry, mutexOverflowTableSize);
firstFreeOverflowEntry = &mutexOverflowTable[0];
mutexOverflowTable[i - 1].next = 0;
conditionHashTableSize = CONDITION_HASH_TABLE_SIZE;
- conditionHashTable = (conditionHashEntry*)malloc(sizeof(conditionHashEntry)
- * conditionHashTableSize);
+ conditionHashTable = MNEW(conditionHashEntry, conditionHashTableSize);
conditionHashMask = (conditionHashTableSize - 1) << 3;
for (i = 0; i < conditionHashTableSize; ++i)
conditionHashTable[i].condition.cvWaiters = 0;
conditionHashTable[i].condition.mux = 0;
}
-
- /* Load exception classes */
- loader_load_sysclass(&class_java_lang_IllegalMonitorStateException,
- utf_new_char("java/lang/IllegalMonitorStateException"));
}
+
/*
* Reorders part of the condition hash table. Must be called after an entry has been deleted.
*/
if (mux->muxWaiters != 0)
{
tid = mux->muxWaiters;
- mux->muxWaiters = tid->next;
+ mux->muxWaiters = tid->vmThread->next;
iresumeThread(tid);
}
}
DBG( fprintf(stderr, "waiting on %p\n", cv); );
if (mux->holder != currentThread) {
- *exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
+ *exceptionptr = new_exception(string_java_lang_IllegalMonitorStateException);
}
assert(blockInts > 0);
/* If there's anyone waiting here, wake them up */
if (mux->muxWaiters != 0) {
tid = mux->muxWaiters;
- mux->muxWaiters = tid->next;
+ mux->muxWaiters = tid->vmThread->next;
iresumeThread(tid);
}
}
if (cv->mux->holder != currentThread) {
- *exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
+ *exceptionptr = new_exception(string_java_lang_IllegalMonitorStateException);
}
assert(blockInts > 0);
DBG( fprintf(stderr, "releasing a waiter\n"); );
tid = cv->cvWaiters;
- cv->cvWaiters = tid->next;
+ cv->cvWaiters = tid->vmThread->next;
/* Place it on mux list */
- tid->next = cv->mux->muxWaiters;
+ tid->vmThread->next = cv->mux->muxWaiters;
cv->mux->muxWaiters = tid;
}
}
}
if (cv->mux->holder != currentThread) {
- *exceptionptr = native_new_and_init(class_java_lang_IllegalMonitorStateException);
+ *exceptionptr = new_exception(string_java_lang_IllegalMonitorStateException);
}
assert(blockInts > 0);
/* Find the end of the cv list */
if (cv->cvWaiters) {
- for (tidp = &cv->cvWaiters; *tidp != 0; tidp = &(*tidp)->next)
+ for (tidp = &cv->cvWaiters; *tidp != 0; tidp = &(*tidp)->vmThread->next)
;
/* Place entire cv list on mux list */
cv->cvWaiters = 0;
}
}
+
+#endif