[llvm-commits] [vmkit] r51028 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h JavaIsolate.cpp JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaJITOpcodes.cpp JavaMetaJIT.cpp JavaRuntimeJIT.cpp Jnjvm.cpp Jnjvm.h LowerConstantCalls.cpp VirtualTables.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue May 13 02:27:10 PDT 2008
Author: geoffray
Date: Tue May 13 04:27:08 2008
New Revision: 51028
URL: http://llvm.org/viewvc/llvm-project?rev=51028&view=rev
Log:
Java code does not call doNew anymore but gcmalloc instead.
The virtualInstance field of a class was useless.
Removed unused LLVM functions.
Set the data layout when creating modules.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Tue May 13 04:27:08 2008
@@ -351,39 +351,12 @@
return res;
}
-#ifndef MULTIPLE_VM
-JavaObject* Class::doNew(Jnjvm* vm) {
- JavaObject* res = (JavaObject*)gc::operator new(virtualSize, virtualVT);
- res->classOf = this;
- return res;
-}
-
-// Copy doNew because LLVM wants two different pointers (for simplicity)
-JavaObject* Class::doNewUnknown(Jnjvm* vm) {
- JavaObject* res = (JavaObject*)gc::operator new(virtualSize, virtualVT);
- res->classOf = this;
- return res;
-}
-#else
JavaObject* Class::doNew(Jnjvm* vm) {
JavaObject* res = (JavaObject*)vm->allocateObject(virtualSize, virtualVT);
res->classOf = this;
return res;
}
-// Copy doNew because LLVM wants two different pointers (for simplicity)
-JavaObject* Class::doNewUnknown(Jnjvm* vm) {
- JavaObject* res = (JavaObject*)vm->allocateObject(virtualSize, virtualVT);
- res->classOf = this;
- return res;
-}
-#endif
-
-JavaObject* Class::initialiseObject(JavaObject* res) {
- memcpy(res, virtualInstance, virtualSize);
- return res;
-}
-
bool CommonClass::inheritName(const UTF8* Tname) {
if (name->equals(Tname)) {
return true;
@@ -576,16 +549,15 @@
VirtualTable* VT = JavaJIT::makeVT(cl, false);
uint64 size = mvm::jit::getTypeSize(cl->virtualType->getContainedType(0));
- cl->virtualSize = size;
+ cl->virtualSize = (uint32)size;
+ mvm::jit::protectConstants();
+ cl->virtualSizeLLVM = llvm::ConstantInt::get(llvm::Type::Int32Ty, size);
+ mvm::jit::unprotectConstants();
cl->virtualVT = VT;
- cl->virtualInstance = (JavaObject*)cl->isolate->allocateObject(size, VT);
- cl->virtualInstance->initialise(cl);
for (std::vector<JavaField*>::iterator i = cl->virtualFields.begin(),
e = cl->virtualFields.end(); i!= e; ++i) {
- // Virtual fields apparenty do not have initializers, which is good
- // for isolates. I should not have to do this, but just to make sure.
- (*i)->initField(cl->virtualInstance);
+ JavaJIT::initField(*i);
}
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Tue May 13 04:27:08 2008
@@ -169,13 +169,13 @@
class Class : public CommonClass {
private:
llvm::GlobalVariable* _staticVar;
+ llvm::GlobalVariable* _llvmVT;
public:
static VirtualTable* VT;
unsigned int minor;
unsigned int major;
ArrayUInt8* bytes;
- JavaObject* virtualInstance;
llvm::Function* virtualTracer;
llvm::Function* staticTracer;
mvm::Code* codeVirtualTracer;
@@ -189,14 +189,14 @@
void resolveFields();
llvm::Value* staticVar(JavaJIT* jit);
+ llvm::Value* llvmVT(JavaJIT* jit);
- uint64 virtualSize;
+ llvm::ConstantInt* virtualSizeLLVM;
+ uint32 virtualSize;
VirtualTable* virtualVT;
- uint64 staticSize;
+ uint32 staticSize;
VirtualTable* staticVT;
JavaObject* doNew(Jnjvm* vm);
- JavaObject* doNewUnknown(Jnjvm* vm);
- JavaObject* initialiseObject(JavaObject* obj);
virtual void print(mvm::PrintBuffer *buf) const;
virtual void TRACER;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue May 13 04:27:08 2008
@@ -449,6 +449,9 @@
isolate->functions = vm_new(isolate, FunctionMap)();
isolate->functionDefs = vm_new(isolate, FunctionDefMap)();
isolate->module = new llvm::Module("Isolate JnJVM");
+ std::string str =
+ mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
+ isolate->module->setDataLayout(str);
isolate->protectModule = mvm::Lock::allocNormal();
isolate->TheModuleProvider = new JnjvmModuleProvider(isolate->module,
isolate->functions,
@@ -514,6 +517,9 @@
isolate->functionDefs = vm_new(isolate, FunctionDefMap)();
isolate->protectModule = mvm::Lock::allocNormal();
isolate->module = new llvm::Module("Bootstrap JnJVM");
+ std::string str =
+ mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
+ isolate->module->setDataLayout(str);
isolate->TheModuleProvider = new JnjvmModuleProvider(isolate->module,
isolate->functions,
isolate->functionDefs);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue May 13 04:27:08 2008
@@ -253,7 +253,8 @@
endNode = llvm::PHINode::Create(funcType->getReturnType(), "", endBlock);
Value* buf = llvm::CallInst::Create(getSJLJBufferLLVM, "", currentBlock);
- Value* test = llvm::CallInst::Create(mvm::jit::setjmpLLVM, buf, "", currentBlock);
+ Value* test = llvm::CallInst::Create(mvm::jit::setjmpLLVM, buf, "",
+ currentBlock);
test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "",
currentBlock);
llvm::BranchInst::Create(executeBlock, endBlock, test, currentBlock);
@@ -300,8 +301,8 @@
valPtrType);
mvm::jit::unprotectConstants();//->unlock();
- Value* result = llvm::CallInst::Create(valPtr, nativeArgs.begin(), nativeArgs.end(),
- "", currentBlock);
+ Value* result = llvm::CallInst::Create(valPtr, nativeArgs.begin(),
+ nativeArgs.end(), "", currentBlock);
if (funcType->getReturnType() != Type::VoidTy)
endNode->addIncoming(result, currentBlock);
@@ -727,7 +728,8 @@
mvm::jit::runPasses(llvmFunction, JavaThread::get()->perFunctionPasses);
/*
- if (compilingMethod->name == compilingClass->isolate->asciizConstructUTF8("main")) {
+ if (compilingMethod->name ==
+ compilingClass->isolate->asciizConstructUTF8("main")) {
llvmFunction->print(llvm::cout);
void* res = mvm::jit::executionEngine->getPointerToGlobal(llvmFunction);
void* base = res;
@@ -1605,35 +1607,43 @@
ctpInfo->checkInfoOfClass(index);
Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(index));
- Value* val = 0;
- if (!cl || !(cl->isResolved())
-#ifndef MULTIPLE_VM
- || !cl->isReady()
-#endif
- ) {
- Value* node = getResolvedClass(index, true);
-#ifndef MULTIPLE_VM
- val = invoke(doNewUnknownLLVM, node, "", currentBlock);
-#else
- val = invoke(doNewUnknownLLVM, node, isolateLocal, "", currentBlock);
-#endif
+ Value* Size = 0;
+ Value* VT = 0;
+ Value* Cl = 0;
+ if (!cl || !cl->isResolved()) {
+ Cl = getResolvedClass(index, true);
+ Size = CallInst::Create(getObjectSizeFromClassLLVM, Cl, "", currentBlock);
+ VT = CallInst::Create(getVTFromClassLLVM, Cl, "", currentBlock);
} else {
- Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module),
- "", currentBlock);
-#ifdef MULTIPLE_VM
Module* M = compilingClass->isolate->module;
- Value* arg = new LoadInst(cl->llvmVar(M), "", currentBlock);
- load = invoke(initialisationCheckLLVM, arg, "", currentBlock);
- val = invoke(doNewLLVM, load, isolateLocal, "", currentBlock);
-#else
- val = invoke(doNewLLVM, load, "", currentBlock);
+ Size = cl->virtualSizeLLVM;
+ VT = cl->llvmVT(this);
+ Cl = new LoadInst(cl->llvmVar(M), "", currentBlock);
+#ifndef MULTIPLE_VM
+ if (!cl->isReady())
#endif
- // give the real type info, escape analysis uses it
- new BitCastInst(val, cl->virtualType, "", currentBlock);
+ Cl = invoke(initialisationCheckLLVM, Cl, "", currentBlock);
}
-
- push(val, AssessorDesc::dRef);
+ std::vector<Value*> args;
+ args.push_back(Size);
+ args.push_back(VT);
+#ifdef MULTIPLE_GC
+ args.push_back(CallInst::Create(getCollectorLLVM, isolateLocal, "",
+ currentBlock));
+#endif
+ Value* val = invoke(javaObjectAllocateLLVM, args, "", currentBlock);
+
+ // Set the class
+
+ std::vector<Value*> gep;
+ gep.push_back(mvm::jit::constantZero);
+ gep.push_back(JavaObject::classOffset());
+ Value* GEP = GetElementPtrInst::Create(val, gep.begin(), gep.end(), "",
+ currentBlock);
+ new StoreInst(Cl, GEP, currentBlock);
+
+ push(val, AssessorDesc::dRef);
}
Value* JavaJIT::arraySize(Value* val) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Tue May 13 04:27:08 2008
@@ -229,6 +229,7 @@
static void initialiseJITIsolateVM(Jnjvm* vm);
+ static void initField(JavaField* field);
static void initField(JavaField* field, JavaObject* obj, uint64 val = 0);
static void initField(JavaField* field, JavaObject* obj, JavaObject* val);
static void initField(JavaField* field, JavaObject* obj, double val);
@@ -237,26 +238,12 @@
static llvm::Function* getSJLJBufferLLVM;
static llvm::Function* virtualLookupLLVM;
static llvm::Function* fieldLookupLLVM;
- static llvm::Function* UTF8AconsLLVM;
- static llvm::Function* Int8AconsLLVM;
- static llvm::Function* Int32AconsLLVM;
- static llvm::Function* Int16AconsLLVM;
- static llvm::Function* FloatAconsLLVM;
- static llvm::Function* DoubleAconsLLVM;
- static llvm::Function* LongAconsLLVM;
- static llvm::Function* ObjectAconsLLVM;
static llvm::Function* printExecutionLLVM;
static llvm::Function* printMethodStartLLVM;
static llvm::Function* printMethodEndLLVM;
static llvm::Function* jniProceedPendingExceptionLLVM;
- static llvm::Function* doNewLLVM;
- // this is when the type is not known at compile time (escape analysis)
- static llvm::Function* doNewUnknownLLVM;
-#ifdef MULTIPLE_VM
static llvm::Function* initialisationCheckLLVM;
static llvm::Function* forceInitialisationCheckLLVM;
-#endif
- static llvm::Function* initialiseObjectLLVM;
static llvm::Function* newLookupLLVM;
#ifndef WITHOUT_VTABLE
static llvm::Function* vtableLookupLLVM;
@@ -275,8 +262,14 @@
static llvm::Function* arrayLengthLLVM;
static llvm::Function* getVTLLVM;
static llvm::Function* getClassLLVM;
- static llvm::Function* getCollectorLLVM;
static llvm::Function* javaObjectAllocateLLVM;
+#ifdef MULTIPLE_GC
+ static llvm::Function* getCollectorLLVM;
+#endif
+ static llvm::Function* getVTFromClassLLVM;
+ static llvm::Function* getObjectSizeFromClassLLVM;
+ static llvm::ConstantInt* constantOffsetObjectSizeInClass;
+ static llvm::ConstantInt* constantOffsetVTInClass;
static Class* getCallingClass();
@@ -289,6 +282,8 @@
static llvm::Function* markAndTraceLLVM;
static const llvm::FunctionType* markAndTraceLLVMType;
#endif
+
+ static const llvm::Type* VTType;
static llvm::Constant* constantJavaObjectNull;
static llvm::Constant* constantUTF8Null;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Tue May 13 04:27:08 2008
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include <stddef.h>
+
#include "llvm/Instructions.h"
#include "llvm/LinkAllPasses.h"
#include "llvm/Module.h"
@@ -19,6 +21,7 @@
#include "JavaArray.h"
#include "JavaCache.h"
+#include "JavaClass.h"
#include "JavaJIT.h"
#include "JavaObject.h"
#include "JavaThread.h"
@@ -69,7 +72,7 @@
mvm::jit::protectTypes();//->lock();
// Create JavaObject::llvmType
const llvm::Type* Pty = mvm::jit::ptrType;
- const llvm::Type* VTType = PointerType::getUnqual(PointerType::getUnqual(Type::Int32Ty));
+ VTType = PointerType::getUnqual(PointerType::getUnqual(Type::Int32Ty));
std::vector<const llvm::Type*> objectFields;
objectFields.push_back(VTType); // VT
@@ -178,36 +181,6 @@
module);
}
- // Create doNewLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
-#ifdef MULTIPLE_VM
- args.push_back(mvm::jit::ptrType);
-#endif
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
- false);
-
- doNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm5Class5doNewEPNS_5JnjvmE",
- module);
- }
-
- // Create doNewUnknownLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
-#ifdef MULTIPLE_VM
- args.push_back(mvm::jit::ptrType);
-#endif
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
- false);
-
- doNewUnknownLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm5Class12doNewUnknownEPNS_5JnjvmE",
- module);
- }
-
// Create multiCallNewLLVM
{
std::vector<const Type*> args;
@@ -221,7 +194,6 @@
module);
}
-#ifdef MULTIPLE_VM
// Create initialisationCheckLLVM
{
std::vector<const Type*> args;
@@ -251,73 +223,7 @@
"forceInitialisationCheck",
module);
}
-#endif
-
-
-
- // Create *AconsLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- args.push_back(mvm::jit::ptrType);
-#ifdef MULTIPLE_VM
- args.push_back(mvm::jit::ptrType);
-#endif
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
- false);
-
- FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm10ArrayFloat5aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
-
- Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm10ArraySInt85aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
-
- DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm11ArrayDouble5aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
-
- Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm11ArraySInt165aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
-
- Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm11ArraySInt325aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
- UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm4UTF85aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
-
- LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
-
- ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm11ArrayObject5aconsEiPNS_10ClassArrayEPNS_5JnjvmE",
- module);
- }
-
- // Create initialiseObjectLLVM
- {
- std::vector<const Type*> args;
- args.push_back(mvm::jit::ptrType);
- args.push_back(JavaObject::llvmType);
- const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
- false);
-
- initialiseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "_ZN5jnjvm5Class16initialiseObjectEPNS_10JavaObjectE",
- module);
- PAListPtr func_toto_PAL;
- SmallVector<ParamAttrsWithIndex, 4> Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
- Attrs.push_back(PAWI);
- func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
- initialiseObjectLLVM->setParamAttrs(func_toto_PAL);
- }
// Create arrayLengthLLVM
{
@@ -364,7 +270,7 @@
const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false);
getClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
- "getVT",
+ "getClass",
module);
PAListPtr func_toto_PAL;
SmallVector<ParamAttrsWithIndex, 4> Attrs;
@@ -397,6 +303,65 @@
newLookupLLVM->setParamAttrs(func_toto_PAL);
}
+#ifdef MULTIPLE_GC
+ // Create getCollectorLLVM
+ {
+ std::vector<const Type*> args;
+ args.push_back(mvm::jit::ptrType);
+ const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
+ false);
+
+ getCollectorLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+ "getCollector",
+ module);
+ PAListPtr func_toto_PAL;
+ SmallVector<ParamAttrsWithIndex, 4> Attrs;
+ ParamAttrsWithIndex PAWI;
+ PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
+ Attrs.push_back(PAWI);
+ func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+ getCollectorLLVM->setParamAttrs(func_toto_PAL);
+ }
+#endif
+
+ // Create getVTFromClassLLVM
+ {
+ std::vector<const Type*> args;
+ args.push_back(mvm::jit::ptrType);
+ const FunctionType* type = FunctionType::get(VTType, args,
+ false);
+
+ getVTFromClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+ "getVTFromClass",
+ module);
+ PAListPtr func_toto_PAL;
+ SmallVector<ParamAttrsWithIndex, 4> Attrs;
+ ParamAttrsWithIndex PAWI;
+ PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
+ Attrs.push_back(PAWI);
+ func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+ getVTFromClassLLVM->setParamAttrs(func_toto_PAL);
+ }
+
+ // Create getSizeFromClassLLVM
+ {
+ std::vector<const Type*> args;
+ args.push_back(mvm::jit::ptrType);
+ const FunctionType* type = FunctionType::get(Type::Int32Ty, args,
+ false);
+
+ getObjectSizeFromClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+ "getObjectSizeFromClass",
+ module);
+ PAListPtr func_toto_PAL;
+ SmallVector<ParamAttrsWithIndex, 4> Attrs;
+ ParamAttrsWithIndex PAWI;
+ PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone;
+ Attrs.push_back(PAWI);
+ func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+ getObjectSizeFromClassLLVM->setParamAttrs(func_toto_PAL);
+ }
+
#ifndef WITHOUT_VTABLE
// Create vtableLookupLLVM
{
@@ -782,9 +747,14 @@
GlobalValue::ExternalLinkage,
cons, "",
module);
-
-
-
+ {
+ Class fake;
+ int offset = (intptr_t)&(fake.virtualSize) - (intptr_t)&fake;
+ constantOffsetObjectSizeInClass = ConstantInt::get(Type::Int32Ty, offset);
+ offset = (intptr_t)&(fake.virtualVT) - (intptr_t)&fake;
+ constantOffsetVTInClass = ConstantInt::get(Type::Int32Ty, offset);
+ }
+
mvm::jit::unprotectConstants();//->unlock();
}
@@ -794,7 +764,8 @@
llvm::Constant* JavaJIT::constantJavaObjectSize;
llvm::GlobalVariable* JavaJIT::JavaObjectVT;
llvm::GlobalVariable* JavaJIT::ArrayObjectVT;
-
+llvm::ConstantInt* JavaJIT::constantOffsetObjectSizeInClass;
+llvm::ConstantInt* JavaJIT::constantOffsetVTInClass;
namespace mvm {
@@ -814,8 +785,6 @@
// LLVM does not allow calling functions from other modules in verifier
//PM->add(llvm::createVerifierPass()); // Verify that input is correct
- // do escape analysis first, because the type is given in the first bitcastinst
- addPass(PM, mvm::createEscapeAnalysisPass(JavaJIT::doNewLLVM, JavaJIT::initialiseObjectLLVM));
addPass(PM, llvm::createCFGSimplificationPass()); // Clean up disgusting code
addPass(PM, llvm::createScalarReplAggregatesPass());// Kill useless allocas
addPass(PM, llvm::createInstructionCombiningPass()); // Clean up after IPCP & DAE
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Tue May 13 04:27:08 2008
@@ -1902,7 +1902,7 @@
args.push_back(size);
args.push_back(new LoadInst(TheVT, "", currentBlock));
#ifdef MULTIPLE_GC
- args.push_back(CallInst::Create(getCollector, isolateLocal, "",
+ args.push_back(CallInst::Create(getCollectorLLVM, isolateLocal, "",
currentBlock));
#endif
Value* res = invoke(javaObjectAllocateLLVM, args, "", currentBlock);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Tue May 13 04:27:08 2008
@@ -98,6 +98,28 @@
return _llvmVar;
}
+Value* Class::llvmVT(JavaJIT* jit) {
+ if (!_llvmVT) {
+ aquire();
+ if (!_llvmVT) {
+ mvm::jit::protectConstants();//->lock();
+ Constant* cons =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (virtualVT)),
+ JavaJIT::VTType);
+ mvm::jit::unprotectConstants();//->unlock();
+
+ isolate->protectModule->lock();
+ _llvmVT = new GlobalVariable(JavaJIT::VTType, true,
+ GlobalValue::ExternalLinkage,
+ cons, "",
+ isolate->module);
+ isolate->protectModule->unlock();
+ }
+ release();
+ }
+ return new LoadInst(_llvmVT, "", jit->currentBlock);
+}
+
Value* CommonClass::llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB) {
#ifndef MULTIPLE_VM
if (!_llvmDelegatee) {
@@ -312,7 +334,7 @@
}
-static void _initField(JavaField* field) {
+void JavaJIT::initField(JavaField* field) {
ConstantInt* offset = field->offset;
const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
bool stat = isStatic(field->access);
@@ -327,7 +349,7 @@
}
void JavaJIT::initField(JavaField* field, JavaObject* obj, uint64 val) {
- _initField(field);
+ initField(field);
const AssessorDesc* funcs = field->signature->funcs;
if (funcs == AssessorDesc::dLong) {
@@ -349,17 +371,17 @@
}
void JavaJIT::initField(JavaField* field, JavaObject* obj, JavaObject* val) {
- _initField(field);
+ initField(field);
((JavaObject**)((uint64)obj + field->ptrOffset))[0] = val;
}
void JavaJIT::initField(JavaField* field, JavaObject* obj, double val) {
- _initField(field);
+ initField(field);
((double*)((uint64)obj + field->ptrOffset))[0] = val;
}
void JavaJIT::initField(JavaField* field, JavaObject* obj, float val) {
- _initField(field);
+ initField(field);
((float*)((uint64)obj + field->ptrOffset))[0] = val;
}
@@ -779,22 +801,22 @@
void JavaField::operator()(float val) {
JavaField * field = this;
- return (*field)(classDef->virtualInstance, val);
+ return (*field)(0, val);
}
void JavaField::operator()(double val) {
JavaField * field = this;
- return (*field)(classDef->virtualInstance, val);
+ return (*field)(0, val);
}
void JavaField::operator()(sint64 val) {
JavaField * field = this;
- return (*field)(classDef->virtualInstance, val);
+ return (*field)(0, val);
}
void JavaField::operator()(uint32 val) {
JavaField * field = this;
- return (*field)(classDef->virtualInstance, val);
+ return (*field)(0, val);
}
Function* Signdef::createFunctionCallBuf(bool virt) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Tue May 13 04:27:08 2008
@@ -47,25 +47,12 @@
#ifndef WITHOUT_VTABLE
llvm::Function* JavaJIT::vtableLookupLLVM = 0;
#endif
-llvm::Function* JavaJIT::UTF8AconsLLVM = 0;
-llvm::Function* JavaJIT::Int8AconsLLVM = 0;
-llvm::Function* JavaJIT::Int32AconsLLVM = 0;
-llvm::Function* JavaJIT::Int16AconsLLVM = 0;
-llvm::Function* JavaJIT::FloatAconsLLVM = 0;
-llvm::Function* JavaJIT::DoubleAconsLLVM = 0;
-llvm::Function* JavaJIT::LongAconsLLVM = 0;
-llvm::Function* JavaJIT::ObjectAconsLLVM = 0;
llvm::Function* JavaJIT::printExecutionLLVM = 0;
llvm::Function* JavaJIT::printMethodStartLLVM = 0;
llvm::Function* JavaJIT::printMethodEndLLVM = 0;
llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0;
-llvm::Function* JavaJIT::doNewLLVM = 0;
-llvm::Function* JavaJIT::doNewUnknownLLVM = 0;
-#ifdef MULTIPLE_VM
llvm::Function* JavaJIT::initialisationCheckLLVM = 0;
llvm::Function* JavaJIT::forceInitialisationCheckLLVM = 0;
-#endif
-llvm::Function* JavaJIT::initialiseObjectLLVM = 0;
llvm::Function* JavaJIT::newLookupLLVM = 0;
llvm::Function* JavaJIT::instanceOfLLVM = 0;
llvm::Function* JavaJIT::aquireObjectLLVM = 0;
@@ -77,12 +64,20 @@
llvm::Function* JavaJIT::arrayLengthLLVM = 0;
llvm::Function* JavaJIT::getVTLLVM = 0;
llvm::Function* JavaJIT::getClassLLVM = 0;
+llvm::Function* JavaJIT::getVTFromClassLLVM = 0;
+llvm::Function* JavaJIT::getObjectSizeFromClassLLVM = 0;
+
+#ifdef MULTIPLE_GC
+llvm::Function* JavaJIT::getCollectorLLVM;
+#endif
#ifdef SERVICE_VM
llvm::Function* JavaJIT::aquireObjectInSharedDomainLLVM = 0;
llvm::Function* JavaJIT::releaseObjectInSharedDomainLLVM = 0;
#endif
+const llvm::Type* JavaJIT::VTType;
+
extern "C" JavaString* runtimeUTF8ToStr(const UTF8* val) {
Jnjvm* vm = JavaThread::get()->isolate;
return vm->UTF8ToStr(val);
@@ -239,12 +234,12 @@
}
return val->second;
}
+#endif
extern "C" CommonClass* initialisationCheck(CommonClass* cl) {
cl->isolate->initialiseClass(cl);
return cl;
}
-#endif
extern "C" JavaObject* getClassDelegatee(CommonClass* cl) {
#ifdef MULTIPLE_VM
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Tue May 13 04:27:08 2008
@@ -716,7 +716,6 @@
#ifndef MULTIPLE_VM
cl->_staticInstance = 0;
#endif
- cl->virtualInstance = 0;
cl->super = 0;
cl->ctpInfo = 0;
return cl;
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Tue May 13 04:27:08 2008
@@ -59,6 +59,9 @@
class Jnjvm : public mvm::Object{
public:
+#ifdef MULTIPLE_GC
+ Collector* GC;
+#endif
static VirtualTable* VT;
static Jnjvm* bootstrapVM;
@@ -256,9 +259,6 @@
DelegateeMap* delegatees;
#endif
-#ifdef MULTIPLE_GC
- Collector* GC;
-#endif
mvm::Lock* protectModule;
llvm::Module* module;
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Tue May 13 04:27:08 2008
@@ -32,7 +32,8 @@
private:
};
char LowerConstantCalls::ID = 0;
- RegisterPass<LowerConstantCalls> X("LowerArrayLength", "Lower Array length");
+ RegisterPass<LowerConstantCalls> X("LowerConstantCalls",
+ "Lower Constant calls");
bool LowerConstantCalls::runOnFunction(Function& F) {
bool Changed = false;
@@ -78,9 +79,46 @@
Value* cl = new LoadInst(classPtr, "", CI);
CI->replaceAllUsesWith(cl);
CI->eraseFromParent();
+ } else if (V == jnjvm::JavaJIT::getVTFromClassLLVM) {
+ Changed = true;
+ Value* val = CI->getOperand(1);
+ std::vector<Value*> indexes;
+ indexes.push_back(jnjvm::JavaJIT::constantOffsetVTInClass);
+ Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
+ indexes.end(), "", CI);
+ VTPtr = new BitCastInst(VTPtr, mvm::jit::ptrPtrType, "", CI);
+ Value* VT = new LoadInst(VTPtr, "", CI);
+ VT = new BitCastInst(VT, jnjvm::JavaJIT::VTType, "", CI);
+ CI->replaceAllUsesWith(VT);
+ CI->eraseFromParent();
+ } else if (V == jnjvm::JavaJIT::getObjectSizeFromClassLLVM) {
+ Changed = true;
+ Value* val = CI->getOperand(1);
+ std::vector<Value*> indexes;
+ indexes.push_back(jnjvm::JavaJIT::constantOffsetObjectSizeInClass);
+ Value* SizePtr = GetElementPtrInst::Create(val, indexes.begin(),
+ indexes.end(), "", CI);
+ SizePtr = new BitCastInst(SizePtr, mvm::jit::ptr32Type, "", CI);
+ Value* Size = new LoadInst(SizePtr, "", CI);
+ CI->replaceAllUsesWith(Size);
+ CI->eraseFromParent();
}
-#ifdef MULTIPLE_VM
else if (V == jnjvm::JavaJIT::forceInitialisationCheckLLVM) {
+ Changed = true;
+ CI->eraseFromParent();
+ }
+#ifdef MULTIPLE_GC
+ else if (V == jnjvm::JavaJIT::getCollectorLLVM) {
+ Changed = true;
+ Value* val = CI->getOperand(1);
+ std::vector<Value*> indexes;
+ indexes.push_back(mvm::jit::constantOne);
+ val = new BitCastInst(val, mvm::jit::ptrPtrType, "", CI);
+ Value* CollectorPtr = GetElementPtrInst::Create(val, indexes.begin(),
+ indexes.end(), "",
+ CI);
+ Value* Collector = new LoadInst(CollectorPtr, "", CI);
+ CI->replaceAllUsesWith(Collector);
CI->eraseFromParent();
}
#endif
Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=51028&r1=51027&r2=51028&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Tue May 13 04:27:08 2008
@@ -133,7 +133,6 @@
#ifndef MULTIPLE_VM
_staticInstance->MARK_AND_TRACE;
#endif
- virtualInstance->MARK_AND_TRACE;
ctpInfo->MARK_AND_TRACE;
TRACE_VECTOR(Attribut*, gc_allocator, attributs);
codeStaticTracer->MARK_AND_TRACE;
More information about the llvm-commits
mailing list