[vmkit-commits] [vmkit] r198061 - only explore exception handler after having explored their try clauses. Ensures that the its locals exists.

Gael Thomas gael.thomas at lip6.fr
Thu Dec 26 14:41:20 PST 2013


Author: gthomas
Date: Thu Dec 26 16:41:19 2013
New Revision: 198061

URL: http://llvm.org/viewvc/llvm-project?rev=198061&view=rev
Log:
only explore exception handler after having explored their try clauses. Ensures that the its locals exists.

Modified:
    vmkit/branches/mcjit/include/j3/j3codegen.h
    vmkit/branches/mcjit/include/j3/j3codegenexception.h
    vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
    vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc

Modified: vmkit/branches/mcjit/include/j3/j3codegen.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegen.h?rev=198061&r1=198060&r2=198061&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3codegen.h (original)
+++ vmkit/branches/mcjit/include/j3/j3codegen.h Thu Dec 26 16:41:19 2013
@@ -134,6 +134,8 @@ namespace j3 {
 
 		void               ldc(uint32_t idx);
 
+		void               selectExceptionNode(uint32_t idx);
+
 		void               translate();
 
 		void               initExceptionNode(J3ExceptionNode** pnode, uint32_t pc, J3ExceptionNode* node);

Modified: vmkit/branches/mcjit/include/j3/j3codegenexception.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegenexception.h?rev=198061&r1=198060&r2=198061&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3codegenexception.h (original)
+++ vmkit/branches/mcjit/include/j3/j3codegenexception.h Thu Dec 26 16:41:19 2013
@@ -18,6 +18,7 @@ namespace j3 {
 		uint32_t          handlerPC;
 		uint32_t          catchType;
 		llvm::BasicBlock* bb;
+		bool              isAdded;
 
 		void dump(uint32_t i);
 	};
@@ -29,6 +30,7 @@ namespace j3 {
 		J3ExceptionEntry** entries;
 		llvm::BasicBlock*  landingPad;
 		llvm::BasicBlock*  curCheck; /* last of the linked list of checker */
+		bool               isAdded;
 
 		void close(J3CodeGen* codeGen);
 		void addEntry(J3CodeGen* codeGen, J3ExceptionEntry* entry);

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=198061&r1=198060&r2=198061&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Thu Dec 26 16:41:19 2013
@@ -552,9 +552,7 @@ void J3CodeGen::ldc(uint32_t idx) {
 	switch(cl->getCtpType(idx)) {
 		case J3Cst::CONSTANT_Long:    res = builder->getInt64(cl->longAt(idx)); break;
 		case J3Cst::CONSTANT_Integer: res = builder->getInt32(cl->integerAt(idx)); break;
-		case J3Cst::CONSTANT_Float:   
-			fprintf(stderr, "generate float: %lf\n", cl->floatAt(idx));
-			res = llvm::ConstantFP::get(builder->getFloatTy(), cl->floatAt(idx)); break;
+		case J3Cst::CONSTANT_Float:   res = llvm::ConstantFP::get(builder->getFloatTy(), cl->floatAt(idx)); break;
 		case J3Cst::CONSTANT_Double:  res = llvm::ConstantFP::get(builder->getDoubleTy(), cl->doubleAt(idx)); break;
 		case J3Cst::CONSTANT_Class:   res = handleToObject(javaClass(cl->classAt(idx))); break;
 		case J3Cst::CONSTANT_String:  
@@ -628,6 +626,21 @@ bool J3CodeGen::onEndPoint() {
 	return 0;
 }
 
+void J3CodeGen::selectExceptionNode(uint32_t idx) {
+	curExceptionNode = idx;
+
+	if(!exceptions.nodes[idx]->isAdded) {
+		exceptions.nodes[idx]->isAdded = 1;
+		for(uint32_t i=0; i<exceptions.nodes[idx]->nbEntries; i++) {
+			J3ExceptionEntry* e = exceptions.nodes[idx]->entries[i];
+			if(!e->isAdded) {
+				e->isAdded = 1;
+				pendingBranchs[topPendingBranchs++] = e->handlerPC;
+			}
+		}
+	}
+}
+
 llvm::Value* J3CodeGen::buildString(const char* msg) {
 	std::vector<llvm::Constant*> elmts;
 	uint32_t n;
@@ -680,7 +693,7 @@ void J3CodeGen::translate() {
 	if(vm->options()->debugTranslate > 1)
 		exceptions.dump(vm->options()->debugTranslate-1);
 
-	curExceptionNode = 0;
+	selectExceptionNode(0);
 
 	stack.topStack = 0;
 	builder->SetInsertPoint(bb);
@@ -721,11 +734,11 @@ void J3CodeGen::translate() {
 
 		if(javaPC < exceptions.nodes[curExceptionNode]->pc || javaPC >= exceptions.nodes[curExceptionNode+1]->pc) {
 			if(javaPC == exceptions.nodes[curExceptionNode+1]->pc)
-				curExceptionNode++;
+				selectExceptionNode(curExceptionNode+1);
 			else
 				for(uint32_t i=0; i<exceptions.nbNodes; i++)
 					if(exceptions.nodes[i]->pc <= javaPC && javaPC < exceptions.nodes[i+1]->pc) {
-						curExceptionNode = i;
+						selectExceptionNode(i);
 						break;
 					}
 			//printf("cur exception node: %d\n", curExceptionNode);

Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc?rev=198061&r1=198060&r2=198061&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc Thu Dec 26 16:41:19 2013
@@ -62,7 +62,7 @@ void J3ExceptionNode::close(J3CodeGen* c
 	if(curCheck) {
 		codeGen->builder->SetInsertPoint(curCheck);
 		codeGen->builder->CreateBr(codeGen->bbRet);
-	}
+	} 
 }
 
 J3ExceptionNode** J3ExceptionTable::newNode(uint32_t pos, uint32_t pc) {





More information about the vmkit-commits mailing list