[vmkit-commits] [vmkit] r136005 - in /vmkit/trunk/lib/J3: Compiler/JavaAOTCompiler.cpp Compiler/LLVMInfo.cpp VMCore/JavaTypes.h VMCore/JnjvmClassLoader.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Jul 25 16:05:46 PDT 2011
Author: geoffray
Date: Mon Jul 25 18:05:46 2011
New Revision: 136005
URL: http://llvm.org/viewvc/llvm-project?rev=136005&view=rev
Log:
1) Emit stubs used during execution of the trainer.
2) Make sure we don't try to recreate IMT and VT of precompiled classes.
Modified:
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
vmkit/trunk/lib/J3/VMCore/JavaTypes.h
vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=136005&r1=136004&r2=136005&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Mon Jul 25 18:05:46 2011
@@ -2275,6 +2275,7 @@
}
} while (changed);
+ // Add the bootstrap classes to the image.
for (std::vector<ZipArchive*>::iterator i = loader->bootArchives.begin(),
e = loader->bootArchives.end(); i != e; ++i) {
ZipArchive* archive = *i;
@@ -2286,6 +2287,38 @@
}
}
+ // Finally add used stubs to the image.
+ for (SignMap::iterator i = loader->javaSignatures->map.begin(),
+ e = loader->javaSignatures->map.end(); i != e; i++) {
+ Signdef* signature = i->second;
+ LLVMSignatureInfo* LSI = getSignatureInfo(signature);
+ if (signature->_staticCallBuf != 0) {
+ LSI->getStaticBuf();
+ }
+ if (signature->_virtualCallBuf != 0) {
+ LSI->getVirtualBuf();
+ }
+ if (signature->_staticCallAP != 0) {
+ LSI->getStaticAP();
+ }
+ if (signature->_virtualCallAP != 0) {
+ LSI->getVirtualAP();
+ }
+ if (signature->_virtualCallStub != 0) {
+ LSI->getVirtualStub();
+ }
+ if (signature->_specialCallStub != 0) {
+ LSI->getSpecialStub();
+ }
+ if (signature->_staticCallStub != 0) {
+ LSI->getStaticStub();
+ }
+ }
+
+ // Finally emit the stub for the main signature.
+ Signdef* mainSignature =
+ loader->constructSign(loader->asciizConstructUTF8("([Ljava/lang/String;)V"));
+ getSignatureInfo(mainSignature)->getStaticBuf();
CreateStaticInitializer();
}
Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=136005&r1=136004&r2=136005&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Mon Jul 25 18:05:46 2011
@@ -72,7 +72,9 @@
virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size);
// TODO: put that elsewhere.
- if (Compiler == classDef->classLoader->getCompiler()) {
+ // The class is resolved if it was precompiled.
+ if ((!classDef->isResolved() || Compiler->isStaticCompiling())
+ && Compiler == classDef->classLoader->getCompiler()) {
for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) {
JavaField& field = classDef->virtualFields[i];
field.ptrOffset = sl->getElementOffset(i + 1);
@@ -396,18 +398,23 @@
std::vector<Value*> Args;
J3Intrinsics& Intrinsics = *Compiler->getIntrinsics();
- std::string name;
+ Function* res = NULL;
if (Compiler->isStaticCompiling()) {
- name += UTF8Buffer(signature->keyName).cString();
- name += virt ? "virtual_ap" : "static_ap";
+ mvm::ThreadAllocator allocator;
+ const char* type = virt ? "virtual_ap" : "static_ap";
+ char* buf = (char*)allocator.Allocate(
+ (signature->keyName->size << 1) + 1 + 11);
+ signature->nativeName(buf, type);
+ res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(),
+ GlobalValue::ExternalLinkage, buf,
+ Compiler->getLLVMModule());
+
+
} else {
- name = "";
+ res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(),
+ GlobalValue::ExternalLinkage, "",
+ Compiler->getLLVMModule());
}
-
- Function* res = Function::Create(virt ? getVirtualBufType() :
- getStaticBufType(),
- GlobalValue::ExternalLinkage, name,
- Compiler->getLLVMModule());
LLVMContext& context = Compiler->getLLVMModule()->getContext();
BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res);
@@ -470,18 +477,23 @@
std::vector<Value*> TempArgs;
J3Intrinsics& Intrinsics = *Compiler->getIntrinsics();
- std::string name;
+ Function* stub = NULL;
if (Compiler->isStaticCompiling()) {
- name += UTF8Buffer(signature->keyName).cString();
- name += virt ? "virtual_stub" : special ? "special_stub" : "static_stub";
+ mvm::ThreadAllocator allocator;
+ const char* type = virt ? "virtual_stub" : special ? "special_stub" : "static_stub";
+ char* buf = (char*)allocator.Allocate(
+ (signature->keyName->size << 1) + 1 + 11);
+ signature->nativeName(buf, type);
+ stub = Function::Create((virt || special)? getVirtualType() : getStaticType(),
+ GlobalValue::ExternalLinkage, buf,
+ Compiler->getLLVMModule());
+
+
} else {
- name = "";
+ stub = Function::Create((virt || special)? getVirtualType() : getStaticType(),
+ GlobalValue::ExternalLinkage, "",
+ Compiler->getLLVMModule());
}
-
- Function* stub = Function::Create((virt || special) ? getVirtualType() :
- getStaticType(),
- GlobalValue::ExternalLinkage, name,
- Compiler->getLLVMModule());
LLVMContext& context = Compiler->getLLVMModule()->getContext();
BasicBlock* currentBlock = BasicBlock::Create(context, "enter", stub);
Modified: vmkit/trunk/lib/J3/VMCore/JavaTypes.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaTypes.h?rev=136005&r1=136004&r2=136005&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaTypes.h Mon Jul 25 18:05:46 2011
@@ -428,6 +428,8 @@
/// type.
///
Typedef* arguments[1];
+
+ friend class JavaAOTCompiler;
};
} // end namespace j3
Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h?rev=136005&r1=136004&r2=136005&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h Mon Jul 25 18:05:46 2011
@@ -305,6 +305,7 @@
friend class Class;
friend class CommonClass;
friend class StringList;
+ friend class JavaAOTCompiler;
};
/// JnjvmBootstrapLoader - This class is for the bootstrap class loader, which
More information about the vmkit-commits
mailing list