[vmkit-commits] [vmkit] r95499 - in /vmkit/trunk: include/j3/JnjvmModule.h include/mvm/JIT.h lib/J3/Classpath/ClasspathVMThrowable.inc lib/J3/Compiler/ExceptionsCheck.inc lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJIT.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaJITOpcodes.cpp lib/J3/Compiler/JnjvmModule.cpp lib/J3/LLVMRuntime/runtime-default.ll lib/J3/VMCore/JavaClass.cpp lib/J3/VMCore/JavaClass.h lib/Mvm/Compiler/JIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Feb 6 08:47:25 PST 2010
Author: geoffray
Date: Sat Feb 6 10:47:24 2010
New Revision: 95499
URL: http://llvm.org/viewvc/llvm-project?rev=95499&view=rev
Log:
Print line number information in J3!
Modified:
vmkit/trunk/include/j3/JnjvmModule.h
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc
vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
vmkit/trunk/lib/J3/Compiler/JavaJIT.h
vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
vmkit/trunk/lib/J3/VMCore/JavaClass.h
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
Modified: vmkit/trunk/include/j3/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/include/j3/JnjvmModule.h (original)
+++ vmkit/trunk/include/j3/JnjvmModule.h Sat Feb 6 10:47:24 2010
@@ -29,6 +29,7 @@
class GlobalVariable;
class GCFunctionInfo;
class GVMaterializer;
+ class MDNode;
class Module;
class Type;
class Value;
@@ -110,6 +111,7 @@
llvm::Function* methodFunction;
llvm::Constant* offsetConstant;
const llvm::FunctionType* functionType;
+ llvm::MDNode* DbgSubprogram;
public:
@@ -119,14 +121,17 @@
const llvm::FunctionType* getFunctionType();
LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0),
- offsetConstant(0), functionType(0), GCInfo(0) {}
+ offsetConstant(0), functionType(0), DbgSubprogram(0), GCInfo(0) {}
+ void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; }
+ llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; }
virtual void clear() {
GCInfo = 0;
methodFunction = 0;
offsetConstant = 0;
functionType = 0;
+ DbgSubprogram = 0;
}
};
@@ -230,8 +235,8 @@
static const llvm::Type* JavaClassType;
static const llvm::Type* JavaClassArrayType;
static const llvm::Type* JavaClassPrimitiveType;
- static const llvm::Type* JavaCacheType;
static const llvm::Type* ConstantPoolType;
+ static const llvm::Type* CodeLineInfoType;
static const llvm::Type* UTF8Type;
static const llvm::Type* JavaMethodType;
static const llvm::Type* JavaFieldType;
@@ -375,16 +380,13 @@
protected:
-
llvm::Module* TheModule;
llvm::GVMaterializer* TheModuleProvider;
JnjvmModule JavaIntrinsics;
void addJavaPasses();
-private:
-
-
+private:
bool enabledException;
bool cooperativeGC;
@@ -393,9 +395,11 @@
std::map<llvm::Function*, JavaMethod*> functions;
typedef std::map<llvm::Function*, JavaMethod*>::iterator function_iterator;
-
-public:
+ std::map<llvm::MDNode*, JavaMethod*> DbgInfos;
+ typedef std::map<llvm::MDNode*, JavaMethod*>::iterator dbg_iterator;
+
+public:
JavaLLVMCompiler(const std::string &ModuleID);
virtual bool isStaticCompiling() = 0;
@@ -424,13 +428,13 @@
void disableCooperativeGC() {
cooperativeGC = false;
}
-
+
virtual JavaCompiler* Create(const std::string& ModuleID) = 0;
virtual ~JavaLLVMCompiler();
-
JavaMethod* getJavaMethod(llvm::Function*);
+ llvm::MDNode* GetDbgSubprogram(JavaMethod* meth);
void resolveVirtualClass(Class* cl);
void resolveStaticClass(Class* cl);
@@ -442,7 +446,6 @@
static LLVMMethodInfo* getMethodInfo(JavaMethod* method);
static LLVMAssessorInfo& getTypedefInfo(const Typedef* type);
-
virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl) = 0;
virtual JavaObject* getFinalObject(llvm::Value* C) = 0;
virtual llvm::Constant* getNativeClass(CommonClass* cl) = 0;
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Sat Feb 6 10:47:24 2010
@@ -25,8 +25,8 @@
class Constant;
class ConstantFP;
class ConstantInt;
+ class DIFactory;
class ExecutionEngine;
- class ExistingModuleProvider;
class Function;
class FunctionPassManager;
class GCFunctionInfo;
@@ -171,6 +171,9 @@
llvm::Constant* constantFatMask;
llvm::Constant* constantPtrOne;
llvm::Constant* constantPtrZero;
+
+ llvm::DIFactory* DebugFactory;
+
static const llvm::PointerType* ptrType;
static const llvm::PointerType* ptr32Type;
static const llvm::PointerType* ptrPtrType;
@@ -181,7 +184,6 @@
static llvm::GCStrategy* GC;
static mvm::LockRecursive protectEngine;
static llvm::Module *globalModule;
- static llvm::ExistingModuleProvider *globalModuleProvider;
static llvm::FunctionPassManager* globalFunctionPasses;
static const llvm::TargetData* TheTargetData;
static mvm::BumpPtrAllocator* Allocator;
Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc Sat Feb 6 10:47:24 2010
@@ -98,12 +98,13 @@
}
bool native = isNative(meth->access);
+ uint16 lineNumber = meth->lookupLineNumber(reinterpret_cast<uintptr_t>(ip));
UserClass* newS = vm->upcalls->newStackTraceElement;
res = newS->doNew(vm);
vm->upcalls->initStackTraceElement->invokeIntSpecial(vm, newS, res,
&sourceName,
- 0, // source line
+ lineNumber,
&className,
&methodName, native);
return res;
Modified: vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc Sat Feb 6 10:47:24 2010
@@ -5,6 +5,11 @@
Instruction* res = CallInst::Create(F, args.begin(), args.end(), Name,
InsertAtEnd);
+ DILocation Location =
+ module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex,
+ DIScope(DbgSubprogram));
+ res->setMetadata("dbg", Location.getNode());
+
if (TheCompiler->hasExceptionsEnabled()) {
Value* threadId = getCurrentThread(module->JavaThreadType);
Value* geps[2] = { module->constantZero,
@@ -61,6 +66,10 @@
BasicBlock *InsertAtEnd) {
Instruction* res = CallInst::Create(F, arg1, Name, InsertAtEnd);
+ DILocation Location =
+ module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex,
+ DIScope(DbgSubprogram));
+ res->setMetadata("dbg", Location.getNode());
if (TheCompiler->hasExceptionsEnabled()) {
Value* threadId = getCurrentThread(module->JavaThreadType);
@@ -112,6 +121,10 @@
Value* args[2] = { arg1, arg2 };
Instruction* res = CallInst::Create(F, args, args + 2, Name, InsertAtEnd);
+ DILocation Location =
+ module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex,
+ DIScope(DbgSubprogram));
+ res->setMetadata("dbg", Location.getNode());
if (TheCompiler->hasExceptionsEnabled()) {
Value* threadId = getCurrentThread(module->JavaThreadType);
@@ -160,6 +173,10 @@
Instruction* JavaJIT::invoke(Value *F, const char* Name,
BasicBlock *InsertAtEnd) {
Instruction* res = llvm::CallInst::Create(F, Name, InsertAtEnd);
+ DILocation Location =
+ module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex,
+ DIScope(DbgSubprogram));
+ res->setMetadata("dbg", Location.getNode());
if (TheCompiler->hasExceptionsEnabled()) {
Value* threadId = getCurrentThread(module->JavaThreadType);
@@ -206,7 +223,11 @@
}
void JavaJIT::throwException(llvm::Function* F, Value* arg1) {
- Value* obj = CallInst::Create(F, arg1, "", currentBlock);
+ Instruction* obj = CallInst::Create(F, arg1, "", currentBlock);
+ DILocation Location =
+ module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex,
+ DIScope(DbgSubprogram));
+ obj->setMetadata("dbg", Location.getNode());
if (currentExceptionBlock != endExceptionBlock) {
Instruction* insn = currentExceptionBlock->begin();
PHINode* node = dyn_cast<PHINode>(insn);
@@ -246,7 +267,11 @@
void JavaJIT::throwException(llvm::Function* F, Value** args,
uint32 nbArgs) {
- Value* obj = CallInst::Create(F, args, args + nbArgs, "", currentBlock);
+ Instruction* obj = CallInst::Create(F, args, args + nbArgs, "", currentBlock);
+ DILocation Location =
+ module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex,
+ DIScope(DbgSubprogram));
+ obj->setMetadata("dbg", Location.getNode());
if (currentExceptionBlock != endExceptionBlock) {
Instruction* insn = currentExceptionBlock->begin();
PHINode* node = dyn_cast<PHINode>(insn);
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Feb 6 10:47:24 2010
@@ -956,11 +956,17 @@
MethodElts.push_back(ConstantExpr::getCast(Instruction::BitCast, func,
JnjvmModule::ptrType));
}
+
+ // codeInfo
+ MethodElts.push_back(Constant::getNullValue(JnjvmModule::CodeLineInfoType));
+
+ // codeInfoLength
+ MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0));
// offset
MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset));
- //JInfo
+ // JInfo
MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
return ConstantStruct::get(STy, MethodElts);
Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 6 10:47:24 2010
@@ -755,6 +755,9 @@
Instruction* JavaJIT::inlineCompile(BasicBlock*& curBB,
BasicBlock* endExBlock,
std::vector<Value*>& args) {
+
+ DbgSubprogram = TheCompiler->GetDbgSubprogram(compilingMethod);
+
PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "inline compile %s.%s\n",
UTF8Buffer(compilingClass->name).cString(),
UTF8Buffer(compilingMethod->name).cString());
@@ -792,7 +795,7 @@
for (uint32 i = 0; i < codeLen; ++i) {
opcodeInfos[i].exceptionBlock = endExBlock;
}
-
+
BasicBlock* firstBB = llvmFunction->begin();
if (firstBB->begin() != firstBB->end()) {
@@ -904,7 +907,24 @@
}
readExceptionTable(reader, codeLen);
-
+
+ // Lookup line number table attribute.
+ uint16 nba = reader.readU2();
+ for (uint16 i = 0; i < nba; ++i) {
+ const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2());
+ uint32 attLen = reader.readU4();
+ if (attName->equals(Attribut::lineNumberTableAttribut)) {
+ uint16 lineLength = reader.readU2();
+ for (uint16 i = 0; i < lineLength; ++i) {
+ uint16 pc = reader.readU2();
+ uint16 ln = reader.readU2();
+ opcodeInfos[pc].lineNumber = ln;
+ }
+ } else {
+ reader.seek(attLen, Reader::SeekCur);
+ }
+ }
+
exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
if (returnType != Type::getVoidTy(getGlobalContext())) {
@@ -944,17 +964,17 @@
UTF8Buffer(compilingClass->name).cString(),
UTF8Buffer(compilingMethod->name).cString());
-
+ DbgSubprogram = TheCompiler->GetDbgSubprogram(compilingMethod);
+
Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut);
if (!codeAtt) {
fprintf(stderr, "I haven't verified your class file and it's malformed:"
- " no code attribut found for %s.%s!\n",
+ " no code attribute found for %s.%s!\n",
UTF8Buffer(compilingClass->name).cString(),
UTF8Buffer(compilingMethod->name).cString());
abort();
- }
-
+ }
Reader reader(codeAtt, &(compilingClass->bytes));
uint16 maxStack = reader.readU2();
@@ -971,14 +991,14 @@
currentBlock = createBasicBlock("start");
endExceptionBlock = createBasicBlock("endExceptionBlock");
- unifiedUnreachable = createBasicBlock("unifiedUnreachable");
+ unifiedUnreachable = createBasicBlock("unifiedUnreachable");
opcodeInfos = new Opinfo[codeLen];
memset(opcodeInfos, 0, codeLen * sizeof(Opinfo));
for (uint32 i = 0; i < codeLen; ++i) {
opcodeInfos[i].exceptionBlock = endExceptionBlock;
}
-
+
#if JNJVM_EXECUTE > 0
{
Value* arg = TheCompiler->getMethodInClass(compilingMethod);
@@ -1123,6 +1143,23 @@
readExceptionTable(reader, codeLen);
+ // Lookup line number table attribute.
+ uint16 nba = reader.readU2();
+ for (uint16 i = 0; i < nba; ++i) {
+ const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2());
+ uint32 attLen = reader.readU4();
+ if (attName->equals(Attribut::lineNumberTableAttribut)) {
+ uint16 lineLength = reader.readU2();
+ for (uint16 i = 0; i < lineLength; ++i) {
+ uint16 pc = reader.readU2();
+ uint16 ln = reader.readU2();
+ opcodeInfos[pc].lineNumber = ln;
+ }
+ } else {
+ reader.seek(attLen, Reader::SeekCur);
+ }
+ }
+
exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
endBlock = createBasicBlock("end");
Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sat Feb 6 10:47:24 2010
@@ -20,6 +20,7 @@
#include "llvm/Metadata.h"
#include "llvm/Type.h"
#include "llvm/Value.h"
+#include "llvm/Analysis/DebugInfo.h"
#include "types.h"
@@ -56,10 +57,13 @@
/// stack - The stack at this location if there is a new block
///
std::vector<CommonClass*> stack;
+
+ /// lineNumber - The line number of this bytecode.
+ uint16 lineNumber;
};
-/// JavaJIT - The compilation engine of VMKit. Parses the bycode and returns
+/// JavaJIT - The compilation engine of J3. Parses the bycode and returns
/// its LLVM representation.
///
class JavaJIT {
@@ -78,6 +82,8 @@
callsStackWalker = false;
endNode = 0;
currentStackIndex = 0;
+ currentLineNumber = 0;
+ currentCtpIndex = -1;
}
/// javaCompile - Compile the Java method.
@@ -136,6 +142,16 @@
/// getCurrentThread - Emit code to get the current thread.
llvm::Value* getCurrentThread(const llvm::Type* Ty);
+//===------------------------- Debugging support --------------------------===//
+
+ llvm::MDNode* DbgSubprogram;
+
+ /// currentLineIndex - The current line being processed.
+ uint32 currentLineNumber;
+
+ /// currentCtpIndex - The constant pool index being processed.
+ uint16 currentCtpIndex;
+
//===--------------------------- Inline support ---------------------------===//
/// inlineCompile - Parse the method and start its LLVM representation
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 6 10:47:24 2010
@@ -13,7 +13,9 @@
#include "llvm/Instructions.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
+#include "llvm/Analysis/DebugInfo.h"
#include "llvm/CodeGen/GCStrategy.h"
+#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/Support/ManagedStatic.h"
@@ -60,6 +62,19 @@
JavaJITMethodInfo(GFI, currentCompiledMethod);
vm->RuntimeFunctions.addMethodInfo(MI, Code,
(void*)((uintptr_t)Code + Size));
+ uint32 infoLength = Details.LineStarts.size();
+ currentCompiledMethod->codeInfoLength = infoLength;
+ if (infoLength) {
+ currentCompiledMethod->codeInfo =
+ new(Alloc, "CodeLineInfo") CodeLineInfo[infoLength];
+ for (uint32 i = 0; i < infoLength; ++i) {
+ DILocation DLT = Details.MF->getDILocation(Details.LineStarts[i].Loc);
+ currentCompiledMethod->codeInfo[i].address =
+ Details.LineStarts[i].Address;
+ currentCompiledMethod->codeInfo[i].lineNumber = DLT.getLineNumber();
+ currentCompiledMethod->codeInfo[i].ctpIndex = DLT.getColumnNumber();
+ }
+ }
}
}
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Sat Feb 6 10:47:24 2010
@@ -167,6 +167,10 @@
currentExceptionBlock = opinfo->exceptionBlock;
+ // Update the line number information.
+ if (opinfo->lineNumber)
+ currentLineNumber = opinfo->lineNumber;
+
// To prevent a gcj bug with useless goto
if (currentBlock->getTerminator() != 0) {
currentBlock = createBasicBlock("gcj bug");
@@ -1932,24 +1936,28 @@
case INVOKEVIRTUAL : {
uint16 index = readU2(bytecodes, i);
+ currentCtpIndex = index;
invokeVirtual(index);
break;
}
case INVOKESPECIAL : {
uint16 index = readU2(bytecodes, i);
+ currentCtpIndex = index;
invokeSpecial(index);
break;
}
case INVOKESTATIC : {
uint16 index = readU2(bytecodes, i);
+ currentCtpIndex = index;
invokeStatic(index);
break;
}
case INVOKEINTERFACE : {
uint16 index = readU2(bytecodes, i);
+ currentCtpIndex = index;
invokeInterface(index);
i += 2;
break;
Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sat Feb 6 10:47:24 2010
@@ -42,6 +42,7 @@
const llvm::Type* JnjvmModule::JavaArrayDoubleType = 0;
const llvm::Type* JnjvmModule::JavaArrayLongType = 0;
const llvm::Type* JnjvmModule::JavaArrayObjectType = 0;
+const llvm::Type* JnjvmModule::CodeLineInfoType = 0;
const llvm::Type* JnjvmModule::ConstantPoolType = 0;
const llvm::Type* JnjvmModule::UTF8Type = 0;
const llvm::Type* JnjvmModule::JavaFieldType = 0;
@@ -158,6 +159,9 @@
PointerType::getUnqual(module->getTypeByName("JavaThread"));
MutatorThreadType =
PointerType::getUnqual(module->getTypeByName("MutatorThread"));
+
+ CodeLineInfoType =
+ PointerType::getUnqual(module->getTypeByName("CodeLineInfo"));
LLVMAssessorInfo::initialise();
}
@@ -374,6 +378,19 @@
return I->second;
}
+MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) {
+ if (getMethodInfo(meth)->getDbgSubprogram() == NULL) {
+ MDNode* node =
+ JavaIntrinsics.DebugFactory->CreateSubprogram(DIDescriptor(), "", "",
+ "", DICompileUnit(), 0,
+ DIType(), false,
+ false).getNode();
+ DbgInfos.insert(std::make_pair(node, meth));
+ getMethodInfo(meth)->setDbgSubprogram(node);
+ }
+ return getMethodInfo(meth)->getDbgSubprogram();
+}
+
JavaLLVMCompiler::~JavaLLVMCompiler() {
delete JavaFunctionPasses;
delete JavaNativeFunctionPasses;
Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll Sat Feb 6 10:47:24 2010
@@ -38,8 +38,10 @@
%JavaField = type { i8*, i16, %UTF8*, %UTF8*, %Attribut*, i16, %JavaClass*, i32,
i16, i8* }
+%CodeLineInfo = type { i8*, i16, i16, %JavaMethod*, %CodeLineInfo* }
+
%JavaMethod = type { i8*, i16, %Attribut*, i16, %JavaClass*,
- %UTF8*, %UTF8*, i8, i8*, i32, i8* }
+ %UTF8*, %UTF8*, i8, i8*, %CodeLineInfo*, i16, i32, i8* }
%JavaClassPrimitive = type { %JavaCommonClass, i32 }
%JavaClassArray = type { %JavaCommonClass, %JavaCommonClass* }
Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Sat Feb 6 10:47:24 2010
@@ -1730,3 +1730,14 @@
}
}
}
+
+uint16 JavaMethod::lookupLineNumber(uintptr_t ip) {
+ for(uint16 i = 0; i < codeInfoLength; ++i) {
+ if (codeInfo[i].address > ip) {
+ assert(i > 0 && "Wrong ip address for method");
+ return codeInfo[i - 1].lineNumber;
+ }
+ }
+ if (codeInfoLength) return codeInfo[codeInfoLength - 1].lineNumber;
+ return 0;
+}
Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Sat Feb 6 10:47:24 2010
@@ -989,6 +989,17 @@
}
};
+class CodeLineInfo : public mvm::PermanentObject {
+public:
+ uintptr_t address;
+ uint16 lineNumber;
+ uint16 ctpIndex;
+ // TODO: Use these fields when inlining.
+ JavaMethod* executingMethod;
+ // The code where the inlined method starts.
+ CodeLineInfo* inlineLocation;
+};
+
/// JavaMethod - This class represents Java methods.
///
class JavaMethod : public mvm::PermanentObject {
@@ -1049,7 +1060,15 @@
/// code - Pointer to the compiled code of this method.
///
void* code;
-
+
+ /// codeInfo - Array of CodeLineInfo objects.
+ ///
+ CodeLineInfo* codeInfo;
+
+ /// codeInfoLength - Number of entries in the codeInfo field.
+ ///
+ uint16 codeInfoLength;
+
/// offset - The index of the method in the virtual table.
///
uint32 offset;
@@ -1059,6 +1078,11 @@
///
Attribut* lookupAttribut(const UTF8* key);
+ /// lookupLineNumber - Find the line number based on the given instruction
+ /// pointer.
+ ///
+ uint16 lookupLineNumber(uintptr_t ip);
+
/// getSignature - Get the signature of thes method, resolving it if
/// necessary.
///
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=95499&r1=95498&r2=95499&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Feb 6 10:47:24 2010
@@ -17,6 +17,7 @@
#include <llvm/Module.h>
#include <llvm/PassManager.h>
#include <llvm/Type.h>
+#include <llvm/Analysis/DebugInfo.h>
#include <llvm/Analysis/LoopPass.h>
#include <llvm/Analysis/Verifier.h>
#include <llvm/Assembly/Parser.h>
@@ -307,7 +308,8 @@
module->setDataLayout(globalModule->getDataLayout());
module->setTargetTriple(globalModule->getTargetTriple());
- LLVMContext& Context = module->getContext();
+ LLVMContext& Context = module->getContext();
+ DebugFactory = new DIFactory(*module);
// Constant declaration
constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1);
More information about the vmkit-commits
mailing list