initialize vtables with pointers to JIT function, including native methods, since this allows code shrinkers to eliminate unused methods without confusing the VM

This commit is contained in:
Joel Dice 2008-01-20 15:05:59 -07:00
parent a60dafaf4f
commit 422133d1ba

View File

@ -380,7 +380,9 @@ unsigned
localSize(MyThread* t, object method) localSize(MyThread* t, object method)
{ {
unsigned size = codeMaxLocals(t, methodCode(t, method)); unsigned size = codeMaxLocals(t, methodCode(t, method));
if (methodFlags(t, method) & ACC_SYNCHRONIZED) { if ((methodFlags(t, method) & (ACC_SYNCHRONIZED | ACC_STATIC))
== ACC_SYNCHRONIZED)
{
++ size; ++ size;
} }
return size; return size;
@ -1603,8 +1605,8 @@ handleEntrance(MyThread* t, Frame* frame)
{ {
object method = frame->context->method; object method = frame->context->method;
if ((methodFlags(t, method) & ACC_SYNCHRONIZED) if ((methodFlags(t, method) & (ACC_SYNCHRONIZED | ACC_STATIC))
and ((methodFlags(t, method) & ACC_STATIC) == 0)) == ACC_SYNCHRONIZED)
{ {
Compiler* c = frame->c; Compiler* c = frame->c;
@ -4428,14 +4430,10 @@ class MyProcessor: public Processor {
object class_, object class_,
object code) object code)
{ {
object compiled
= ((flags & ACC_NATIVE)
? getNativeCompiled(static_cast<MyThread*>(t))
: getDefaultCompiled(static_cast<MyThread*>(t)));
return vm::makeMethod return vm::makeMethod
(t, vmFlags, returnCode, parameterCount, parameterFootprint, flags, (t, vmFlags, returnCode, parameterCount, parameterFootprint, flags,
offset, name, spec, class_, code, compiled); offset, name, spec, class_, code,
getDefaultCompiled(static_cast<MyThread*>(t)));
} }
virtual object virtual object
@ -4465,13 +4463,11 @@ class MyProcessor: public Processor {
virtual void virtual void
initVtable(Thread* t, object c) initVtable(Thread* t, object c)
{ {
for (unsigned i = 0; i < classLength(t, c); ++i) { void* compiled = &singletonBody
object compiled (t, getDefaultCompiled(static_cast<MyThread*>(t)), 0);
= ((classFlags(t, c) & ACC_NATIVE)
? getNativeCompiled(static_cast<MyThread*>(t))
: getDefaultCompiled(static_cast<MyThread*>(t)));
classVtable(t, c, i) = &singletonBody(t, compiled, 0); for (unsigned i = 0; i < classLength(t, c); ++i) {
classVtable(t, c, i) = compiled;
} }
} }
@ -4715,9 +4711,14 @@ compile(MyThread* t, object method)
if (UNLIKELY(t->exception)) return; if (UNLIKELY(t->exception)) return;
if (methodCompiled(t, method) == p->getDefaultCompiled(t)) { if (methodCompiled(t, method) == p->getDefaultCompiled(t)) {
Context context(t, method, p->indirectCaller); object compiled;
if (methodFlags(t, method) & ACC_NATIVE) {
compiled = p->getNativeCompiled(t);
} else {
Context context(t, method, p->indirectCaller);
compiled = compile(t, &context);
}
object compiled = compile(t, &context);
set(t, method, MethodCompiled, compiled); set(t, method, MethodCompiled, compiled);
if (methodVirtual(t, method)) { if (methodVirtual(t, method)) {