use virtual dispatch when calling Thread.run from VM

This commit is contained in:
Joel Dice 2008-06-25 10:28:11 -06:00
parent 2716169110
commit 61e65098df
3 changed files with 22 additions and 9 deletions

View File

@ -2872,6 +2872,17 @@ makeTrace(Thread* t, Thread* target)
return v.trace ? v.trace : makeArray(t, 0, true);
}
void
runJavaThread(Thread* t)
{
object method = resolveMethod(t, "java/lang/Thread", "run", "()V");
if (t->exception == 0) {
t->m->processor->invoke
(t, findMethod(t, method, objectClass(t, t->javaThread)),
t->javaThread);
}
}
void
noop()
{ }

View File

@ -1190,6 +1190,9 @@ inline void stress(Thread* t);
#endif // not VM_STRESS
void
runJavaThread(Thread* t);
class Thread {
public:
enum State {
@ -1242,8 +1245,7 @@ class Thread {
t->m->localThread->set(t);
t->m->processor->invoke
(t, "java/lang/Thread", "run", "()V", t->javaThread);
runJavaThread(t);
if (t->exception) {
printTrace(t, t->exception);
@ -2023,6 +2025,13 @@ findMethod(Thread* t, object class_, object name, object spec)
(t, class_, name, spec, findMethodInClass, makeNoSuchMethodError);
}
inline object
findMethod(Thread* t, object method, object class_)
{
return arrayBody(t, classVirtualTable(t, class_),
methodOffset(t, method));
}
inline unsigned
objectArrayLength(Thread* t UNUSED, object array)
{

View File

@ -125,13 +125,6 @@ isSpecialMethod(Thread* t, object method, object class_)
and isSuperclass(t, methodClass(t, method), class_);
}
inline object
findMethod(Thread* t, object method, object class_)
{
return arrayBody(t, classVirtualTable(t, class_),
methodOffset(t, method));
}
void*
resolveNativeMethod2(Thread* t, object method);