allocate root thread on heap, not stack

This commit is contained in:
Joel Dice 2007-07-20 17:26:13 -06:00
parent 108f8d7bc0
commit b57e1eee76
6 changed files with 9 additions and 31 deletions

View File

@ -180,8 +180,7 @@ start(Thread* t, jobject this_)
object message = makeString(t, "thread already started");
t->exception = makeIllegalStateException(t, message);
} else {
p = new (t->vm->system->allocate(sizeof(Thread)))
Thread(t->vm, t->vm->system, *this_, t);
p = new (t->vm->system->allocate(sizeof(Thread))) Thread(t->vm, *this_, t);
enter(p, Thread::ActiveState);

View File

@ -1,12 +1,8 @@
#include "sys/mman.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "system.h"
#include "class-finder.h"

View File

@ -1,8 +1,6 @@
#ifndef COMMON_H
#define COMMON_H
#include "stdint.h"
#include "stdlib.h"
#include "stdarg.h"
@ -29,8 +27,6 @@
inline void* operator new(size_t, void* p) throw() { return p; }
namespace vm {
typedef void* object;

View File

@ -1294,17 +1294,11 @@ Machine::dispose()
if (libraries) {
libraries->dispose();
}
if (rootThread) {
rootThread->dispose();
}
}
Thread::Thread(Machine* m, Allocator* allocator, object javaThread,
Thread* parent):
Thread::Thread(Machine* m, object javaThread, Thread* parent):
vtable(&(m->jniEnvVTable)),
vm(m),
allocator(allocator),
parent(parent),
peer((parent ? parent->child : 0)),
child(0),
@ -1412,9 +1406,7 @@ Thread::dispose()
heap = 0;
#endif // VM_STRESS
if (allocator) {
allocator->free(this);
}
vm->system->free(this);
}
void

View File

@ -1158,18 +1158,13 @@ class Thread {
static const unsigned HeapSizeInWords = HeapSizeInBytes / BytesPerWord;
static const unsigned StackSizeInWords = StackSizeInBytes / BytesPerWord;
Thread(Machine* m, Allocator* allocator, object javaThread, Thread* parent);
~Thread() {
exit();
}
Thread(Machine* m, object javaThread, Thread* parent);
void exit();
void dispose();
JNIEnvVTable* vtable;
Machine* vm;
Allocator* allocator;
Thread* parent;
Thread* peer;
Thread* child;

View File

@ -2372,16 +2372,16 @@ run(System* system, Heap* heap, ClassFinder* classFinder,
const char* className, int argc, const char** argv)
{
Machine m(system, heap, classFinder);
Thread t(&m, 0, 0, 0);
Thread* t = new (system->allocate(sizeof(Thread))) Thread(&m, 0, 0);
enter(&t, Thread::ActiveState);
enter(t, Thread::ActiveState);
::run(&t, className, argc, argv);
::run(t, className, argc, argv);
int exitCode = 0;
if (t.exception) exitCode = -1;
if (t->exception) exitCode = -1;
exit(&t);
exit(t);
return exitCode;
}