mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
fix process=interpret class initialization regression
A long time ago, I refactored the class initialization code in the VM, but did not notice until today that it had caused the process=interpret build to break on certain recursive initializations. In particular, we were not always detecting when a thread recursively tried to initialize a class it was already in the process of initializing, leading to the mistaken assumption that another thread was initializing it and that we should wait until it was done, in which case we would wait forever. This commit ensures that we always detect recursive initialization and short-circuit it.
This commit is contained in:
@ -761,12 +761,6 @@ invokeNative(Thread* t, object method)
|
||||
bool
|
||||
classInit2(Thread* t, object class_, unsigned ipOffset)
|
||||
{
|
||||
for (ClassInitList* list = t->classInitList; list; list = list->next) {
|
||||
if (list->class_ == class_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PROTECT(t, class_);
|
||||
|
||||
if (preInitClass(t, class_)) {
|
||||
@ -3111,6 +3105,26 @@ class MyProcessor: public Processor {
|
||||
// ignore
|
||||
}
|
||||
|
||||
virtual bool
|
||||
isInitializing(vm::Thread* vmt, object c)
|
||||
{
|
||||
Thread* t = static_cast<Thread*>(vmt);
|
||||
|
||||
for (ClassInitList* list = t->classInitList; list; list = list->next) {
|
||||
if (list->class_ == c) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (Thread::ClassInitStack* s = t->classInitStack; s; s = s->next) {
|
||||
if (s->class_ == c) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void
|
||||
visitObjects(vm::Thread* vmt, Heap::Visitor* v)
|
||||
{
|
||||
|
Reference in New Issue
Block a user