From 811fbf0ab9cc805cdb4bed45edd8e6f2b4bfeeba Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 8 Jan 2008 14:23:49 -0700 Subject: [PATCH] don't try to compile a method twice if it was compiled as a side-effect of initializing a class --- src/compile.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 5b496e3073..c049a1e996 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -3384,11 +3384,9 @@ void logCompile(const void* code, unsigned size, const char* class_, const char* name, const char* spec) { - if (Verbose) { - fprintf(stderr, "%s.%s%s from %p to %p\n", - class_, name, spec, code, - static_cast(code) + size); - } + fprintf(stderr, "%s.%s%s from %p to %p\n", + class_, name, spec, code, + static_cast(code) + size); } void @@ -3717,6 +3715,11 @@ compile(MyThread* t, Context* context) { Compiler* c = context->c; +// fprintf(stderr, "compiling %s.%s%s\n", +// &byteArrayBody(t, className(t, methodClass(t, context->method)), 0), +// &byteArrayBody(t, methodName(t, context->method), 0), +// &byteArrayBody(t, methodSpec(t, context->method), 0)); + c->prologue(); object code = methodCode(t, context->method); @@ -4645,14 +4648,16 @@ compile(MyThread* t, object method) initClass(t, methodClass(t, method)); if (UNLIKELY(t->exception)) return; - Context context(t, method, p->indirectCaller); + if (methodCompiled(t, method) == p->getDefaultCompiled(t)) { + Context context(t, method, p->indirectCaller); - object compiled = compile(t, &context); - set(t, method, MethodCompiled, compiled); + object compiled = compile(t, &context); + set(t, method, MethodCompiled, compiled); - if (methodVirtual(t, method)) { - classVtable(t, methodClass(t, method), methodOffset(t, method)) - = &singletonValue(t, compiled, 0); + if (methodVirtual(t, method)) { + classVtable(t, methodClass(t, method), methodOffset(t, method)) + = &singletonValue(t, compiled, 0); + } } } }