[vmkit-commits] [vmkit] r135808 - in /vmkit/trunk: lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.cpp lib/J3/VMCore/JnjvmClassLoader.cpp lib/Mvm/Compiler/JIT.cpp mmtk/inline/InlineMethods.cpp mmtk/magic/LowerJavaRT.cpp mmtk/mmtk-alloc/Selected.cpp mmtk/mmtk-j3/Memory.cpp tools/precompiler/Precompiler.cpp tools/vmjc/vmjc.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Jul 22 14:32:31 PDT 2011
Author: geoffray
Date: Fri Jul 22 16:32:31 2011
New Revision: 135808
URL: http://llvm.org/viewvc/llvm-project?rev=135808&view=rev
Log:
Few changes to make AOT precompiler work.
Modified:
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
vmkit/trunk/mmtk/inline/InlineMethods.cpp
vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
vmkit/trunk/mmtk/mmtk-j3/Memory.cpp
vmkit/trunk/tools/precompiler/Precompiler.cpp
vmkit/trunk/tools/vmjc/vmjc.cpp
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Fri Jul 22 16:32:31 2011
@@ -57,7 +57,7 @@
} else if (classDef->isArray()) {
Constant* C = CreateConstantFromClassArray(classDef->asArrayClass());
varGV->setInitializer(C);
- } else if (classDef->isPrimitive()) {
+ } else if (classDef->isPrimitive() && compileRT) {
Constant* C =
CreateConstantFromClassPrimitive(classDef->asPrimitiveClass());
varGV->setInitializer(C);
@@ -2186,7 +2186,6 @@
}
void JavaAOTCompiler::compileClassLoader(JnjvmBootstrapLoader* loader) {
- loader->setCompiler(this);
compileRT = true;
precompile = true;
addJavaPasses();
@@ -2215,10 +2214,19 @@
parseFunction(meth);
}
- for (native_class_iterator i = nativeClasses.begin(),
- e = nativeClasses.end(); i != e; ++i) {
- AddInitializerToClass(i->second, i->first);
- }
+ bool changed = false;
+ do {
+ changed = false;
+ for (native_class_iterator i = nativeClasses.begin(),
+ e = nativeClasses.end(); i != e; ++i) {
+ if (!i->second->hasInitializer()) {
+ changed = true;
+ AddInitializerToClass(i->second, i->first);
+ }
+ }
+ } while (changed);
+
+ CreateStaticInitializer();
}
/// compileAllStubs - Compile all the native -> Java stubs.
Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Fri Jul 22 16:32:31 2011
@@ -406,7 +406,7 @@
Function* res = Function::Create(virt ? getVirtualBufType() :
getStaticBufType(),
- GlobalValue::InternalLinkage, name,
+ GlobalValue::ExternalLinkage, name,
Compiler->getLLVMModule());
LLVMContext& context = Compiler->getLLVMModule()->getContext();
@@ -480,7 +480,7 @@
Function* stub = Function::Create((virt || special) ? getVirtualType() :
getStaticType(),
- GlobalValue::InternalLinkage, name,
+ GlobalValue::ExternalLinkage, name,
Compiler->getLLVMModule());
LLVMContext& context = Compiler->getLLVMModule()->getContext();
Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Fri Jul 22 16:32:31 2011
@@ -53,7 +53,7 @@
this->name = name;
}
-Attribut* Class::lookupAttribut(const UTF8* key ) {
+Attribut* Class::lookupAttribut(const UTF8* key) {
for (uint32 i = 0; i < nbAttributs; ++i) {
Attribut* cur = &(attributs[i]);
if (cur->name->equals(key)) return cur;
@@ -62,7 +62,7 @@
return 0;
}
-Attribut* JavaField::lookupAttribut(const UTF8* key ) {
+Attribut* JavaField::lookupAttribut(const UTF8* key) {
for (uint32 i = 0; i < nbAttributs; ++i) {
Attribut* cur = &(attributs[i]);
if (cur->name->equals(key)) return cur;
@@ -71,7 +71,7 @@
return 0;
}
-Attribut* JavaMethod::lookupAttribut(const UTF8* key ) {
+Attribut* JavaMethod::lookupAttribut(const UTF8* key) {
for (uint32 i = 0; i < nbAttributs; ++i) {
Attribut* cur = &(attributs[i]);
if (cur->name->equals(key)) return cur;
Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Fri Jul 22 16:32:31 2011
@@ -1198,10 +1198,6 @@
JavaField& field = realCl->staticFields[i];
JCL->hashUTF8->insert(field.name);
JCL->hashUTF8->insert(field.type);
- if (field.getSignature()->isReference()
- && (field.lookupAttribut(Attribut::constantAttribut) != NULL)) {
- field.InitStaticField(JCL->getIsolate());
- }
}
for (uint32 i = 0; i< realCl->nbVirtualFields; ++i) {
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Fri Jul 22 16:32:31 2011
@@ -48,12 +48,6 @@
#include <dlfcn.h>
#include <sys/mman.h>
-#if defined(__MACH__)
-#define SELF_HANDLE RTLD_DEFAULT
-#else
-#define SELF_HANDLE 0
-#endif
-
using namespace mvm;
using namespace llvm;
@@ -156,18 +150,15 @@
}
+extern "C" void MMTk_InlineMethods(llvm::Module* module);
+
BaseIntrinsics::BaseIntrinsics(llvm::Module* module) {
module->setDataLayout(MvmModule::globalModule->getDataLayout());
module->setTargetTriple(MvmModule::globalModule->getTargetTriple());
LLVMContext& Context = module->getContext();
- typedef void (*init_inline_t)(llvm::Module* module);
- static const char* MMTkSymbol = "MMTk_InlineMethods";
- init_inline_t init_inline =
- (init_inline_t)(uintptr_t)dlsym(SELF_HANDLE, MMTkSymbol);
- if (init_inline != NULL) init_inline(module);
-
+ MMTk_InlineMethods(module);
mvm::llvm_runtime::makeLLVMModuleContents(module);
// Type declaration
Modified: vmkit/trunk/mmtk/inline/InlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/inline/InlineMethods.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/mmtk/inline/InlineMethods.cpp (original)
+++ vmkit/trunk/mmtk/inline/InlineMethods.cpp Fri Jul 22 16:32:31 2011
@@ -35,11 +35,11 @@
#include "MMTkNonHeapWriteInline.inc"
}
-extern "C" void MMTk_InlineMethods(llvm::Module* module) {
- mmtk_malloc::makeLLVMFunction(module);
- //mmtk_field_write::makeLLVMFunction(module);
- //mmtk_array_write::makeLLVMFunction(module);
- //mmtk_non_heap_write::makeLLVMFunction(module);
}
+extern "C" void MMTk_InlineMethods(llvm::Module* module) {
+ //mmtk::mmtk_malloc::makeLLVMFunction(module);
+ //mmtk::mmtk_field_write::makeLLVMFunction(module);
+ //mmtk::mmtk_array_write::makeLLVMFunction(module);
+ //mmtk::mmtk_non_heap_write::makeLLVMFunction(module);
}
Modified: vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerJavaRT.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/mmtk/magic/LowerJavaRT.cpp (original)
+++ vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Fri Jul 22 16:32:31 2011
@@ -69,6 +69,7 @@
if (!strncmp(GV.getName().data(), "JnJVM_java", 10) ||
!strncmp(GV.getName().data(), "java", 4) ||
!strncmp(GV.getName().data(), "JnJVM_gnu", 9) ||
+ !strncmp(GV.getName().data(), "_3", 2) ||
!strncmp(GV.getName().data(), "gnu", 3)) {
GV.replaceAllUsesWith(Constant::getNullValue(GV.getType()));
GV.eraseFromParent();
@@ -92,9 +93,4 @@
return Changed;
}
-
-ModulePass* createLowerJavaRT() {
- return new LowerJavaRT();
-}
-
}
Modified: vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp Fri Jul 22 16:32:31 2011
@@ -164,7 +164,7 @@
#else
uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
#endif
- void* baseAddr = mmap((void*)0x30000000, 0x30000000, PROT_READ | PROT_WRITE,
+ void* baseAddr = mmap((void*)0x60000000, 0x40000000, PROT_READ | PROT_WRITE,
flags, -1, 0);
if (baseAddr == MAP_FAILED) {
perror("mmap");
Modified: vmkit/trunk/mmtk/mmtk-j3/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/Memory.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/Memory.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/Memory.cpp Fri Jul 22 16:32:31 2011
@@ -16,19 +16,19 @@
namespace mmtk {
extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapStartConstant__ (MMTkObject* M) {
- return (uintptr_t)0x30000000;
+ return (uintptr_t)0x60000000;
}
extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapEndConstant__ (MMTkObject* M) {
- return (uintptr_t)0x60000000;
+ return (uintptr_t)0xa0000000;
}
extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableStartConstant__ (MMTkObject* M) {
- return (uintptr_t)0x30000000;
+ return (uintptr_t)0x60000000;
}
extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableEndConstant__ (MMTkObject* M) {
- return (uintptr_t)0x60000000;
+ return (uintptr_t)0xa0000000;
}
extern "C" sint32
Modified: vmkit/trunk/tools/precompiler/Precompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/precompiler/Precompiler.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/tools/precompiler/Precompiler.cpp (original)
+++ vmkit/trunk/tools/precompiler/Precompiler.cpp Fri Jul 22 16:32:31 2011
@@ -24,6 +24,7 @@
#include "j3/JavaAOTCompiler.h"
#include "j3/JavaJITCompiler.h"
+#include "../../lib/J3/VMCore/JavaThread.h"
#include "../../lib/J3/VMCore/JnjvmClassLoader.h"
#include "../../lib/J3/VMCore/Jnjvm.h"
@@ -40,6 +41,16 @@
#include "FrametablesSymbols.inc"
};
+
+static void mainCompilerLoaderStart(JavaThread* th) {
+ Jnjvm* vm = th->getJVM();
+ JnjvmBootstrapLoader* bootstrapLoader = vm->bootstrapLoader;
+ JavaAOTCompiler* M = (JavaAOTCompiler*)bootstrapLoader->getCompiler();
+ M->compileClassLoader(bootstrapLoader);
+ vm->exit();
+}
+
+
int main(int argc, char **argv, char **envp) {
llvm::llvm_shutdown_obj X;
@@ -63,7 +74,13 @@
// Now AOT Compile all compiled methods.
JavaAOTCompiler* AOT = new JavaAOTCompiler("AOT");
- AOT->compileClassLoader(loader);
+ loader->setCompiler(AOT);
+
+ vm->doExit = false;
+ JavaThread* th = new JavaThread(vm);
+ vm->setMainThread(th);
+ th->start((void (*)(mvm::Thread*))mainCompilerLoaderStart);
+ vm->waitForExit();
AOT->printStats();
Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=135808&r1=135807&r2=135808&view=diff
==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Fri Jul 22 16:32:31 2011
@@ -224,3 +224,6 @@
return 0;
}
+// Because MMTk has not been created yet, provide this method in order to link.
+extern "C" void MMTk_InlineMethods(llvm::Module* module) {
+}
More information about the vmkit-commits
mailing list