fix use of uninitialized values at root thread creation time when running in stress mode; allocate Thread::defaultHeap on the heap instead of as part of the Thread structure

This commit is contained in:
Joel Dice 2007-10-13 19:18:25 -06:00
parent 5c99edd90e
commit 659555b6ce
3 changed files with 23 additions and 14 deletions

View File

@ -4096,11 +4096,13 @@ class MyProcessor: public Processor {
{ {
MyThread* t = static_cast<MyThread*>(vmt); MyThread* t = static_cast<MyThread*>(vmt);
for (Reference* r = t->reference; r; r = r->next) { if (t->m->active) {
v->visit(&(r->target)); for (Reference* r = t->reference; r; r = r->next) {
} v->visit(&(r->target));
}
visitStack(t, v); visitStack(t, v);
}
} }
virtual uintptr_t virtual uintptr_t

View File

@ -1336,6 +1336,7 @@ Machine::Machine(System* system, Heap* heap, Finder* finder,
weakReferences(0), weakReferences(0),
tenuredWeakReferences(0), tenuredWeakReferences(0),
unsafe(false), unsafe(false),
active(false),
heapPoolIndex(0) heapPoolIndex(0)
{ {
populateJNITables(&javaVMVTable, &jniEnvVTable); populateJNITables(&javaVMVTable, &jniEnvVTable);
@ -1386,12 +1387,12 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
heapIndex(0), heapIndex(0),
heapOffset(0), heapOffset(0),
protector(0), protector(0),
runnable(this) runnable(this),
defaultHeap(static_cast<uintptr_t*>(m->system->allocate(HeapSizeInBytes))),
heap(defaultHeap)
#ifdef VM_STRESS #ifdef VM_STRESS
, stress(false), , stress(false)
defaultHeap(static_cast<uintptr_t*>(m->system->allocate(HeapSizeInBytes)))
#endif // VM_STRESS #endif // VM_STRESS
, heap(defaultHeap)
{ {
if (parent == 0) { if (parent == 0) {
assert(this, m->rootThread == 0); assert(this, m->rootThread == 0);
@ -1399,6 +1400,7 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
m->rootThread = this; m->rootThread = this;
m->unsafe = true; m->unsafe = true;
m->active = false;
if (not m->system->success(m->system->attach(&runnable))) { if (not m->system->success(m->system->attach(&runnable))) {
abort(this); abort(this);
@ -1494,6 +1496,7 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
if (parent == 0) { if (parent == 0) {
enter(this, Thread::IdleState); enter(this, Thread::IdleState);
m->active = true;
} }
} }

View File

@ -1098,6 +1098,12 @@ class Machine {
#include "type-enums.cpp" #include "type-enums.cpp"
}; };
enum State {
UnsafeState,
BootState,
ActiveState
};
Machine(System* system, Heap* heap, Finder* finder, Processor* processor); Machine(System* system, Heap* heap, Finder* finder, Processor* processor);
~Machine() { ~Machine() {
@ -1136,6 +1142,7 @@ class Machine {
object weakReferences; object weakReferences;
object tenuredWeakReferences; object tenuredWeakReferences;
bool unsafe; bool unsafe;
bool active;
JavaVMVTable javaVMVTable; JavaVMVTable javaVMVTable;
JNIEnvVTable jniEnvVTable; JNIEnvVTable jniEnvVTable;
uintptr_t* heapPool[HeapPoolSize]; uintptr_t* heapPool[HeapPoolSize];
@ -1242,14 +1249,11 @@ class Thread {
unsigned heapOffset; unsigned heapOffset;
Protector* protector; Protector* protector;
Runnable runnable; Runnable runnable;
#ifdef VM_STRESS
bool stress;
uintptr_t* defaultHeap; uintptr_t* defaultHeap;
uintptr_t* heap; uintptr_t* heap;
#else // not VM_STRESS #ifdef VM_STRESS
uintptr_t* heap; bool stress;
uintptr_t defaultHeap[HeapSizeInWords]; #endif // VM_STRESS
#endif // not VM_STRESS
}; };
inline object inline object