[vmkit-commits] [vmkit] r140948 - in /vmkit/trunk: include/j3/JavaJITCompiler.h include/j3/JavaLLVMCompiler.h lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Oct 1 07:30:50 PDT 2011
Author: geoffray
Date: Sat Oct 1 09:30:49 2011
New Revision: 140948
URL: http://llvm.org/viewvc/llvm-project?rev=140948&view=rev
Log:
Bugfix where we were calling a customized version from a non-customized method. Also support direct calls to customized methods.
Modified:
vmkit/trunk/include/j3/JavaJITCompiler.h
vmkit/trunk/include/j3/JavaLLVMCompiler.h
vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
Modified: vmkit/trunk/include/j3/JavaJITCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaJITCompiler.h?rev=140948&r1=140947&r2=140948&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaJITCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaJITCompiler.h Sat Oct 1 09:30:49 2011
@@ -84,7 +84,7 @@
class JavaJ3LazyJITCompiler : public JavaJITCompiler {
public:
- virtual bool needsCallback(JavaMethod* meth, bool* needsInit);
+ virtual bool needsCallback(JavaMethod* meth, Class* customizeFor, bool* needsInit);
virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign,
bool stat, llvm::BasicBlock* insert);
virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side);
Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=140948&r1=140947&r2=140948&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sat Oct 1 09:30:49 2011
@@ -212,10 +212,13 @@
llvm::FunctionPassManager* JavaFunctionPasses;
llvm::FunctionPassManager* JavaNativeFunctionPasses;
- virtual bool needsCallback(JavaMethod* meth, bool* needsInit) {
+ virtual bool needsCallback(JavaMethod* meth,
+ Class* customizeFor,
+ bool* needsInit) {
*needsInit = true;
return meth == NULL;
}
+
virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign,
bool stat, llvm::BasicBlock* insert) = 0;
Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=140948&r1=140947&r2=140948&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Oct 1 09:30:49 2011
@@ -111,31 +111,29 @@
Value* val = NULL; // The return from the method.
const UTF8* name = 0;
Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index, name);
+
+ bool customized = false;
+ if (!overridesThis
+ && (stack[stackSize() - signature->nbArguments - 1].bytecode == ALOAD_0)
+ && !isStatic(compilingMethod->access)) {
+ assert(meth != NULL);
+ isCustomizable = true;
+ if (customizeFor != NULL) {
+ meth = customizeFor->lookupMethodDontThrow(
+ meth->name, meth->type, false, true, NULL);
+ assert(meth);
+ canBeDirect = true;
+ customized = true;
+ assert(!meth->classDef->isInterface());
+ assert(!isAbstract(meth->access));
+ }
+ }
if ((cl && isFinal(cl->access)) ||
(meth && (isFinal(meth->access) || isPrivate(meth->access)))) {
canBeDirect = true;
}
- bool customized = false;
- if (!canBeDirect) {
- if (!overridesThis
- && (stack[stackSize() - signature->nbArguments - 1].bytecode == ALOAD_0)
- && !isStatic(compilingMethod->access)) {
- assert(meth != NULL);
- isCustomizable = true;
- if (customizeFor != NULL) {
- meth = customizeFor->lookupMethodDontThrow(
- meth->name, meth->type, false, true, NULL);
- assert(meth);
- canBeDirect = true;
- customized = true;
- assert(!meth->classDef->isInterface());
- assert(!isAbstract(meth->access));
- }
- }
- }
-
if (meth && isInterface(meth->classDef->access)) {
// This can happen because we compute miranda methods before resolving
// interfaces.
@@ -175,10 +173,12 @@
makeArgs(it, index, args, signature->nbArguments + 1);
JITVerifyNull(args[0]);
val = invokeInline(meth, args, customized);
- } else if (canBeDirect && !TheCompiler->needsCallback(meth, &needsInit)) {
+ } else if (canBeDirect &&
+ !TheCompiler->needsCallback(meth, customized ? customizeFor : NULL, &needsInit)) {
makeArgs(it, index, args, signature->nbArguments + 1);
JITVerifyNull(args[0]);
- val = invoke(TheCompiler->getMethod(meth, NULL), args, "", currentBlock);
+ val = invoke(TheCompiler->getMethod(meth, customized ? customizeFor : NULL),
+ args, "", currentBlock);
} else {
BasicBlock* endBlock = 0;
@@ -1554,7 +1554,7 @@
Value* func = 0;
bool needsInit = false;
- if (TheCompiler->needsCallback(meth, &needsInit)) {
+ if (TheCompiler->needsCallback(meth, NULL, &needsInit)) {
if (needsInit) {
// Make sure the class is loaded before materializing the method.
uint32 clIndex = ctpInfo->getClassIndexFromMethod(index);
@@ -1632,7 +1632,7 @@
Value* func = 0;
bool needsInit = false;
- if (TheCompiler->needsCallback(meth, &needsInit)) {
+ if (TheCompiler->needsCallback(meth, NULL, &needsInit)) {
func = TheCompiler->addCallback(compilingClass, index, signature,
true, currentBlock);
} else {
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=140948&r1=140947&r2=140948&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Oct 1 09:30:49 2011
@@ -410,9 +410,12 @@
return func;
}
-bool JavaJ3LazyJITCompiler::needsCallback(JavaMethod* meth, bool* needsInit) {
+bool JavaJ3LazyJITCompiler::needsCallback(JavaMethod* meth,
+ Class* customizeFor,
+ bool* needsInit) {
*needsInit = true;
- return (meth == NULL || meth->code == NULL);
+ return (meth == NULL ||
+ getMethod(meth, customizeFor)->hasExternalWeakLinkage());
}
JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID)
Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=140948&r1=140947&r2=140948&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sat Oct 1 09:30:49 2011
@@ -158,9 +158,11 @@
if (customizeFor != NULL) {
int len = strlen(buf);
+ UTF8Buffer buffer(customizeFor->name);
+ buffer.toCompileName("_Customized");
buf[len] = '_';
buf[len + 1] = '_';
- buf[len + 2] = 0;
+ memcpy(buf + len + 2, buffer.cString(), strlen(buffer.cString()) + 1);
}
return buf;
@@ -212,8 +214,10 @@
void LLVMMethodInfo::setCustomizedVersion(Class* cl, llvm::Function* F) {
assert(customizedVersions.size() == 0);
mvm::ThreadAllocator allocator;
- char* buf = GetMethodName(allocator, methodDef, cl);
- F->setName(buf);
+ if (Compiler->emitFunctionName() || JITEmitDebugInfo) {
+ char* buf = GetMethodName(allocator, methodDef, cl);
+ F->setName(buf);
+ }
methodFunction = NULL;
customizedVersions[cl] = F;
}
More information about the vmkit-commits
mailing list