[vmkit-commits] [vmkit] r94896 - in /vmkit/trunk: include/j3/JnjvmModule.h include/j3/JnjvmModuleProvider.h lib/J3/Compiler/JITInfo.cpp lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JnjvmModule.cpp lib/J3/Compiler/JnjvmModuleProvider.cpp lib/Mvm/Compiler/JIT.cpp tools/vmjc/vmjc.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Jan 30 08:29:46 PST 2010
Author: geoffray
Date: Sat Jan 30 10:29:45 2010
New Revision: 94896
URL: http://llvm.org/viewvc/llvm-project?rev=94896&view=rev
Log:
Move to new LLVM interface for materializing functions.
Modified:
vmkit/trunk/include/j3/JnjvmModule.h
vmkit/trunk/include/j3/JnjvmModuleProvider.h
vmkit/trunk/lib/J3/Compiler/JITInfo.cpp
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
vmkit/trunk/tools/vmjc/vmjc.cpp
Modified: vmkit/trunk/include/j3/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JnjvmModule.h (original)
+++ vmkit/trunk/include/j3/JnjvmModule.h Sat Jan 30 10:29:45 2010
@@ -28,6 +28,7 @@
class FunctionType;
class GlobalVariable;
class GCFunctionInfo;
+ class GVMaterializer;
class Module;
class Type;
class Value;
@@ -376,7 +377,7 @@
protected:
llvm::Module* TheModule;
- llvm::ModuleProvider* TheModuleProvider;
+ llvm::GVMaterializer* TheModuleProvider;
JnjvmModule JavaIntrinsics;
void addJavaPasses();
Modified: vmkit/trunk/include/j3/JnjvmModuleProvider.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModuleProvider.h?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JnjvmModuleProvider.h (original)
+++ vmkit/trunk/include/j3/JnjvmModuleProvider.h Sat Jan 30 10:29:45 2010
@@ -10,25 +10,27 @@
#ifndef JNJVM_MODULE_PROVIDER_H
#define JNJVM_MODULE_PROVIDER_H
-#include <llvm/ModuleProvider.h>
+#include <llvm/GVMaterializer.h>
namespace j3 {
class JavaJITCompiler;
-class JnjvmModuleProvider : public llvm::ModuleProvider {
+class JnjvmModuleProvider : public llvm::GVMaterializer {
public:
JavaJITCompiler* Comp;
+ llvm::Module* TheModule;
JnjvmModuleProvider(llvm::Module* M, JavaJITCompiler* C);
~JnjvmModuleProvider();
- bool materializeFunction(llvm::Function *F, std::string *ErrInfo = 0);
-
- llvm::Module* materializeModule(std::string *ErrInfo = 0) {
- return TheModule;
+ virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0);
+ virtual bool isMaterializable(const llvm::GlobalValue*) const;
+ virtual bool isDematerializable(const llvm::GlobalValue*) const {
+ return false;
}
+ virtual bool MaterializeModule(llvm::Module*, std::string*) { return true; }
};
} // End j3 namespace
Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Sat Jan 30 10:29:45 2010
@@ -162,20 +162,20 @@
methodFunction = Mod->getLLVMModule()->getFunction(buf);
if (!methodFunction) {
methodFunction = Function::Create(getFunctionType(),
- GlobalValue::GhostLinkage, buf,
+ GlobalValue::ExternalWeakLinkage, buf,
Mod->getLLVMModule());
} else {
assert(methodFunction->getFunctionType() == getFunctionType() &&
"Type mismatch");
if (methodFunction->isDeclaration()) {
- methodFunction->setLinkage(GlobalValue::GhostLinkage);
+ methodFunction->setLinkage(GlobalValue::ExternalWeakLinkage);
}
}
} else {
methodFunction = Function::Create(getFunctionType(),
- GlobalValue::GhostLinkage,
+ GlobalValue::ExternalWeakLinkage,
"", Mod->getLLVMModule());
}
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Jan 30 10:29:45 2010
@@ -12,7 +12,6 @@
#include "llvm/Instructions.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
#include "llvm/PassManager.h"
#include "llvm/Support/raw_ostream.h"
@@ -1617,7 +1616,6 @@
ObjectPrinter = Function::Create(FTy, GlobalValue::ExternalLinkage,
"printJavaObject", getLLVMModule());
- TheModuleProvider = new ExistingModuleProvider(TheModule);
addJavaPasses();
}
Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sat Jan 30 10:29:45 2010
@@ -350,7 +350,7 @@
// We are jitting. Take the lock.
JnjvmModule::protectIR();
- if (func->hasNotBeenReadFromBitcode()) {
+ if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) {
JavaJIT jit(this, meth, func);
if (isNative(meth->access)) {
jit.nativeCompile();
@@ -390,13 +390,13 @@
}
void JavaLLVMCompiler::addJavaPasses() {
- JavaNativeFunctionPasses = new FunctionPassManager(TheModuleProvider);
+ JavaNativeFunctionPasses = new FunctionPassManager(TheModule);
JavaNativeFunctionPasses->add(new TargetData(TheModule));
// Lower constant calls to lower things like getClass used
// on synchronized methods.
JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics()));
- JavaFunctionPasses = new FunctionPassManager(TheModuleProvider);
+ JavaFunctionPasses = new FunctionPassManager(TheModule);
JavaFunctionPasses->add(new TargetData(TheModule));
if (cooperativeGC)
JavaFunctionPasses->add(mvm::createLoopSafePointsPass());
Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp Sat Jan 30 10:29:45 2010
@@ -65,7 +65,7 @@
const FunctionType* type = stat ? LSI->getStaticType() :
LSI->getVirtualType();
- F = Function::Create(type, GlobalValue::GhostLinkage, key, TheModule);
+ F = Function::Create(type, GlobalValue::ExternalWeakLinkage, key, TheModule);
CallbackInfo A(cl, index, stat);
callbacks.insert(std::make_pair(F, A));
@@ -74,9 +74,13 @@
}
-bool JnjvmModuleProvider::materializeFunction(Function *F,
- std::string *ErrInfo) {
+bool JnjvmModuleProvider::Materialize(GlobalValue *GV,
+ std::string *ErrInfo) {
+ Function* F = dyn_cast<Function>(GV);
+ assert(F && "Not a function");
+ if (F->getLinkage() == GlobalValue::ExternalLinkage) return false;
+
// The caller of materializeFunction *must* always hold the JIT lock.
// Because we are materializing a function here, we must release the
// JIT lock and get the global vmkit lock to be thread-safe.
@@ -101,7 +105,6 @@
return false;
}
-
JavaMethod* meth = Comp->getJavaMethod(F);
if (!meth) {
@@ -139,17 +142,23 @@
return false;
}
+bool JnjvmModuleProvider::isMaterializable(const llvm::GlobalValue* GV) const {
+ return GV->getLinkage() == GlobalValue::ExternalWeakLinkage;
+}
+
+
JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m,
JavaJITCompiler* C) {
Comp = C;
TheModule = m;
+ m->setMaterializer(this);
JnjvmModule::protectEngine.lock();
- JnjvmModule::executionEngine->addModuleProvider(this);
+ JnjvmModule::executionEngine->addModule(TheModule);
JnjvmModule::protectEngine.unlock();
}
JnjvmModuleProvider::~JnjvmModuleProvider() {
JnjvmModule::protectEngine.lock();
- JnjvmModule::executionEngine->removeModuleProvider(this);
+ JnjvmModule::executionEngine->removeModule(TheModule);
JnjvmModule::protectEngine.unlock();
}
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Jan 30 10:29:45 2010
@@ -15,7 +15,6 @@
#include <llvm/Linker.h>
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
-#include <llvm/ModuleProvider.h>
#include <llvm/PassManager.h>
#include <llvm/Type.h>
#include <llvm/Analysis/LoopPass.h>
@@ -120,11 +119,10 @@
#endif
if (!M) {
globalModule = new Module("bootstrap module", getGlobalContext());
- globalModuleProvider = new ExistingModuleProvider (globalModule);
InitializeNativeTarget();
- executionEngine = ExecutionEngine::createJIT(globalModuleProvider, 0,
+ executionEngine = ExecutionEngine::createJIT(globalModule, 0,
0, level, false);
Allocator = new BumpPtrAllocator();
@@ -138,11 +136,10 @@
TheTargetData = executionEngine->getTargetData();
} else {
globalModule = M;
- globalModuleProvider = new ExistingModuleProvider (globalModule);
TheTargetData = T->getTargetData();
}
- globalFunctionPasses = new FunctionPassManager(globalModuleProvider);
+ globalFunctionPasses = new FunctionPassManager(globalModule);
mvm::llvm_runtime::makeLLVMModuleContents(globalModule);
@@ -445,7 +442,6 @@
const llvm::TargetData* MvmModule::TheTargetData;
llvm::GCStrategy* MvmModule::GC;
llvm::Module *MvmModule::globalModule;
-llvm::ExistingModuleProvider *MvmModule::globalModuleProvider;
llvm::FunctionPassManager* MvmModule::globalFunctionPasses;
llvm::ExecutionEngine* MvmModule::executionEngine;
mvm::LockRecursive MvmModule::protectEngine;
Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=94896&r1=94895&r2=94896&view=diff
==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Sat Jan 30 10:29:45 2010
@@ -18,7 +18,6 @@
#include "llvm/LinkAllPasses.h"
#include "llvm/LinkAllVMCore.h"
#include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
#include "llvm/PassManager.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
More information about the vmkit-commits
mailing list