fix GC safety bugs

This commit is contained in:
Joel Dice 2010-12-09 22:17:57 -07:00
parent 2d0ff83653
commit 651ad20fc3
3 changed files with 9 additions and 7 deletions

View File

@ -1084,14 +1084,14 @@ interceptFileOperations(Thread* t)
(t, root(t, Machine::BootLoader), "java/io/FileInputStream"); (t, root(t, Machine::BootLoader), "java/io/FileInputStream");
if (fileInputStreamClass == 0) return; if (fileInputStreamClass == 0) return;
PROTECT(t, fileInputStreamClass);
object fileInputStreamFdField = findFieldInClass2 object fileInputStreamFdField = findFieldInClass2
(t, fileInputStreamClass, "fd", "Ljava/io/FileDescriptor;"); (t, fileInputStreamClass, "fd", "Ljava/io/FileDescriptor;");
if (fileInputStreamFdField == 0) return; if (fileInputStreamFdField == 0) return;
cp->fileInputStreamFdField = fieldOffset(t, fileInputStreamFdField); cp->fileInputStreamFdField = fieldOffset(t, fileInputStreamFdField);
PROTECT(t, fileInputStreamClass);
intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V", intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V",
voidPointer(openFile)); voidPointer(openFile));

View File

@ -1903,14 +1903,15 @@ bootJavaClass(Thread* t, Machine::Type type, int superType, const char* name,
PROTECT(t, bootMethod); PROTECT(t, bootMethod);
object n = makeByteArray(t, name); object n = makeByteArray(t, name);
PROTECT(t, n);
object class_ = vm::type(t, type); object class_ = vm::type(t, type);
PROTECT(t, class_);
set(t, class_, ClassName, n); set(t, class_, ClassName, n);
object vtable; object vtable;
if (vtableLength >= 0) { if (vtableLength >= 0) {
PROTECT(t, class_);
vtable = makeArray(t, vtableLength); vtable = makeArray(t, vtableLength);
for (int i = 0; i < vtableLength; ++ i) { for (int i = 0; i < vtableLength; ++ i) {
arrayBody(t, vtable, i) = bootMethod; arrayBody(t, vtable, i) = bootMethod;

View File

@ -1513,7 +1513,8 @@ shutDown(Thread* t);
inline void inline void
stress(Thread* t) stress(Thread* t)
{ {
if ((t->flags & (Thread::StressFlag | Thread::TracingFlag)) == 0 if ((not t->m->unsafe)
and (t->flags & (Thread::StressFlag | Thread::TracingFlag)) == 0
and t->state != Thread::NoState and t->state != Thread::NoState
and t->state != Thread::IdleState) and t->state != Thread::IdleState)
{ {
@ -3166,10 +3167,10 @@ getMethodRuntimeData(Thread* t, object method)
inline object inline object
getJClass(Thread* t, object c) getJClass(Thread* t, object c)
{ {
object jclass = classRuntimeDataJclass(t, getClassRuntimeData(t, c));
if (jclass == 0) {
PROTECT(t, c); PROTECT(t, c);
object jclass = classRuntimeDataJclass(t, getClassRuntimeData(t, c));
if (jclass == 0) {
ACQUIRE(t, t->m->classLock); ACQUIRE(t, t->m->classLock);
jclass = classRuntimeDataJclass(t, getClassRuntimeData(t, c)); jclass = classRuntimeDataJclass(t, getClassRuntimeData(t, c));