[vmkit-commits] [vmkit] r198318 - Remove useless hashing of method type and the associated methods.

Gael Thomas gael.thomas at lip6.fr
Thu Jan 2 09:06:05 PST 2014


Author: gthomas
Date: Thu Jan  2 11:06:05 2014
New Revision: 198318

URL: http://llvm.org/viewvc/llvm-project?rev=198318&view=rev
Log:
Remove useless hashing of method type and the associated methods.

Modified:
    vmkit/branches/mcjit/include/j3/j3classloader.h
    vmkit/branches/mcjit/include/j3/j3constants.h
    vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc
    vmkit/branches/mcjit/lib/j3/vm/j3constants.cc
    vmkit/branches/mcjit/lib/j3/vm/j3method.cc
    vmkit/branches/mcjit/lib/j3/vm/j3options.cc

Modified: vmkit/branches/mcjit/include/j3/j3classloader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=198318&r1=198317&r2=198318&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3classloader.h (original)
+++ vmkit/branches/mcjit/include/j3/j3classloader.h Thu Jan  2 11:06:05 2014
@@ -51,24 +51,21 @@ namespace j3 {
 		pthread_mutex_t                      _mutexTypes;
 		vmkit::NameMap<J3Type*>::map         types;        /* shortcut to find types */
 
-		pthread_mutex_t                      _mutexMethodTypes;
-		vmkit::NameMap<J3MethodType*>::map   methodTypes;  /* shortcut to find method types - REMOVE */
-
 		pthread_mutex_t                      _mutexInterfaces;
 		InterfaceMethodRefMap                interfaces; 
 
 		pthread_mutex_t                      _mutexMethods;
 		MethodRefMap                         methods;      /* all te known method */
 
-		void                          wrongType(J3ObjectType* from, const vmkit::Name* type);
-		J3Type*                       getTypeInternal(J3ObjectType* from, const vmkit::Name* type, uint32_t start, uint32_t* end);
-
 	protected:
 		std::vector<void*, vmkit::StdAllocator<void*> > nativeLibraries;
 
 	public:
 		J3ClassLoader(J3* vm, J3ObjectHandle* javaClassLoader, vmkit::BumpAllocator* allocator);
 
+		J3Type*                       getTypeInternal(J3ObjectType* from, const vmkit::Name* type, uint32_t start, uint32_t* end);
+		void                          wrongType(J3ObjectType* from, const vmkit::Name* type);
+
 		uint32_t                      interfaceIndex(J3Method* sign);
 
 		J3GlobalReferences*           globalReferences() { return &_globalReferences; }

Modified: vmkit/branches/mcjit/include/j3/j3constants.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3constants.h?rev=198318&r1=198317&r2=198318&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3constants.h (original)
+++ vmkit/branches/mcjit/include/j3/j3constants.h Thu Jan  2 11:06:05 2014
@@ -107,8 +107,6 @@ namespace j3 {
 			return ((value - 1) & (-bound)) + bound;
 		}
 
-		static const vmkit::Name* rewrite(J3ObjectType* cl, const vmkit::Name* orig);
-
 #define defOpcode(ID, val, effect)											\
 		static const uint8_t BC_##ID = val;
 #include "j3bc.def"

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=198318&r1=198317&r2=198318&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc Thu Jan  2 11:06:05 2014
@@ -26,7 +26,6 @@ J3ClassLoader::J3ClassLoader(J3* v, J3Ob
 		_globalReferences(allocator),
 		classes(vmkit::Name::less, allocator),
 		types(vmkit::Name::less, allocator),
-		methodTypes(vmkit::Name::less, allocator), 
 		interfaces(j3InterfaceMethodLess, allocator),
 		methods(j3MethodLess, allocator),
 		nativeLibraries(allocator) {
@@ -34,7 +33,6 @@ J3ClassLoader::J3ClassLoader(J3* v, J3Ob
 
 	pthread_mutex_init(&_mutexClasses, 0);
 	pthread_mutex_init(&_mutexTypes, 0);
-	pthread_mutex_init(&_mutexMethodTypes, 0);
 	pthread_mutex_init(&_mutexInterfaces, 0);
 	pthread_mutex_init(&_mutexMethods, 0);
 }
@@ -166,38 +164,6 @@ J3Type* J3ClassLoader::getType(J3Class*
 	}
 
 	return res;
-}
-
-J3MethodType* J3ClassLoader::getMethodType(J3ObjectType* from, const vmkit::Name* sign) {
-	pthread_mutex_lock(&_mutexMethodTypes);
-	J3MethodType* res = methodTypes[sign];
-	pthread_mutex_unlock(&_mutexMethodTypes);
-
-	if(!res) {
-		J3Type*  args[sign->length()];
-		uint32_t nbArgs = 0;
-		uint32_t cur = 1;
-
-		if(sign->cStr()[0] != J3Cst::ID_Left)
-			wrongType(from, sign);
-
-		while(sign->cStr()[cur] != J3Cst::ID_Right) {
-			args[nbArgs++] = getTypeInternal(from, sign, cur, &cur);
-		}
-		args[nbArgs++] = getTypeInternal(from, sign, cur+1, &cur);
-		if(cur != sign->length())
-			wrongType(from, sign);
-
-		pthread_mutex_lock(&_mutexMethodTypes);
-		J3MethodType* tmp = methodTypes[sign];
-		if(tmp)
-			res = tmp;
-		else
-			res = new(allocator(), nbArgs - 1) J3MethodType(args, nbArgs);
-		pthread_mutex_unlock(&_mutexMethodTypes);
-	}
-
-	return res;
 }
 
 J3Method* J3ClassLoader::method(uint16_t access, J3ObjectType* cl, const vmkit::Name* name, const vmkit::Name* sign) {

Modified: vmkit/branches/mcjit/lib/j3/vm/j3constants.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3constants.cc?rev=198318&r1=198317&r2=198318&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3constants.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3constants.cc Thu Jan  2 11:06:05 2014
@@ -10,28 +10,6 @@ using namespace j3;
 
 char    J3Cst::nativePrefix[] = "Java_";
 
-const vmkit::Name* J3Cst::rewrite(J3ObjectType* cl, const vmkit::Name* orig) {
-	const vmkit::Name* clName = cl->name();
-	char res[clName->length() + orig->length() + 3];
-	uint32_t d;
-
-	res[0] = ID_Left;
-	if(cl->isClass()) {
-		res[1] = ID_Classname;
-		memcpy(res+2, clName->cStr(), sizeof(char)*clName->length());
-		res[2 + clName->length()] = ID_End;
-		d = 2;
-	} else {
-		memcpy(res+1, clName->cStr(), sizeof(char)*clName->length());
-		d = 0;
-	}
-
-	memcpy(res+1+d+clName->length(), orig->cStr()+1, sizeof(char)*(orig->length()-1));
-	res[d + clName->length() + orig->length()] = 0;
-
-	return cl->loader()->vm()->names()->get(res);
-}
-
 #define defOpcode(ID, val, effect)											\
 	#ID,
 const char* J3Cst::opcodeNames[] = {

Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=198318&r1=198317&r2=198318&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Thu Jan  2 11:06:05 2014
@@ -227,13 +227,26 @@ J3Value J3Method::invokeVirtual(J3Object
 
 J3MethodType* J3Method::methodType(J3ObjectType* from) {
 	if(!_methodType) {
-		const vmkit::Name* realSign = sign();
+		const vmkit::Name* sign = J3Method::sign();
 		J3ClassLoader*     loader = cl()->loader();
+		J3Type*            args[1+sign->length()];
+		uint32_t           nbArgs = 0;
+		uint32_t           cur = 1;
+
+		if(sign->cStr()[0] != J3Cst::ID_Left)
+			loader->wrongType(from, sign);
 
 		if(!J3Cst::isStatic(access()))
-			realSign = J3Cst::rewrite(cl(), sign());
+			args[nbArgs++] = cl();
 
-		_methodType = loader->getMethodType(from ? from : cl(), realSign);
+		while(sign->cStr()[cur] != J3Cst::ID_Right) {
+			args[nbArgs++] = loader->getTypeInternal(from, sign, cur, &cur);
+		}
+		args[nbArgs++] = loader->getTypeInternal(from, sign, cur+1, &cur);
+		if(cur != sign->length())
+			loader->wrongType(from, sign);
+		
+		_methodType = new(loader->allocator(), nbArgs - 1) J3MethodType(args, nbArgs);
 	}
 
 	return _methodType;

Modified: vmkit/branches/mcjit/lib/j3/vm/j3options.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3options.cc?rev=198318&r1=198317&r2=198318&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3options.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3options.cc Thu Jan  2 11:06:05 2014
@@ -15,11 +15,11 @@ J3Options::J3Options() {
 
 	debugEnterIndent = 1;
 
-	debugExecute = 2;
+	debugExecute = 1;
 	debugLoad = 0;
 	debugResolve = 0;
 	debugIniting = 0;
-	debugTranslate = 2;
+	debugTranslate = 0;
 	debugLinking = 0;
 
 	genDebugExecute = debugExecute ? 1 : 0;





More information about the vmkit-commits mailing list