[vmkit-commits] [vmkit] r197975 - Interface method dispatch table is ok, but type is not checked and do not yet handle collision.

Gael Thomas gael.thomas at lip6.fr
Tue Dec 24 03:03:27 PST 2013


Author: gthomas
Date: Tue Dec 24 05:03:27 2013
New Revision: 197975

URL: http://llvm.org/viewvc/llvm-project?rev=197975&view=rev
Log:
Interface method dispatch table is ok, but type is not checked and do not yet handle  collision.

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

Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=197975&r1=197974&r2=197975&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Tue Dec 24 05:03:27 2013
@@ -160,18 +160,19 @@ namespace j3 {
 	public:
 		J3ObjectType(J3ClassLoader* loader, const vmkit::Name* name);
 
-		void prepareInterfaceTable();
+		J3InterfaceSlotDescriptor* slotDescriptorAt(uint32_t index) { return &_interfaceSlotDescriptors[index]; }
+		void                       prepareInterfaceTable();
 
-		virtual J3Method* findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1);
-		virtual J3Method* findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1);
+		virtual J3Method*          findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1);
+		virtual J3Method*          findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1);
 
-		bool              isObjectType() { return 1; }
+		bool                       isObjectType() { return 1; }
 
-		J3ObjectHandle*   javaClass();
+		J3ObjectHandle*            javaClass();
 
-		static J3ObjectType* nativeClass(J3ObjectHandle* handle);
+		static J3ObjectType*       nativeClass(J3ObjectHandle* handle);
 
-		void dumpInterfaceSlotDescriptors();
+		void                       dumpInterfaceSlotDescriptors();
 	};
 
 	class J3Layout : public J3ObjectType {

Modified: vmkit/branches/mcjit/include/j3/j3object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=197975&r1=197974&r2=197975&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3object.h (original)
+++ vmkit/branches/mcjit/include/j3/j3object.h Tue Dec 24 05:03:27 2013
@@ -39,6 +39,8 @@ namespace j3 {
 	};
 
 	class J3VirtualTable {
+		friend class J3Trampoline;
+
 	public:
 		static const uint32_t nbInterfaceMethodTable = 23;
 		static const uint32_t gepObjectClass = 0;

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=197975&r1=197974&r2=197975&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Tue Dec 24 05:03:27 2013
@@ -200,7 +200,7 @@ void J3ObjectType::prepareInterfaceTable
 		cur += slots[i].nbMethods;
 	}
 
-	dumpInterfaceSlotDescriptors();
+	//dumpInterfaceSlotDescriptors();
 }
 
 void J3ObjectType::dumpInterfaceSlotDescriptors() {

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=197975&r1=197974&r2=197975&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc Tue Dec 24 05:03:27 2013
@@ -10,11 +10,20 @@ using namespace j3;
 void* J3Trampoline::interfaceTrampoline(J3Object* obj) {
 	J3ObjectHandle* prev = J3Thread::get()->tell();
 	J3ObjectHandle* handle = J3Thread::get()->push(obj);
-	uint32_t index = J3Thread::get()->interfaceMethodIndex();
-	fprintf(stderr, "%d - %ls\n", index, handle->vt()->type()->name()->cStr());
+	J3ObjectType* type = obj->vt()->type()->asObjectType();
+	uint32_t index = J3Thread::get()->interfaceMethodIndex() % J3VirtualTable::nbInterfaceMethodTable;
+	J3InterfaceSlotDescriptor* desc = type->slotDescriptorAt(index);
+	void* res;
+
+	if(desc->nbMethods == 1) {
+		res = desc->methods[0]->fnPtr();
+		handle->vt()->_interfaceMethodTable[index] = res;
+	} else
+		J3::internalError(L"implement me: interface Trampoline with collision");
 
 	J3Thread::get()->restore(prev);
-	J3::internalError(L"implement me: interface Trampoline");
+
+	return res;
 }
 
 void* J3Trampoline::staticTrampoline(J3Object* obj, J3Method* target) {





More information about the vmkit-commits mailing list