JIT-related GC safety fixes

This commit is contained in:
Joel Dice 2007-12-16 15:41:07 -07:00
parent fb29fd11d8
commit e4fbadd051
4 changed files with 35 additions and 12 deletions

View File

@ -28,7 +28,7 @@ src = src
classpath = classpath classpath = classpath
test = test test = test
input = $(test-build)/Exceptions.class input = $(test-build)/GC.class
build-cxx = g++ build-cxx = g++
build-cc = gcc build-cc = gcc
@ -109,10 +109,10 @@ ifeq ($(mode),debug)
cflags += -O0 -g3 cflags += -O0 -g3
endif endif
ifeq ($(mode),stress) ifeq ($(mode),stress)
cflags += -O0 -g3 -DNDEBUG -DVM_STRESS cflags += -O0 -g3 -DVM_STRESS
endif endif
ifeq ($(mode),stress-major) ifeq ($(mode),stress-major)
cflags += -O0 -g3 -DNDEBUG -DVM_STRESS -DVM_STRESS_MAJOR cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
endif endif
ifeq ($(mode),fast) ifeq ($(mode),fast)
cflags += -O3 -g3 -DNDEBUG cflags += -O3 -g3 -DNDEBUG

View File

@ -2914,6 +2914,7 @@ finish(MyThread* t, Compiler* c, object method, Vector* objectPool,
if (method) { if (method) {
PROTECT(t, method); PROTECT(t, method);
PROTECT(t, result);
for (unsigned i = 0; i < objectPool->length(); i += sizeof(PoolElement)) { for (unsigned i = 0; i < objectPool->length(); i += sizeof(PoolElement)) {
PoolElement* e = objectPool->peek<PoolElement>(i); PoolElement* e = objectPool->peek<PoolElement>(i);
@ -3076,17 +3077,20 @@ void
compile(MyThread* t, object method); compile(MyThread* t, object method);
void* void*
compileMethod(MyThread* t) compileMethod2(MyThread* t)
{ {
object node = findTraceNode(t, *static_cast<void**>(t->stack)); object node = findTraceNode(t, *static_cast<void**>(t->stack));
PROTECT(t, node);
object target = resolveTarget(t, t->stack, traceNodeTarget(t, node)); object target = resolveTarget(t, t->stack, traceNodeTarget(t, node));
PROTECT(t, target);
if (LIKELY(t->exception == 0)) { if (LIKELY(t->exception == 0)) {
compile(t, target); compile(t, target);
} }
if (UNLIKELY(t->exception)) { if (UNLIKELY(t->exception)) {
unwind(t); return 0;
} else { } else {
if (not traceNodeVirtualCall(t, node)) { if (not traceNodeVirtualCall(t, node)) {
Compiler* c = makeCompiler(t->m->system, 0); Compiler* c = makeCompiler(t->m->system, 0);
@ -3098,6 +3102,18 @@ compileMethod(MyThread* t)
} }
} }
void*
compileMethod(MyThread* t)
{
void* r = compileMethod2(t);
if (UNLIKELY(t->exception)) {
unwind(t);
} else {
return r;
}
}
uint64_t uint64_t
invokeNative2(MyThread* t, object method) invokeNative2(MyThread* t, object method)
{ {
@ -3302,7 +3318,7 @@ visitStack(MyThread* t, Heap::Visitor* v)
void** stack = static_cast<void**>(t->stack); void** stack = static_cast<void**>(t->stack);
MyThread::CallTrace* trace = t->trace; MyThread::CallTrace* trace = t->trace;
while (true) { while (stack) {
object node = findTraceNode(t, *stack); object node = findTraceNode(t, *stack);
if (node) { if (node) {
PROTECT(t, node); PROTECT(t, node);
@ -3316,7 +3332,7 @@ visitStack(MyThread* t, Heap::Visitor* v)
visitParameters(t, v, base, method); visitParameters(t, v, base, method);
} }
visitStackAndLocals(t, v, base, method); visitStackAndLocals(t, v, base, node);
stack = static_cast<void**>(base) + 1; stack = static_cast<void**>(base) + 1;
base = *static_cast<void**>(base); base = *static_cast<void**>(base);
@ -3838,8 +3854,6 @@ compile(MyThread* t, object method)
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
if (methodCompiled(t, method) == p->getDefaultCompiled(t)) { if (methodCompiled(t, method) == p->getDefaultCompiled(t)) {
PROTECT(t, method);
Compiler* c = makeCompiler(t->m->system, p->indirectCaller); Compiler* c = makeCompiler(t->m->system, p->indirectCaller);
object compiled = compile(t, c, method); object compiled = compile(t, c, method);

View File

@ -332,7 +332,7 @@ class Segment {
} }
void replaceWith(Segment* s) { void replaceWith(Segment* s) {
system(context)->free(data); if (data) system(context)->free(data);
data = s->data; data = s->data;
s->data = 0; s->data = 0;
@ -350,7 +350,7 @@ class Segment {
abort(context); abort(context);
} }
} else { } else {
map = 0; assert(context, map == 0);
} }
} }
@ -467,7 +467,7 @@ class Context {
ageMap(&gen1, max(1, log(TenureThreshold)), 1, 0, false), ageMap(&gen1, max(1, log(TenureThreshold)), 1, 0, false),
gen1(this, &ageMap, 0, 0), gen1(this, &ageMap, 0, 0),
nextAgeMap(&nextGen1, max(1, log(TenureThreshold)), 1, 0, false), nextAgeMap(&nextGen1, max(1, log(TenureThreshold)), 1, 0, false),
nextGen1(this, &nextAgeMap, 0, 0), nextGen1(this, &nextAgeMap, 0, 0),
pointerMap(&gen2, 1, 1, 0, true), pointerMap(&gen2, 1, 1, 0, true),

View File

@ -2777,6 +2777,11 @@ intern(Thread* t, object s)
void void
collect(Thread* t, Heap::CollectionType type) collect(Thread* t, Heap::CollectionType type)
{ {
#ifdef VM_STRESS
bool stress = t->stress;
if (not stress) t->stress = true;
#endif
Machine* m = t->m; Machine* m = t->m;
m->unsafe = true; m->unsafe = true;
@ -2800,6 +2805,10 @@ collect(Thread* t, Heap::CollectionType type)
m->heapPoolIndex = 0; m->heapPoolIndex = 0;
m->fixedFootprint = 0; m->fixedFootprint = 0;
#ifdef VM_STRESS
if (not stress) t->stress = false;
#endif
} }
void void