mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
allocate root thread on heap, not stack
This commit is contained in:
parent
108f8d7bc0
commit
b57e1eee76
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
10
src/run.cpp
10
src/run.cpp
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user