[vmkit-commits] [vmkit] r198509 - Don't add the same interface method twice.

Gael Thomas gael.thomas at lip6.fr
Sat Jan 4 10:10:56 PST 2014


Author: gthomas
Date: Sat Jan  4 12:10:55 2014
New Revision: 198509

URL: http://llvm.org/viewvc/llvm-project?rev=198509&view=rev
Log:
Don't add the same interface method twice.

Modified:
    vmkit/branches/mcjit/include/j3/j3object.h
    vmkit/branches/mcjit/lib/j3/vm/j3class.cc
    vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc
    vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc

Modified: vmkit/branches/mcjit/include/j3/j3object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=198509&r1=198508&r2=198509&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3object.h (original)
+++ vmkit/branches/mcjit/include/j3/j3object.h Sat Jan  4 12:10:55 2014
@@ -43,7 +43,7 @@ namespace j3 {
 		friend class J3Trampoline;
 
 	public:
-		static const uint32_t nbInterfaceMethodTable = 117;//41;
+		static const uint32_t nbInterfaceMethodTable = 41;
 		static const uint32_t gepObjectClass = 0;
 		static const uint32_t gepInterfaceMethods = 2;
 		static const uint32_t gepVirtualMethods = 4;

Modified: vmkit/branches/mcjit/lib/j3/vm/j3class.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=198509&r1=198508&r2=198509&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Sat Jan  4 12:10:55 2014
@@ -215,13 +215,21 @@ void J3ObjectType::prepareInterfaceTable
 					if(!method)
 						method = base;
 
-					total++;
 					uint32_t index = base->interfaceIndex() % J3VirtualTable::nbInterfaceMethodTable;
-					J3Method** tmp = (J3Method**)alloca(sizeof(J3Method*)*(slots[index].nbMethods+1));
-					memcpy(tmp, slots[index].methods, sizeof(J3Method*)*slots[index].nbMethods);
-					tmp[slots[index].nbMethods] = method;
-					slots[index].methods = tmp;
-					slots[index].nbMethods++;
+					uint32_t found = 0;
+
+					for(uint32_t i=0; !found && i<slots[index].nbMethods; i++)
+						if(slots[index].methods[i] == method)
+							found=1;
+
+					if(!found) {
+						total++;
+						J3Method** tmp = (J3Method**)alloca(sizeof(J3Method*)*(slots[index].nbMethods+1));
+						memcpy(tmp, slots[index].methods, sizeof(J3Method*)*slots[index].nbMethods);
+						tmp[slots[index].nbMethods] = method;
+						slots[index].methods = tmp;
+						slots[index].nbMethods++;
+					}
 				}
 			}
 		}

Modified: vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc?rev=198509&r1=198508&r2=198509&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc Sat Jan  4 12:10:55 2014
@@ -43,7 +43,7 @@ uint32_t J3ClassLoader::interfaceIndex(J
 
 	if(it == interfaces.end()) {
 		res = interfaces.size();
-		fprintf(stderr, " new interface: %s::%s%s ---> %d\n", method->cl()->name()->cStr(), method->name()->cStr(), method->signature()->name()->cStr(), res);
+		//		fprintf(stderr, " new interface: %s::%s%s ---> %d\n", method->cl()->name()->cStr(), method->name()->cStr(), method->signature()->name()->cStr(), res);
 		interfaces[method] = res;
 	} else {
 		res = it->second;

Modified: vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc?rev=198509&r1=198508&r2=198509&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc Sat Jan  4 12:10:55 2014
@@ -19,8 +19,12 @@ void* J3Trampoline::interfaceTrampoline(
 		desc->methods[0]->ensureCompiled(0);
 		res = desc->methods[0]->fnPtr();
 		handle->vt()->_interfaceMethodTable[index] = res;
-	} else
+	} else {
+		for(uint32_t i=0; i<desc->nbMethods; i++)
+			fprintf(stderr, "   method: %s::%s%s\n", desc->methods[i]->cl()->name()->cStr(),
+							desc->methods[i]->name()->cStr(), desc->methods[i]->signature()->name()->cStr());
 		J3::internalError("implement me: interface Trampoline with collision: %d", desc->nbMethods);
+	}
 
 	J3Thread::get()->restore(prev);
 





More information about the vmkit-commits mailing list