[vmkit-commits] [vmkit] r97987 - in /vmkit/trunk: Makefile.rules include/mvm/JIT.h lib/J3/Compiler/J3Intrinsics.cpp lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaLLVMCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/Mvm/Compiler/InlineMalloc.cpp lib/Mvm/Compiler/JIT.cpp tools/j3/Main.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Mar 8 13:26:47 PST 2010
Author: geoffray
Date: Mon Mar 8 15:26:47 2010
New Revision: 97987
URL: http://llvm.org/viewvc/llvm-project?rev=97987&view=rev
Log:
Create a LLVMContext for each compiler created, hence for each class loader.
Modified:
vmkit/trunk/Makefile.rules
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp
vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
vmkit/trunk/tools/j3/Main.cpp
vmkit/trunk/tools/vmjc/vmjc.cpp
vmkit/trunk/tools/vmkit/Launcher.cpp
Modified: vmkit/trunk/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.rules?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/Makefile.rules (original)
+++ vmkit/trunk/Makefile.rules Mon Mar 8 15:26:47 2010
@@ -137,6 +137,7 @@
$(Verb) $(LOPT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -std-compile-opts -LowerJavaRT -f $(JARNAME).bc -o $(JARNAME)-optimized.bc
$(Verb) $(LLVMLD) -r -o $(LibDir)/FinalMMTk.bc $(LibDir)/MMTKAlloc.bc $(JARNAME)-optimized.bc $(LibDir)/MMTKRuntime.bc
$(Verb) $(LOPT) -std-compile-opts $(LibDir)/FinalMMTk.bc -o $(LibDir)/FinalMMTk.bc
+ #$(Verb) $(LLC) -march=cpp -cppgen=function -cppfor=gcmalloc $(LibDir)/FinalMMTk.bc -o $(PROJ_SRC_ROOT)/lib/Mvm/Compiler/MMTkInline.inc
endif
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Mon Mar 8 15:26:47 2010
@@ -200,7 +200,7 @@
static void copyDefinitions(llvm::Module* Dst, llvm::Module* Src);
- static void AddStandardCompilePasses();
+ static void addCommandLinePasses(llvm::FunctionPassManager* PM);
static const char* getHostTriple();
};
Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Mon Mar 8 15:26:47 2010
@@ -33,74 +33,68 @@
J3Intrinsics::J3Intrinsics(llvm::Module* module) :
BaseIntrinsics(module) {
+ j3::llvm_runtime::makeLLVMModuleContents(module);
- llvm::Module* globalModule = mvm::MvmModule::globalModule;
-
- if (!globalModule->getTypeByName("JavaThread")) {
- j3::llvm_runtime::makeLLVMModuleContents(globalModule);
- mvm::MvmModule::copyDefinitions(module, globalModule);
- }
-
- VTType = PointerType::getUnqual(globalModule->getTypeByName("VT"));
+ VTType = PointerType::getUnqual(module->getTypeByName("VT"));
LLVMContext& Context = module->getContext();
#ifdef ISOLATE_SHARING
JnjvmType =
- PointerType::getUnqual(globalModule->getTypeByName("Jnjvm"));
+ PointerType::getUnqual(module->getTypeByName("Jnjvm"));
#endif
ConstantPoolType = ptrPtrType;
JavaObjectType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaObject"));
+ PointerType::getUnqual(module->getTypeByName("JavaObject"));
JavaArrayType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaArray"));
+ PointerType::getUnqual(module->getTypeByName("JavaArray"));
JavaCommonClassType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaCommonClass"));
+ PointerType::getUnqual(module->getTypeByName("JavaCommonClass"));
JavaClassPrimitiveType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaClassPrimitive"));
+ PointerType::getUnqual(module->getTypeByName("JavaClassPrimitive"));
JavaClassArrayType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaClassArray"));
+ PointerType::getUnqual(module->getTypeByName("JavaClassArray"));
JavaClassType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaClass"));
+ PointerType::getUnqual(module->getTypeByName("JavaClass"));
JavaArrayUInt8Type =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayUInt8"));
+ PointerType::getUnqual(module->getTypeByName("ArrayUInt8"));
JavaArraySInt8Type =
- PointerType::getUnqual(globalModule->getTypeByName("ArraySInt8"));
+ PointerType::getUnqual(module->getTypeByName("ArraySInt8"));
JavaArrayUInt16Type =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayUInt16"));
+ PointerType::getUnqual(module->getTypeByName("ArrayUInt16"));
JavaArraySInt16Type =
- PointerType::getUnqual(globalModule->getTypeByName("ArraySInt16"));
+ PointerType::getUnqual(module->getTypeByName("ArraySInt16"));
JavaArrayUInt32Type =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayUInt32"));
+ PointerType::getUnqual(module->getTypeByName("ArrayUInt32"));
JavaArraySInt32Type =
- PointerType::getUnqual(globalModule->getTypeByName("ArraySInt32"));
+ PointerType::getUnqual(module->getTypeByName("ArraySInt32"));
JavaArrayLongType =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayLong"));
+ PointerType::getUnqual(module->getTypeByName("ArrayLong"));
JavaArrayFloatType =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayFloat"));
+ PointerType::getUnqual(module->getTypeByName("ArrayFloat"));
JavaArrayDoubleType =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayDouble"));
+ PointerType::getUnqual(module->getTypeByName("ArrayDouble"));
JavaArrayObjectType =
- PointerType::getUnqual(globalModule->getTypeByName("ArrayObject"));
+ PointerType::getUnqual(module->getTypeByName("ArrayObject"));
JavaFieldType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaField"));
+ PointerType::getUnqual(module->getTypeByName("JavaField"));
JavaMethodType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaMethod"));
+ PointerType::getUnqual(module->getTypeByName("JavaMethod"));
UTF8Type =
- PointerType::getUnqual(globalModule->getTypeByName("UTF8"));
+ PointerType::getUnqual(module->getTypeByName("UTF8"));
AttributType =
- PointerType::getUnqual(globalModule->getTypeByName("Attribut"));
+ PointerType::getUnqual(module->getTypeByName("Attribut"));
JavaThreadType =
- PointerType::getUnqual(globalModule->getTypeByName("JavaThread"));
+ PointerType::getUnqual(module->getTypeByName("JavaThread"));
MutatorThreadType =
- PointerType::getUnqual(globalModule->getTypeByName("MutatorThread"));
+ PointerType::getUnqual(module->getTypeByName("MutatorThread"));
CodeLineInfoType =
- PointerType::getUnqual(globalModule->getTypeByName("CodeLineInfo"));
+ PointerType::getUnqual(module->getTypeByName("CodeLineInfo"));
JavaObjectNullConstant =
Constant::getNullValue(J3Intrinsics::JavaObjectType);
@@ -152,25 +146,6 @@
ClassReadyConstant = ConstantInt::get(Type::getInt8Ty(Context), ready);
- globalModule->addTypeName("JavaObject", JavaObjectType->getContainedType(0));
- globalModule->addTypeName("JavaArray", JavaArrayType->getContainedType(0));
- globalModule->addTypeName("JavaCommonClass",
- JavaCommonClassType->getContainedType(0));
- globalModule->addTypeName("JavaClass", JavaClassType->getContainedType(0));
- globalModule->addTypeName("JavaClassPrimitive",
- JavaClassPrimitiveType->getContainedType(0));
- globalModule->addTypeName("JavaClassArray",
- JavaClassArrayType->getContainedType(0));
- globalModule->addTypeName("ArrayUInt8", JavaArrayUInt8Type->getContainedType(0));
- globalModule->addTypeName("ArraySInt8", JavaArraySInt8Type->getContainedType(0));
- globalModule->addTypeName("ArrayUInt16", JavaArrayUInt16Type->getContainedType(0));
- globalModule->addTypeName("ArraySInt16", JavaArraySInt16Type->getContainedType(0));
- globalModule->addTypeName("ArraySInt32", JavaArraySInt32Type->getContainedType(0));
- globalModule->addTypeName("ArrayLong", JavaArrayLongType->getContainedType(0));
- globalModule->addTypeName("ArrayFloat", JavaArrayFloatType->getContainedType(0));
- globalModule->addTypeName("ArrayDouble", JavaArrayDoubleType->getContainedType(0));
- globalModule->addTypeName("ArrayObject", JavaArrayObjectType->getContainedType(0));
-
InterfaceLookupFunction = module->getFunction("j3InterfaceLookup");
MultiCallNewFunction = module->getFunction("j3MultiCallNew");
ForceLoadedCheckFunction = module->getFunction("forceLoadedCheck");
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Mon Mar 8 15:26:47 2010
@@ -354,7 +354,7 @@
Module& Mod = *getLLVMModule();
varGV = new GlobalVariable(Mod, Ty, false, GlobalValue::InternalLinkage,
- 0, "");
+ 0, "final object");
Constant* C = ConstantExpr::getBitCast(varGV,
JavaIntrinsics.JavaObjectType);
@@ -1592,7 +1592,8 @@
std::vector<const llvm::Type*> llvmArgs;
llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader.
- const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false);
+ const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()),
+ llvmArgs, false);
StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage,
"Init", getLLVMModule());
@@ -1616,7 +1617,6 @@
"printJavaObject", getLLVMModule());
addJavaPasses();
-
}
void JavaAOTCompiler::printStats() {
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Mon Mar 8 15:26:47 2010
@@ -424,7 +424,6 @@
newArgv[1] = mainClass;
JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
- mvm::MvmModule::AddStandardCompilePasses();
JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL);
vm->runApplication(argc + 1, newArgv);
Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Mon Mar 8 15:26:47 2010
@@ -24,7 +24,7 @@
using namespace llvm;
JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) :
- TheModule(new llvm::Module(str, getGlobalContext())),
+ TheModule(new llvm::Module(str, *(new LLVMContext()))),
DebugFactory(new DIFactory(*TheModule)),
JavaIntrinsics(TheModule) {
@@ -70,7 +70,6 @@
mvm::MvmModule::runPasses(func, JavaNativeFunctionPasses);
} else {
jit.javaCompile();
- mvm::MvmModule::runPasses(func, mvm::MvmModule::globalFunctionPasses);
mvm::MvmModule::runPasses(func, JavaFunctionPasses);
}
func->setLinkage(GlobalValue::ExternalLinkage);
@@ -123,7 +122,7 @@
JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics()));
JavaFunctionPasses = new FunctionPassManager(TheModule);
- JavaFunctionPasses->add(new TargetData(TheModule));
+ mvm::MvmModule::addCommandLinePasses(JavaFunctionPasses);
if (cooperativeGC)
JavaFunctionPasses->add(mvm::createLoopSafePointsPass());
Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Mon Mar 8 15:26:47 2010
@@ -20,7 +20,6 @@
#include "mvm/JIT.h"
#include "JavaConstantPool.h"
-#include "JavaJIT.h"
#include "JavaString.h"
#include "JavaThread.h"
#include "JavaTypes.h"
@@ -28,7 +27,7 @@
#include "Jnjvm.h"
#include "Reader.h"
-#include "j3/JavaCompiler.h"
+#include "j3/JavaLLVMCompiler.h"
#include "j3/LLVMInfo.h"
#include <cstdio>
@@ -42,9 +41,7 @@
const TargetData* targetData = mvm::MvmModule::TheTargetData;
const StructLayout* sl = 0;
const StructType* structType = 0;
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)classDef->classLoader->getCompiler();
- LLVMContext& context = Mod->getLLVMModule()->getContext();
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
if (classDef->super) {
LLVMClassInfo* CLI = Compiler->getClassInfo(classDef->super);
@@ -53,9 +50,8 @@
for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) {
JavaField& field = classDef->virtualFields[i];
- field.num = i + 1;
Typedef* type = field.getSignature();
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(type);
fields.push_back(LAI.llvmType);
}
@@ -65,26 +61,30 @@
sl = targetData->getStructLayout(structType);
} else {
- virtualType = Mod->getIntrinsics()->JavaObjectType;
+ virtualType = Compiler->getIntrinsics()->JavaObjectType;
assert(virtualType && "intrinsics not iniitalized");
structType = dyn_cast<const StructType>(virtualType->getContainedType(0));
sl = targetData->getStructLayout(structType);
}
-
- for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) {
- JavaField& field = classDef->virtualFields[i];
- field.ptrOffset = sl->getElementOffset(i + 1);
- }
-
uint64 size = mvm::MvmModule::getTypeSize(structType);
- classDef->virtualSize = (uint32)size;
- classDef->alignment = sl->getAlignment();
virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size);
+
+ // TODO: put that elsewhere.
+ if (Compiler == classDef->classLoader->getCompiler()) {
+ for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) {
+ JavaField& field = classDef->virtualFields[i];
+ field.ptrOffset = sl->getElementOffset(i + 1);
+ field.num = i + 1;
+ }
+
+ classDef->virtualSize = (uint32)size;
+ classDef->alignment = sl->getAlignment();
- Mod->makeVT(classDef);
- Mod->makeIMT(classDef);
+ Compiler->makeVT(classDef);
+ Compiler->makeIMT(classDef);
+ }
}
return virtualType;
@@ -96,15 +96,12 @@
Class* cl = (Class*)classDef;
std::vector<const llvm::Type*> fields;
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)classDef->classLoader->getCompiler();
- LLVMContext& context = Mod->getLLVMModule()->getContext();
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
for (uint32 i = 0; i < classDef->nbStaticFields; ++i) {
JavaField& field = classDef->staticFields[i];
- field.num = i;
Typedef* type = field.getSignature();
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(type);
fields.push_back(LAI.llvmType);
}
@@ -113,13 +110,17 @@
const TargetData* targetData = mvm::MvmModule::TheTargetData;
const StructLayout* sl = targetData->getStructLayout(structType);
- for (uint32 i = 0; i < classDef->nbStaticFields; ++i) {
- JavaField& field = classDef->staticFields[i];
- field.ptrOffset = sl->getElementOffset(i);
- }
+ // TODO: put that elsewhere.
+ if (Compiler == classDef->classLoader->getCompiler()) {
+ for (uint32 i = 0; i < classDef->nbStaticFields; ++i) {
+ JavaField& field = classDef->staticFields[i];
+ field.num = i;
+ field.ptrOffset = sl->getElementOffset(i);
+ }
- uint64 size = mvm::MvmModule::getTypeSize(structType);
- cl->staticSize = size;
+ uint64 size = mvm::MvmModule::getTypeSize(structType);
+ cl->staticSize = size;
+ }
}
return staticType;
}
@@ -158,25 +159,13 @@
memcpy(buf, "JnJVM", 5);
}
- methodFunction = Compiler->getLLVMModule()->getFunction(buf);
- if (!methodFunction) {
- methodFunction = Function::Create(getFunctionType(),
- GlobalValue::ExternalWeakLinkage, buf,
- Compiler->getLLVMModule());
- } else {
- assert(methodFunction->getFunctionType() == getFunctionType() &&
- "Type mismatch");
- if (methodFunction->isDeclaration()) {
- methodFunction->setLinkage(GlobalValue::ExternalWeakLinkage);
- }
- }
-
+ methodFunction = Function::Create(getFunctionType(),
+ GlobalValue::ExternalWeakLinkage, buf,
+ Compiler->getLLVMModule());
} else {
-
methodFunction = Function::Create(getFunctionType(),
GlobalValue::ExternalWeakLinkage,
"", Compiler->getLLVMModule());
-
}
if (Compiler->useCooperativeGC()) {
@@ -211,11 +200,9 @@
Constant* LLVMMethodInfo::getOffset() {
if (!offsetConstant) {
- JnjvmClassLoader* JCL = methodDef->classDef->classLoader;
- JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler();
- LLVMContext& context = Mod->getLLVMModule()->getContext();
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
- Mod->resolveVirtualClass(methodDef->classDef);
+ Compiler->resolveVirtualClass(methodDef->classDef);
offsetConstant = ConstantInt::get(Type::getInt32Ty(context),
methodDef->offset);
}
@@ -224,14 +211,12 @@
Constant* LLVMFieldInfo::getOffset() {
if (!offsetConstant) {
- JnjvmClassLoader* JCL = fieldDef->classDef->classLoader;
- JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler();
- LLVMContext& context = Mod->getLLVMModule()->getContext();
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
if (isStatic(fieldDef->access)) {
- Mod->resolveStaticClass(fieldDef->classDef);
+ Compiler->resolveStaticClass(fieldDef->classDef);
} else {
- Mod->resolveVirtualClass(fieldDef->classDef);
+ Compiler->resolveVirtualClass(fieldDef->classDef);
}
offsetConstant = ConstantInt::get(Type::getInt32Ty(context), fieldDef->num);
@@ -246,14 +231,12 @@
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
- llvmArgs.push_back(Mod->getIntrinsics()->JavaObjectType);
+ llvmArgs.push_back(Compiler->getIntrinsics()->JavaObjectType);
for (uint32 i = 0; i < size; ++i) {
Typedef* type = arguments[i];
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(type);
llvmArgs.push_back(LAI.llvmType);
}
@@ -261,7 +244,8 @@
llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType);
#endif
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType());
+ LLVMAssessorInfo& LAI =
+ Compiler->getTypedefInfo(signature->getReturnType());
virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false);
mvm::MvmModule::unprotectIR();
}
@@ -275,21 +259,20 @@
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
for (uint32 i = 0; i < size; ++i) {
Typedef* type = arguments[i];
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(type);
llvmArgs.push_back(LAI.llvmType);
}
#if defined(ISOLATE_SHARING)
// cached constant pool
- llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType);
+ llvmArgs.push_back(Compiler->getIntrinsics()->ConstantPoolType);
#endif
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType());
+ LLVMAssessorInfo& LAI =
+ Compiler->getTypedefInfo(signature->getReturnType());
staticType = FunctionType::get(LAI.llvmType, llvmArgs, false);
mvm::MvmModule::unprotectIR();
}
@@ -303,20 +286,18 @@
std::vector<const llvm::Type*> llvmArgs;
uint32 size = signature->nbArguments;
Typedef* const* arguments = signature->getArgumentsType();
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
const llvm::Type* Ty =
- PointerType::getUnqual(Mod->getIntrinsics()->JavaObjectType);
+ PointerType::getUnqual(Compiler->getIntrinsics()->JavaObjectType);
- llvmArgs.push_back(Mod->getIntrinsics()->ptrType); // JNIEnv
+ llvmArgs.push_back(Compiler->getIntrinsics()->ptrType); // JNIEnv
llvmArgs.push_back(Ty); // Class
for (uint32 i = 0; i < size; ++i) {
Typedef* type = arguments[i];
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(type);
const llvm::Type* Ty = LAI.llvmType;
- if (Ty == Mod->getIntrinsics()->JavaObjectType) {
+ if (Ty == Compiler->getIntrinsics()->JavaObjectType) {
llvmArgs.push_back(LAI.llvmTypePtr);
} else {
llvmArgs.push_back(LAI.llvmType);
@@ -325,12 +306,13 @@
#if defined(ISOLATE_SHARING)
// cached constant pool
- llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType);
+ llvmArgs.push_back(Compiler->getIntrinsics()->ConstantPoolType);
#endif
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType());
+ LLVMAssessorInfo& LAI =
+ Compiler->getTypedefInfo(signature->getReturnType());
const llvm::Type* RetType =
- LAI.llvmType == Mod->getIntrinsics()->JavaObjectType ?
+ LAI.llvmType == Compiler->getIntrinsics()->JavaObjectType ?
LAI.llvmTypePtr : LAI.llvmType;
nativeType = FunctionType::get(RetType, llvmArgs, false);
mvm::MvmModule::unprotectIR();
@@ -343,24 +325,22 @@
std::vector<Value*> Args;
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
- LLVMContext& context = Mod->getLLVMModule()->getContext();
- J3Intrinsics& Intrinsics = *Mod->getIntrinsics();
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
+ J3Intrinsics& Intrinsics = *Compiler->getIntrinsics();
Function* res = 0;
- if (Mod->isStaticCompiling()) {
+ if (Compiler->isStaticCompiling()) {
const char* type = virt ? "virtual_buf" : "static_buf";
char* buf = (char*)alloca((signature->keyName->size << 1) + 1 + 11);
signature->nativeName(buf, type);
res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(),
GlobalValue::ExternalLinkage, buf,
- Mod->getLLVMModule());
+ Compiler->getLLVMModule());
} else {
res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(),
GlobalValue::ExternalLinkage, "",
- Mod->getLLVMModule());
+ Compiler->getLLVMModule());
}
BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res);
@@ -382,7 +362,7 @@
Typedef* const* arguments = signature->getArgumentsType();
for (uint32 i = 0; i < signature->nbArguments; ++i) {
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(arguments[i]);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(arguments[i]);
Value* arg = new LoadInst(ptr, "", currentBlock);
if (arguments[i]->isReference()) {
@@ -406,7 +386,7 @@
currentBlock = endBlock;
arg = node;
} else if (arguments[i]->isFloat()) {
- arg = new TruncInst(arg, Mod->AssessorInfo[I_INT].llvmType,
+ arg = new TruncInst(arg, Compiler->AssessorInfo[I_INT].llvmType,
"", currentBlock);
arg = new BitCastInst(arg, LAI.llvmType, "", currentBlock);
} else if (arguments[i]->isDouble()) {
@@ -415,7 +395,7 @@
arg = new TruncInst(arg, LAI.llvmType, "", currentBlock);
}
Args.push_back(arg);
- ptr = GetElementPtrInst::Create(ptr, Mod->getIntrinsics()->constantOne,"",
+ ptr = GetElementPtrInst::Create(ptr, Intrinsics.constantOne,"",
currentBlock);
}
@@ -437,11 +417,9 @@
std::vector<Value*> Args;
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
- J3Intrinsics& Intrinsics = *Mod->getIntrinsics();
+ J3Intrinsics& Intrinsics = *Compiler->getIntrinsics();
std::string name;
- if (Mod->isStaticCompiling()) {
+ if (Compiler->isStaticCompiling()) {
name += UTF8Buffer(signature->keyName).cString();
name += virt ? "virtual_ap" : "static_ap";
} else {
@@ -451,8 +429,8 @@
Function* res = Function::Create(virt ? getVirtualBufType() :
getStaticBufType(),
GlobalValue::InternalLinkage, name,
- Mod->getLLVMModule());
- LLVMContext& context = Mod->getLLVMModule()->getContext();
+ Compiler->getLLVMModule());
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res);
Function::arg_iterator i = res->arg_begin();
@@ -472,7 +450,7 @@
Typedef* const* arguments = signature->getArgumentsType();
for (uint32 i = 0; i < signature->nbArguments; ++i) {
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(arguments[i]);
+ LLVMAssessorInfo& LAI = Compiler->getTypedefInfo(arguments[i]);
Value* arg = new VAArgInst(ap, LAI.llvmType, "", currentBlock);
if (arguments[i]->isReference()) {
arg = new IntToPtrInst(arg, Intrinsics.JavaObjectType, "", currentBlock);
@@ -517,11 +495,9 @@
std::vector<Value*> Args;
std::vector<Value*> FunctionArgs;
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
- J3Intrinsics& Intrinsics = *Mod->getIntrinsics();
+ J3Intrinsics& Intrinsics = *Compiler->getIntrinsics();
std::string name;
- if (Mod->isStaticCompiling()) {
+ if (Compiler->isStaticCompiling()) {
name += UTF8Buffer(signature->keyName).cString();
name += virt ? "virtual_stub" : special ? "special_stub" : "static_stub";
} else {
@@ -531,8 +507,8 @@
Function* stub = Function::Create((virt || special) ? getVirtualType() :
getStaticType(),
GlobalValue::InternalLinkage, name,
- Mod->getLLVMModule());
- LLVMContext& context = Mod->getLLVMModule()->getContext();
+ Compiler->getLLVMModule());
+ LLVMContext& context = Compiler->getLLVMModule()->getContext();
BasicBlock* currentBlock = BasicBlock::Create(context, "enter", stub);
BasicBlock* endBlock = BasicBlock::Create(context, "end", stub);
@@ -551,7 +527,7 @@
for (; arg != stub->arg_end() ; ++arg) {
FunctionArgs.push_back(arg);
- if (Mod->useCooperativeGC()) {
+ if (Compiler->useCooperativeGC()) {
if (arg->getType() == Intrinsics.JavaObjectType) {
Value* GCArgs[2] = {
new BitCastInst(arg, Intrinsics.ptrPtrType, "", currentBlock),
@@ -620,13 +596,12 @@
// Lock here because we are called by arbitrary code
mvm::MvmModule::protectIR();
std::vector<const llvm::Type*> Args;
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
- Args.push_back(Mod->getIntrinsics()->ConstantPoolType); // ctp
+ Args.push_back(Compiler->getIntrinsics()->ConstantPoolType); // ctp
Args.push_back(getVirtualPtrType());
- Args.push_back(Mod->getIntrinsics()->JavaObjectType);
- Args.push_back(Mod->AssessorInfo[I_LONG].llvmTypePtr);
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType());
+ Args.push_back(Compiler->getIntrinsics()->JavaObjectType);
+ Args.push_back(Compiler->AssessorInfo[I_LONG].llvmTypePtr);
+ LLVMAssessorInfo& LAI =
+ Compiler->getTypedefInfo(signature->getReturnType());
virtualBufType = FunctionType::get(LAI.llvmType, Args, false);
mvm::MvmModule::unprotectIR();
}
@@ -637,13 +612,12 @@
if (!staticBufType) {
// Lock here because we are called by arbitrary code
mvm::MvmModule::protectIR();
- JavaLLVMCompiler* Mod =
- (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
std::vector<const llvm::Type*> Args;
- Args.push_back(Mod->getIntrinsics()->ConstantPoolType); // ctp
+ Args.push_back(Compiler->getIntrinsics()->ConstantPoolType); // ctp
Args.push_back(getStaticPtrType());
- Args.push_back(Mod->AssessorInfo[I_LONG].llvmTypePtr);
- LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType());
+ Args.push_back(Compiler->AssessorInfo[I_LONG].llvmTypePtr);
+ LLVMAssessorInfo& LAI =
+ Compiler->getTypedefInfo(signature->getReturnType());
staticBufType = FunctionType::get(LAI.llvmType, Args, false);
mvm::MvmModule::unprotectIR();
}
@@ -656,7 +630,7 @@
mvm::MvmModule::protectIR();
if (!virtualBufFunction) {
virtualBufFunction = createFunctionCallBuf(true);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setVirtualCallBuf((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(virtualBufFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -673,7 +647,7 @@
mvm::MvmModule::protectIR();
if (!virtualAPFunction) {
virtualAPFunction = createFunctionCallAP(true);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setVirtualCallAP((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(virtualAPFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -690,7 +664,7 @@
mvm::MvmModule::protectIR();
if (!staticBufFunction) {
staticBufFunction = createFunctionCallBuf(false);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setStaticCallBuf((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(staticBufFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -707,7 +681,7 @@
mvm::MvmModule::protectIR();
if (!staticAPFunction) {
staticAPFunction = createFunctionCallAP(false);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setStaticCallAP((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(staticAPFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -724,7 +698,7 @@
mvm::MvmModule::protectIR();
if (!staticStubFunction) {
staticStubFunction = createFunctionStub(false, false);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setStaticCallStub((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(staticStubFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -741,7 +715,7 @@
mvm::MvmModule::protectIR();
if (!specialStubFunction) {
specialStubFunction = createFunctionStub(true, false);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setSpecialCallStub((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(specialStubFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -758,7 +732,7 @@
mvm::MvmModule::protectIR();
if (!virtualStubFunction) {
virtualStubFunction = createFunctionStub(false, true);
- if (!signature->initialLoader->getCompiler()->isStaticCompiling()) {
+ if (!Compiler->isStaticCompiling()) {
signature->setVirtualCallStub((intptr_t)
mvm::MvmModule::executionEngine->getPointerToGlobal(virtualStubFunction));
// Now that it's compiled, we don't need the IR anymore
@@ -814,8 +788,7 @@
PointerType::getUnqual(Type::getDoubleTy(getLLVMContext()));
AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3;
- AssessorInfo[I_TAB].llvmType = PointerType::getUnqual(
- mvm::MvmModule::globalModule->getTypeByName("JavaObject"));
+ AssessorInfo[I_TAB].llvmType = JavaIntrinsics.JavaObjectType;
AssessorInfo[I_TAB].llvmTypePtr =
PointerType::getUnqual(AssessorInfo[I_TAB].llvmType);
AssessorInfo[I_TAB].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2;
Modified: vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp Mon Mar 8 15:26:47 2010
@@ -41,8 +41,8 @@
bool InlineMalloc::runOnFunction(Function& F) {
- Function* Malloc = mvm::MvmModule::globalModule->getFunction("gcmalloc");
- if (Malloc->isDeclaration()) return false;
+ Function* Malloc = F.getParent()->getFunction("gcmalloc");
+ if (!Malloc || Malloc->isDeclaration()) return false;
bool Changed = false;
for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) {
BasicBlock *Cur = BI;
@@ -53,9 +53,8 @@
Instruction* CI = Call.getInstruction();
if (CI) {
Function* F = Call.getCalledFunction();
- if (F && F->getName() == "gcmalloc") {
+ if (F == Malloc) {
if (dyn_cast<Constant>(Call.getArgument(0))) {
- Call.setCalledFunction(mvm::MvmModule::globalModule->getFunction("gcmalloc"));
Changed |= InlineFunction(Call, 0, mvm::MvmModule::TheTargetData);
break;
}
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Mon Mar 8 15:26:47 2010
@@ -29,7 +29,8 @@
#include <llvm/Support/Debug.h>
#include <llvm/Support/IRReader.h>
#include <llvm/Support/MutexGuard.h>
-#include "llvm/Support/SourceMgr.h"
+#include <llvm/Support/PassNameParser.h>
+#include <llvm/Support/SourceMgr.h>
#include <llvm/Target/TargetData.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h>
@@ -55,6 +56,10 @@
namespace llvm_runtime {
#include "LLVMRuntime.inc"
}
+
+ namespace mmtk_runtime {
+ #include "MMTkInline.inc"
+ }
void linkVmkitGC();
}
@@ -109,7 +114,7 @@
void MvmModule::loadBytecodeFile(const std::string& str) {
SMDiagnostic Err;
- Module* M = ParseIRFile(str, Err, getGlobalContext());
+ Module* M = ParseIRFile(str, Err, globalModule->getContext());
if (M) {
M->setTargetTriple(getHostTriple());
Linker::LinkModules(globalModule, M, 0);
@@ -164,7 +169,6 @@
globalFunctionPasses = new FunctionPassManager(globalModule);
- mvm::llvm_runtime::makeLLVMModuleContents(globalModule);
//LLVMContext& Context = globalModule->getContext();
//MetadataTypeKind = Context.getMDKindID("HighLevelType");
@@ -325,7 +329,35 @@
module->setTargetTriple(MvmModule::globalModule->getTargetTriple());
LLVMContext& Context = module->getContext();
- MvmModule::copyDefinitions(module, MvmModule::globalModule);
+ if (MutatorThread::MMTkCollectorSize) {
+ // If we have found MMTk, read the gcmalloc function and set the address of
+ // global variables and functions used by gcmalloc.
+ mvm::mmtk_runtime::makeLLVMFunction(module);
+ if (MvmModule::executionEngine) {
+ for (Module::global_iterator i = module->global_begin(),
+ e = module->global_end(); i != e; ++i) {
+ if (i->isDeclaration()) {
+ GlobalVariable* GV =
+ MvmModule::globalModule->getGlobalVariable(i->getName(), true);
+ assert(GV && "GV can not be found");
+ void* ptr = MvmModule::executionEngine->getPointerToGlobal(GV);
+ MvmModule::executionEngine->updateGlobalMapping(i, ptr);
+ }
+ }
+ for (Module::iterator i = module->begin(), e = module->end();
+ i != e; ++i) {
+ if (i->isDeclaration() && !i->isIntrinsic()) {
+ Function* F =
+ MvmModule::globalModule->getFunction(i->getName());
+ assert(F && "Function can not be found");
+ void* ptr = MvmModule::executionEngine->getPointerToFunction(F);
+ MvmModule::executionEngine->updateGlobalMapping(i, ptr);
+ }
+ }
+ }
+ }
+ mvm::llvm_runtime::makeLLVMModuleContents(module);
+
// Type declaration
ptrType = PointerType::getUnqual(Type::getInt8Ty(Context));
@@ -454,6 +486,8 @@
assert(AllocateUnresolvedFunction && "No allocateUnresolved function");
AddFinalizationCandidate = module->getFunction("addFinalizationCandidate");
assert(AddFinalizationCandidate && "No addFinalizationCandidate function");
+
+ MvmModule::copyDefinitions(module, MvmModule::globalModule);
}
const llvm::TargetData* MvmModule::TheTargetData;
@@ -485,10 +519,6 @@
PM->add(P);
}
-namespace mvm {
- llvm::FunctionPass* createInlineMallocPass();
-}
-
// This is equivalent to:
// opt -simplifycfg -mem2reg -instcombine -jump-threading -simplifycfg
// -scalarrepl -instcombine -condprop -simplifycfg -predsimplify
@@ -496,17 +526,8 @@
// -instcombine -gvn -sccp -simplifycfg -instcombine -condprop -dse -adce
// -simplifycfg
//
-void MvmModule::AddStandardCompilePasses() {
- FunctionPassManager* PM = globalFunctionPasses;
- PM->add(new TargetData(*MvmModule::TheTargetData));
-
- addPass(PM, createVerifierPass()); // Verify that input is correct
-
-#ifdef WITH_MMTK
- addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
- addPass(PM, createInlineMallocPass());
-#endif
-
+static void AddStandardCompilePasses(FunctionPassManager* PM) {
+
addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas
@@ -538,10 +559,68 @@
addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores
addPass(PM, createAggressiveDCEPass()); // Delete dead instructions
addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
+}
+static cl::opt<bool>
+DisableOptimizations("disable-opt",
+ cl::desc("Do not run any optimization passes"));
+
+cl::opt<bool>
+StandardCompileOpts("std-compile-opts",
+ cl::desc("Include the standard compile time optimizations"));
- PM->doInitialization();
+// The OptimizationList is automatically populated with registered Passes by the
+// PassNameParser.
+//
+static llvm::cl::list<const llvm::PassInfo*, bool, llvm::PassNameParser>
+PassList(llvm::cl::desc("Optimizations available:"));
+
+namespace mvm {
+ llvm::FunctionPass* createInlineMallocPass();
+}
+
+void MvmModule::addCommandLinePasses(FunctionPassManager* PM) {
+ addPass(PM, new TargetData(*MvmModule::TheTargetData));
+
+ addPass(PM, createVerifierPass()); // Verify that input is correct
+
+#ifdef WITH_MMTK
+ addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
+ addPass(PM, createInlineMallocPass());
+#endif
+ // Create a new optimization pass for each one specified on the command line
+ for (unsigned i = 0; i < PassList.size(); ++i) {
+ // Check to see if -std-compile-opts was specified before this option. If
+ // so, handle it.
+ if (StandardCompileOpts &&
+ StandardCompileOpts.getPosition() < PassList.getPosition(i)) {
+ if (!DisableOptimizations) AddStandardCompilePasses(PM);
+ StandardCompileOpts = false;
+ }
+
+ const PassInfo *PassInf = PassList[i];
+ Pass *P = 0;
+ if (PassInf->getNormalCtor())
+ P = PassInf->getNormalCtor()();
+ else
+ errs() << "cannot create pass: "
+ << PassInf->getPassName() << "\n";
+ if (P) {
+ bool isModulePass = (P->getPassKind() == PT_Module);
+ if (isModulePass)
+ errs() << "vmkit does not support module pass: "
+ << PassInf->getPassName() << "\n";
+ else addPass(PM, P);
+
+ }
+ }
+
+ // If -std-compile-opts was specified at the end of the pass list, add them.
+ if (StandardCompileOpts) {
+ AddStandardCompilePasses(PM);
+ }
+ PM->doInitialization();
}
// We protect the creation of IR with the executionEngine lock because
@@ -560,53 +639,26 @@
void MvmModule::copyDefinitions(Module* Dst, Module* Src) {
- // Loop over all of the functions in the src module, mapping them over
- for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
- const Function *SF = I; // SrcFunction
- if (SF->isDeclaration()) {
- Function* F = Function::Create(SF->getFunctionType(),
- GlobalValue::ExternalLinkage,
- SF->getName(), Dst);
- F->setAttributes(SF->getAttributes());
- }
- }
-
Function* SF = Src->getFunction("gcmalloc");
- if (SF && !SF->isDeclaration()) {
- Function* F = Function::Create(SF->getFunctionType(),
- GlobalValue::ExternalLinkage,
- SF->getName(), Dst);
- F->setAttributes(SF->getAttributes());
- if (executionEngine) {
- void* ptr = executionEngine->getPointerToFunction(SF);
- executionEngine->updateGlobalMapping(F, ptr);
- }
+ Function* DF = Dst->getFunction("gcmalloc");
+ if (SF && DF && executionEngine && !SF->isDeclaration()) {
+ void* ptr = executionEngine->getPointerToFunction(SF);
+ executionEngine->updateGlobalMapping(DF, ptr);
}
SF = Src->getFunction("gcmallocUnresolved");
- if (SF && !SF->isDeclaration()) {
- Function* F = Function::Create(SF->getFunctionType(),
- GlobalValue::ExternalLinkage,
- SF->getName(), Dst);
- F->setAttributes(SF->getAttributes());
- if (executionEngine) {
- void* ptr = executionEngine->getPointerToFunction(SF);
- executionEngine->updateGlobalMapping(F, ptr);
- }
+ DF = Dst->getFunction("gcmallocUnresolved");
+ if (SF && DF && executionEngine && !SF->isDeclaration()) {
+ void* ptr = executionEngine->getPointerToFunction(SF);
+ executionEngine->updateGlobalMapping(DF, ptr);
}
SF = Src->getFunction("addFinalizationCandidate");
- if (SF && !SF->isDeclaration()) {
- Function* F = Function::Create(SF->getFunctionType(),
- GlobalValue::ExternalLinkage,
- SF->getName(), Dst);
- F->setAttributes(SF->getAttributes());
- if (executionEngine) {
- void* ptr = executionEngine->getPointerToFunction(SF);
- executionEngine->updateGlobalMapping(F, ptr);
- }
+ DF = Dst->getFunction("addFinalizationCandidate");
+ if (SF && DF && executionEngine && !SF->isDeclaration()) {
+ void* ptr = executionEngine->getPointerToFunction(SF);
+ executionEngine->updateGlobalMapping(DF, ptr);
}
-
}
void JITMethodInfo::scan(void* TL, void* ip, void* addr) {
Modified: vmkit/trunk/tools/j3/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/tools/j3/Main.cpp (original)
+++ vmkit/trunk/tools/j3/Main.cpp Mon Mar 8 15:26:47 2010
@@ -17,8 +17,10 @@
#include "../../lib/J3/VMCore/JnjvmClassLoader.h"
#include "../../lib/J3/VMCore/Jnjvm.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
+extern llvm::cl::opt<bool> StandardCompileOpts;
using namespace j3;
using namespace mvm;
@@ -31,7 +33,7 @@
Collector::initialise();
// Tell the compiler to run all optimizations.
- MvmModule::AddStandardCompilePasses();
+ StandardCompileOpts = true;
// Create the allocator that will allocate the bootstrap loader and the JVM.
mvm::BumpPtrAllocator Allocator;
Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Mon Mar 8 15:26:47 2010
@@ -74,22 +74,6 @@
static cl::opt<bool>
DisableOutput("disable-output", cl::desc("Disable output"), cl::init(false));
-
-// The OptimizationList is automatically populated with registered Passes by the
-// PassNameParser.
-//
-static llvm::cl::list<const llvm::PassInfo*, bool, llvm::PassNameParser>
-PassList(llvm::cl::desc("Optimizations available:"));
-
-
-static cl::opt<bool>
-DisableOptimizations("disable-opt",
- cl::desc("Do not run any optimization passes"));
-
-static cl::opt<bool>
-StandardCompileOpts("std-compile-opts",
- cl::desc("Include the standard compile time optimizations"));
-
static cl::opt<std::string>
TargetTriple("mtriple", cl::desc("Override target triple for module"));
@@ -122,53 +106,6 @@
WithClinit("with-clinit", cl::desc("Classes to clinit"), cl::ZeroOrMore,
cl::CommaSeparated);
-
-inline void addPass(FunctionPassManager *PM, Pass *P) {
- // Add the pass to the pass manager...
- PM->add(P);
-}
-
-
-void addCommandLinePass(char** argv) {
- FunctionPassManager* Passes = mvm::MvmModule::globalFunctionPasses;
- Passes->add(new TargetData(*mvm::MvmModule::TheTargetData));
-
- // Create a new optimization pass for each one specified on the command line
- for (unsigned i = 0; i < PassList.size(); ++i) {
- // Check to see if -std-compile-opts was specified before this option. If
- // so, handle it.
- if (StandardCompileOpts &&
- StandardCompileOpts.getPosition() < PassList.getPosition(i)) {
- if (!DisableOptimizations) mvm::MvmModule::AddStandardCompilePasses();
- StandardCompileOpts = false;
- }
-
- const PassInfo *PassInf = PassList[i];
- Pass *P = 0;
- if (PassInf->getNormalCtor())
- P = PassInf->getNormalCtor()();
- else
- errs() << argv[0] << ": cannot create pass: "
- << PassInf->getPassName() << "\n";
- if (P) {
- bool isModulePass = (P->getPassKind() == PT_Module);
- if (isModulePass)
- errs() << argv[0] << ": vmkit does not support module pass: "
- << PassInf->getPassName() << "\n";
- else addPass(Passes, P);
-
- }
- }
-
- // If -std-compile-opts was specified at the end of the pass list, add them.
- if (StandardCompileOpts) {
- mvm::MvmModule::AddStandardCompilePasses();
- }
-
- Passes->doInitialization();
-}
-
-
int main(int argc, char **argv) {
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
try {
@@ -243,7 +180,6 @@
mvm::Collector::initialise();
JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp, false);
- addCommandLinePass(argv);
if (DisableExceptions) Comp->disableExceptions();
if (DisableStubs) Comp->generateStubs = false;
Modified: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=97987&r1=97986&r2=97987&view=diff
==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (original)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Mon Mar 8 15:26:47 2010
@@ -36,14 +36,6 @@
Interactive, RunJava, RunNet
};
-// The OptimizationList is automatically populated with registered Passes by the
-// PassNameParser.
-//
-static llvm::cl::list<const llvm::PassInfo*, bool, llvm::PassNameParser>
-PassList(llvm::cl::desc("Optimizations available:"));
-
-
-
static llvm::cl::opt<VMType> VMToRun(llvm::cl::desc("Choose VM to run:"),
llvm::cl::values(
clEnumValN(Interactive , "i", "Run in interactive mode"),
@@ -56,59 +48,6 @@
"potentially sacrificing code quality"),
cl::init(false));
-static cl::opt<bool>
-DisableOptimizations("disable-opt",
- cl::desc("Do not run any optimization passes"));
-
-static cl::opt<bool>
-StandardCompileOpts("std-compile-opts",
- cl::desc("Include the standard compile time optimizations"));
-
-inline void addPass(FunctionPassManager *PM, Pass *P) {
- // Add the pass to the pass manager...
- PM->add(P);
-}
-
-
-void addCommandLinePass(char** argv) {
- FunctionPassManager* Passes = mvm::MvmModule::globalFunctionPasses;
-
- Passes->add(new TargetData(*mvm::MvmModule::TheTargetData));
- // Create a new optimization pass for each one specified on the command line
- for (unsigned i = 0; i < PassList.size(); ++i) {
- // Check to see if -std-compile-opts was specified before this option. If
- // so, handle it.
- if (StandardCompileOpts &&
- StandardCompileOpts.getPosition() < PassList.getPosition(i)) {
- if (!DisableOptimizations) mvm::MvmModule::AddStandardCompilePasses();
- StandardCompileOpts = false;
- }
-
- const PassInfo *PassInf = PassList[i];
- Pass *P = 0;
- if (PassInf->getNormalCtor())
- P = PassInf->getNormalCtor()();
- else
- errs() << argv[0] << ": cannot create pass: "
- << PassInf->getPassName() << "\n";
- if (P) {
- bool isModulePass = (P->getPassKind() == PT_Module);
- if (isModulePass)
- errs() << argv[0] << ": vmkit does not support module pass: "
- << PassInf->getPassName() << "\n";
- else addPass(Passes, P);
-
- }
- }
-
- // If -std-compile-opts was specified at the end of the pass list, add them.
- if (StandardCompileOpts) {
- mvm::MvmModule::AddStandardCompilePasses();
- }
- Passes->doInitialization();
-
-}
-
int found(char** argv, int argc, const char* name) {
int i = 1;
for (; i < argc; i++) {
@@ -141,7 +80,6 @@
#if WITH_J3
JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
- addCommandLinePass(argv);
mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL);
vm->runApplication(argc, argv);
vm->waitForExit();
@@ -158,7 +96,6 @@
#if WITH_J3
JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp);
- addCommandLinePass(argv);
MyCl.vmlets["java"] = (create_vm_t)(mvm::VirtualMachine::createJVM);
MyCl.compilers["java"] = (mvm::Object*)JCL;
#endif
More information about the vmkit-commits
mailing list