[vmkit-commits] [vmkit] r200650 - I think that I have found a way to rebuild a virtual stack of inlined functions. This commit just adds few code able to rebuild this stack in the safepoint generator.

Gael Thomas gael.thomas at lip6.fr
Sun Feb 2 12:46:17 PST 2014


Author: gthomas
Date: Sun Feb  2 14:46:16 2014
New Revision: 200650

URL: http://llvm.org/viewvc/llvm-project?rev=200650&view=rev
Log:
I think that I have found a way to rebuild a virtual stack of inlined functions. This commit just adds few code able to rebuild this stack in the safepoint generator.

Modified:
    vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
    vmkit/branches/mcjit/lib/vmkit/safpoint.cc
    vmkit/branches/mcjit/lib/vmkit/vmkit.cc

Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc?rev=200650&r1=200649&r2=200650&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Sun Feb  2 14:46:16 2014
@@ -47,11 +47,16 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
 
 #if 0
 	/* usefull to debug a single function */
-	if(   cl->name() == vm->names()->get("sun/util/calendar/BaseCalendar") &&
-				method->name() == vm->names()->get("getFixedDate") &&
+	if(   cl->name() == vm->names()->get("java.lang.Class") &&
+				method->name() == vm->names()->get("asSubclass") &&
 				method->signature()->name() == vm->names()->get("(IIILsun/util/calendar/BaseCalendar$Date;)J") ) {
-
+		vm->options()->genDebugExecute = 2;
 		vm->options()->debugTranslate = 3;
+		vm->options()->debugExecute = 5;
+	} else {
+		vm->options()->genDebugExecute = 0;
+		vm->options()->debugTranslate = 0;
+		//vm->options()->debugExecute = 0;
 	}
 #endif
 
@@ -132,6 +137,9 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
 		signature->setCaller(access, (J3Signature::function_t)loader->ee()->getFunctionAddress("generic-caller"));
 
 	method->markCompiled(llvmFunction, fnPtr);
+
+	if(vm->options()->debugTranslate > 2)
+		llvmFunction->dump();
 }
 
 J3CodeGen::~J3CodeGen() {
@@ -406,7 +414,7 @@ void J3CodeGen::invoke(uint32_t access,
 
 	stack.drop(n);
 
-	llvm::Value* res;
+	llvm::Instruction* res;
 
 	if(exceptions.nodes[curExceptionNode]->landingPad) {
 		//llvm::BasicBlock* after = forwardBranch("invoke-after", codeReader->tell(), 0, 0);
@@ -416,6 +424,8 @@ void J3CodeGen::invoke(uint32_t access,
 	} else {
 		res = builder.CreateCall(func, args);
 	}
+
+	res->setDebugLoc(llvm::DebugLoc::get(javaPC, 0, dbgInfo));
 	
 	if(!res->getType()->isVoidTy())
 		stack.push(flatten(res));
@@ -1700,7 +1710,7 @@ void J3CodeGen::generateJava() {
 
 	llvm::DIBuilder* dbgBuilder = new llvm::DIBuilder(*module);
 
-  dbgInfo =
+	dbgInfo =
 		dbgBuilder->createFunction(llvm::DIDescriptor(),    // Function scope
 															 llvmFunction->getName(), // Function name
 															 llvmFunction->getName(), // Mangled name
@@ -1712,7 +1722,10 @@ void J3CodeGen::generateJava() {
 																				                                              // This includes return type at 0th index.
 															 false,                   // True if this function is not externally visible
 															 false,                   // True if this is a function definition
-															 0                        // Set to the beginning of the scope this starts
+															 0,                       // Set to the beginning of the scope this starts
+															 0, 
+															 false,
+															 llvmFunction
 															 );
 
 	uint32_t maxStack   = reader.readU2();

Modified: vmkit/branches/mcjit/lib/vmkit/safpoint.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/safpoint.cc?rev=200650&r1=200649&r2=200650&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/safpoint.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/safpoint.cc Sun Feb  2 14:46:16 2014
@@ -2,6 +2,8 @@
 #include "vmkit/compiler.h"
 #include "vmkit/system.h"
 
+#include "llvm/DebugInfo.h"
+
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Module.h"
@@ -147,6 +149,27 @@ void VmkitGCMetadataPrinter::finishAssem
 
 			for(llvm::GCFunctionInfo::iterator safepoint=gcInfo->begin(); safepoint!=gcInfo->end(); safepoint++) {
 				llvm::DebugLoc* debug = &safepoint->Loc;
+				llvm::MDNode* inlinedAt = debug->getInlinedAt(getModule().getContext());
+
+				if(inlinedAt) {
+					fprintf(stderr, "find inline location in %s\n", gcInfo->getFunction().getName().data());
+					llvm::DISubprogram sub(debug->getScope(getModule().getContext()));
+					fprintf(stderr, "Inlined:                %s::%d\n", sub.getName().data(), debug->getLine());
+					llvm::DILocation cur(inlinedAt);
+					while(cur.getScope()) {
+						llvm::DISubprogram il(cur.getScope());
+						fprintf(stderr, "    =>                  %s::%d\n", il.getName().data(), cur.getLineNumber());
+						cur = cur.getOrigLocation();
+					};
+
+					llvm::DILocation   loc(inlinedAt);
+					llvm::DISubprogram il(loc.getScope());
+					
+
+					if(strcmp(gcInfo->getFunction().getName().data(), il.getName().data()))
+						abort();
+				}
+
 				uint32_t  kind = safepoint->Kind;
 
 				const llvm::MCExpr* address = llvm::MCSymbolRefExpr::Create(safepoint->Label, AP.OutStreamer.getContext());

Modified: vmkit/branches/mcjit/lib/vmkit/vmkit.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/vmkit.cc?rev=200650&r1=200649&r2=200650&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/vmkit.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/vmkit.cc Sun Feb  2 14:46:16 2014
@@ -190,9 +190,10 @@ void VMKit::sigend() {
 }
 
 void VMKit::throwException(void* obj) {
-	//internalError("throw exception...\n");
-	//fprintf(stderr, "throw %p\n", obj);
-	//Thread::get()->vm()->printStackTrace();
+	//	internalError("throw exception...\n");
+	//	fprintf(stderr, "throw %p\n", obj);
+	//	Thread::get()->vm()->printStackTrace();
+	//	abort();
 	throw obj;
 }
 





More information about the vmkit-commits mailing list