mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
implement -Xss command line option
This commit is contained in:
parent
d718bbf833
commit
d78247ab9a
@ -8303,7 +8303,7 @@ invoke(Thread* thread, object method, ArgumentList* arguments)
|
|||||||
uintptr_t stackLimit = t->stackLimit;
|
uintptr_t stackLimit = t->stackLimit;
|
||||||
uintptr_t stackPosition = reinterpret_cast<uintptr_t>(&t);
|
uintptr_t stackPosition = reinterpret_cast<uintptr_t>(&t);
|
||||||
if (stackLimit == 0) {
|
if (stackLimit == 0) {
|
||||||
t->stackLimit = stackPosition - StackSizeInBytes;
|
t->stackLimit = stackPosition - t->m->stackSizeInBytes;
|
||||||
} else if (stackPosition < stackLimit) {
|
} else if (stackPosition < stackLimit) {
|
||||||
throwNew(t, Machine::StackOverflowErrorType);
|
throwNew(t, Machine::StackOverflowErrorType);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class Thread: public vm::Thread {
|
|||||||
unsigned sp;
|
unsigned sp;
|
||||||
int frame;
|
int frame;
|
||||||
object code;
|
object code;
|
||||||
uintptr_t stack[StackSizeInWords];
|
uintptr_t stack[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
@ -50,7 +50,7 @@ pushObject(Thread* t, object o)
|
|||||||
fprintf(stderr, "push object %p at %d\n", o, t->sp);
|
fprintf(stderr, "push object %p at %d\n", o, t->sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(t, t->sp + 1 < StackSizeInWords / 2);
|
assert(t, t->sp + 1 < stackSizeInWords(t) / 2);
|
||||||
t->stack[(t->sp * 2) ] = ObjectTag;
|
t->stack[(t->sp * 2) ] = ObjectTag;
|
||||||
t->stack[(t->sp * 2) + 1] = reinterpret_cast<uintptr_t>(o);
|
t->stack[(t->sp * 2) + 1] = reinterpret_cast<uintptr_t>(o);
|
||||||
++ t->sp;
|
++ t->sp;
|
||||||
@ -63,7 +63,7 @@ pushInt(Thread* t, uint32_t v)
|
|||||||
fprintf(stderr, "push int %d at %d\n", v, t->sp);
|
fprintf(stderr, "push int %d at %d\n", v, t->sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(t, t->sp + 1 < StackSizeInWords / 2);
|
assert(t, t->sp + 1 < stackSizeInWords(t) / 2);
|
||||||
t->stack[(t->sp * 2) ] = IntTag;
|
t->stack[(t->sp * 2) ] = IntTag;
|
||||||
t->stack[(t->sp * 2) + 1] = v;
|
t->stack[(t->sp * 2) + 1] = v;
|
||||||
++ t->sp;
|
++ t->sp;
|
||||||
@ -156,7 +156,7 @@ peekObject(Thread* t, unsigned index)
|
|||||||
index);
|
index);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(t, index < StackSizeInWords / 2);
|
assert(t, index < stackSizeInWords(t) / 2);
|
||||||
assert(t, t->stack[index * 2] == ObjectTag);
|
assert(t, t->stack[index * 2] == ObjectTag);
|
||||||
return *reinterpret_cast<object*>(t->stack + (index * 2) + 1);
|
return *reinterpret_cast<object*>(t->stack + (index * 2) + 1);
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ peekInt(Thread* t, unsigned index)
|
|||||||
index);
|
index);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(t, index < StackSizeInWords / 2);
|
assert(t, index < stackSizeInWords(t) / 2);
|
||||||
assert(t, t->stack[index * 2] == IntTag);
|
assert(t, t->stack[index * 2] == IntTag);
|
||||||
return t->stack[(index * 2) + 1];
|
return t->stack[(index * 2) + 1];
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ inline object*
|
|||||||
pushReference(Thread* t, object o)
|
pushReference(Thread* t, object o)
|
||||||
{
|
{
|
||||||
if (o) {
|
if (o) {
|
||||||
expect(t, t->sp + 1 < StackSizeInWords / 2);
|
expect(t, t->sp + 1 < stackSizeInWords(t) / 2);
|
||||||
pushObject(t, o);
|
pushObject(t, o);
|
||||||
return reinterpret_cast<object*>(t->stack + ((t->sp - 1) * 2) + 1);
|
return reinterpret_cast<object*>(t->stack + ((t->sp - 1) * 2) + 1);
|
||||||
} else {
|
} else {
|
||||||
@ -405,7 +405,7 @@ checkStack(Thread* t, object method)
|
|||||||
+ codeMaxLocals(t, methodCode(t, method))
|
+ codeMaxLocals(t, methodCode(t, method))
|
||||||
+ FrameFootprint
|
+ FrameFootprint
|
||||||
+ codeMaxStack(t, methodCode(t, method))
|
+ codeMaxStack(t, methodCode(t, method))
|
||||||
> StackSizeInWords / 2))
|
> stackSizeInWords(t) / 2))
|
||||||
{
|
{
|
||||||
throwNew(t, Machine::StackOverflowErrorType);
|
throwNew(t, Machine::StackOverflowErrorType);
|
||||||
}
|
}
|
||||||
@ -2879,7 +2879,7 @@ class MyProcessor: public Processor {
|
|||||||
virtual vm::Thread*
|
virtual vm::Thread*
|
||||||
makeThread(Machine* m, object javaThread, vm::Thread* parent)
|
makeThread(Machine* m, object javaThread, vm::Thread* parent)
|
||||||
{
|
{
|
||||||
Thread* t = new (m->heap->allocate(sizeof(Thread)))
|
Thread* t = new (m->heap->allocate(sizeof(Thread) + m->stackSizeInBytes))
|
||||||
Thread(m, javaThread, parent);
|
Thread(m, javaThread, parent);
|
||||||
t->init();
|
t->init();
|
||||||
return t;
|
return t;
|
||||||
@ -2996,7 +2996,7 @@ class MyProcessor: public Processor {
|
|||||||
assert(t, ((methodFlags(t, method) & ACC_STATIC) == 0) xor (this_ == 0));
|
assert(t, ((methodFlags(t, method) & ACC_STATIC) == 0) xor (this_ == 0));
|
||||||
|
|
||||||
if (UNLIKELY(t->sp + methodParameterFootprint(t, method) + 1
|
if (UNLIKELY(t->sp + methodParameterFootprint(t, method) + 1
|
||||||
> StackSizeInWords / 2))
|
> stackSizeInWords(t) / 2))
|
||||||
{
|
{
|
||||||
throwNew(t, Machine::StackOverflowErrorType);
|
throwNew(t, Machine::StackOverflowErrorType);
|
||||||
}
|
}
|
||||||
@ -3020,7 +3020,7 @@ class MyProcessor: public Processor {
|
|||||||
assert(t, ((methodFlags(t, method) & ACC_STATIC) == 0) xor (this_ == 0));
|
assert(t, ((methodFlags(t, method) & ACC_STATIC) == 0) xor (this_ == 0));
|
||||||
|
|
||||||
if (UNLIKELY(t->sp + methodParameterFootprint(t, method) + 1
|
if (UNLIKELY(t->sp + methodParameterFootprint(t, method) + 1
|
||||||
> StackSizeInWords / 2))
|
> stackSizeInWords(t) / 2))
|
||||||
{
|
{
|
||||||
throwNew(t, Machine::StackOverflowErrorType);
|
throwNew(t, Machine::StackOverflowErrorType);
|
||||||
}
|
}
|
||||||
@ -3043,7 +3043,7 @@ class MyProcessor: public Processor {
|
|||||||
or t->state == Thread::ExclusiveState);
|
or t->state == Thread::ExclusiveState);
|
||||||
|
|
||||||
if (UNLIKELY(t->sp + parameterFootprint(vmt, methodSpec, false)
|
if (UNLIKELY(t->sp + parameterFootprint(vmt, methodSpec, false)
|
||||||
> StackSizeInWords / 2))
|
> stackSizeInWords(t) / 2))
|
||||||
{
|
{
|
||||||
throwNew(t, Machine::StackOverflowErrorType);
|
throwNew(t, Machine::StackOverflowErrorType);
|
||||||
}
|
}
|
||||||
|
@ -3269,6 +3269,7 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
local::JavaVMInitArgs* a = static_cast<local::JavaVMInitArgs*>(args);
|
local::JavaVMInitArgs* a = static_cast<local::JavaVMInitArgs*>(args);
|
||||||
|
|
||||||
unsigned heapLimit = 0;
|
unsigned heapLimit = 0;
|
||||||
|
unsigned stackLimit = 0;
|
||||||
const char* bootLibrary = 0;
|
const char* bootLibrary = 0;
|
||||||
const char* classpath = 0;
|
const char* classpath = 0;
|
||||||
const char* javaHome = AVIAN_JAVA_HOME;
|
const char* javaHome = AVIAN_JAVA_HOME;
|
||||||
@ -3285,6 +3286,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
const char* p = a->options[i].optionString + 2;
|
const char* p = a->options[i].optionString + 2;
|
||||||
if (strncmp(p, "mx", 2) == 0) {
|
if (strncmp(p, "mx", 2) == 0) {
|
||||||
heapLimit = local::parseSize(p + 2);
|
heapLimit = local::parseSize(p + 2);
|
||||||
|
} else if (strncmp(p, "ss", 2) == 0) {
|
||||||
|
stackLimit = local::parseSize(p + 2);
|
||||||
} else if (strncmp(p, BOOTCLASSPATH_PREPEND_OPTION ":",
|
} else if (strncmp(p, BOOTCLASSPATH_PREPEND_OPTION ":",
|
||||||
sizeof(BOOTCLASSPATH_PREPEND_OPTION)) == 0)
|
sizeof(BOOTCLASSPATH_PREPEND_OPTION)) == 0)
|
||||||
{
|
{
|
||||||
@ -3327,6 +3330,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (heapLimit == 0) heapLimit = 128 * 1024 * 1024;
|
if (heapLimit == 0) heapLimit = 128 * 1024 * 1024;
|
||||||
|
|
||||||
|
if (stackLimit == 0) stackLimit = 128 * 1024;
|
||||||
|
|
||||||
if (classpath == 0) classpath = ".";
|
if (classpath == 0) classpath = ".";
|
||||||
|
|
||||||
@ -3378,7 +3383,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*m = new (h->allocate(sizeof(Machine))) Machine
|
*m = new (h->allocate(sizeof(Machine))) Machine
|
||||||
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions);
|
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions,
|
||||||
|
stackLimit);
|
||||||
|
|
||||||
*t = p->makeThread(*m, 0, 0);
|
*t = p->makeThread(*m, 0, 0);
|
||||||
|
|
||||||
|
@ -2425,7 +2425,8 @@ namespace vm {
|
|||||||
Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
||||||
Finder* appFinder, Processor* processor, Classpath* classpath,
|
Finder* appFinder, Processor* processor, Classpath* classpath,
|
||||||
const char** properties, unsigned propertyCount,
|
const char** properties, unsigned propertyCount,
|
||||||
const char** arguments, unsigned argumentCount):
|
const char** arguments, unsigned argumentCount,
|
||||||
|
unsigned stackSizeInBytes):
|
||||||
vtable(&javaVMVTable),
|
vtable(&javaVMVTable),
|
||||||
system(system),
|
system(system),
|
||||||
heapClient(new (heap->allocate(sizeof(HeapClient)))
|
heapClient(new (heap->allocate(sizeof(HeapClient)))
|
||||||
@ -2448,6 +2449,7 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
|||||||
liveCount(0),
|
liveCount(0),
|
||||||
daemonCount(0),
|
daemonCount(0),
|
||||||
fixedFootprint(0),
|
fixedFootprint(0),
|
||||||
|
stackSizeInBytes(stackSizeInBytes),
|
||||||
localThread(0),
|
localThread(0),
|
||||||
stateLock(0),
|
stateLock(0),
|
||||||
heapLock(0),
|
heapLock(0),
|
||||||
|
@ -112,9 +112,6 @@ const unsigned ThreadBackupHeapSizeInBytes = 2 * 1024;
|
|||||||
const unsigned ThreadBackupHeapSizeInWords
|
const unsigned ThreadBackupHeapSizeInWords
|
||||||
= ThreadBackupHeapSizeInBytes / BytesPerWord;
|
= ThreadBackupHeapSizeInBytes / BytesPerWord;
|
||||||
|
|
||||||
const unsigned StackSizeInBytes = 128 * 1024;
|
|
||||||
const unsigned StackSizeInWords = StackSizeInBytes / BytesPerWord;
|
|
||||||
|
|
||||||
const unsigned ThreadHeapPoolSize = 64;
|
const unsigned ThreadHeapPoolSize = 64;
|
||||||
|
|
||||||
const unsigned FixedFootprintThresholdInBytes
|
const unsigned FixedFootprintThresholdInBytes
|
||||||
@ -1281,7 +1278,7 @@ class Machine {
|
|||||||
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
|
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
|
||||||
Processor* processor, Classpath* classpath, const char** properties,
|
Processor* processor, Classpath* classpath, const char** properties,
|
||||||
unsigned propertyCount, const char** arguments,
|
unsigned propertyCount, const char** arguments,
|
||||||
unsigned argumentCount);
|
unsigned argumentCount, unsigned stackSizeInBytes);
|
||||||
|
|
||||||
~Machine() {
|
~Machine() {
|
||||||
dispose();
|
dispose();
|
||||||
@ -1310,6 +1307,7 @@ class Machine {
|
|||||||
unsigned liveCount;
|
unsigned liveCount;
|
||||||
unsigned daemonCount;
|
unsigned daemonCount;
|
||||||
unsigned fixedFootprint;
|
unsigned fixedFootprint;
|
||||||
|
unsigned stackSizeInBytes;
|
||||||
System::Local* localThread;
|
System::Local* localThread;
|
||||||
System::Monitor* stateLock;
|
System::Monitor* stateLock;
|
||||||
System::Monitor* heapLock;
|
System::Monitor* heapLock;
|
||||||
@ -1639,6 +1637,12 @@ objectClass(Thread*, object o)
|
|||||||
return mask(cast<object>(o, 0));
|
return mask(cast<object>(o, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline unsigned
|
||||||
|
stackSizeInWords(Thread* t)
|
||||||
|
{
|
||||||
|
return t->m->stackSizeInBytes / BytesPerWord;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
enter(Thread* t, Thread::State state);
|
enter(Thread* t, Thread::State state);
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ usageAndExit(const char* name)
|
|||||||
(stderr, "usage: %s\n"
|
(stderr, "usage: %s\n"
|
||||||
"\t[{-cp|-classpath} <classpath>]\n"
|
"\t[{-cp|-classpath} <classpath>]\n"
|
||||||
"\t[-Xmx<maximum heap size>]\n"
|
"\t[-Xmx<maximum heap size>]\n"
|
||||||
|
"\t[-Xss<maximum stack size>]\n"
|
||||||
"\t[-Xbootclasspath/p:<classpath to prepend to bootstrap classpath>]\n"
|
"\t[-Xbootclasspath/p:<classpath to prepend to bootstrap classpath>]\n"
|
||||||
"\t[-Xbootclasspath:<bootstrap classpath>]\n"
|
"\t[-Xbootclasspath:<bootstrap classpath>]\n"
|
||||||
"\t[-Xbootclasspath/a:<classpath to append to bootstrap classpath>]\n"
|
"\t[-Xbootclasspath/a:<classpath to append to bootstrap classpath>]\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user