[vmkit-commits] [vmkit] r198500 - Remove the useless method map from class loaders

Gael Thomas gael.thomas at lip6.fr
Sat Jan 4 07:43:59 PST 2014


Author: gthomas
Date: Sat Jan  4 09:43:59 2014
New Revision: 198500

URL: http://llvm.org/viewvc/llvm-project?rev=198500&view=rev
Log:
Remove the useless method map from class loaders

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

Modified: vmkit/branches/mcjit/include/j3/j3classloader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=198500&r1=198499&r2=198500&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3classloader.h (original)
+++ vmkit/branches/mcjit/include/j3/j3classloader.h Sat Jan  4 09:43:59 2014
@@ -25,21 +25,13 @@ namespace j3 {
 	class J3Class;
 
 	class J3ClassLoader : public vmkit::CompilationUnit {
-		struct J3MethodLess {
-			bool operator()(const J3Method* lhs, const J3Method* rhs) const;
-		};
-
 		struct J3InterfaceMethodLess {
 			bool operator()(const J3Method* lhs, const J3Method* rhs) const;
 		};
 
-		typedef std::map<J3Method*, J3Method*, J3MethodLess,
-										 vmkit::StdAllocator<std::pair<J3Method*, J3Method*> > > MethodRefMap;
-
 		typedef std::map<J3Method*, uint32_t, J3InterfaceMethodLess,
 										 vmkit::StdAllocator<std::pair<J3Method*, J3Method*> > > InterfaceMethodRefMap;
 
-		static J3MethodLess           j3MethodLess;
 		static J3InterfaceMethodLess  j3InterfaceMethodLess;
 
 		J3ObjectHandle*                      _javaClassLoader;
@@ -54,9 +46,6 @@ namespace j3 {
 		pthread_mutex_t                      _mutexInterfaces;
 		InterfaceMethodRefMap                interfaces; 
 
-		pthread_mutex_t                      _mutexMethods;
-		MethodRefMap                         methods;      /* all te known method */
-
 		pthread_mutex_t                      _mutexMethodTypes;
 		vmkit::NameMap<J3Signature*>::map   methodTypes;
 
@@ -79,9 +68,6 @@ namespace j3 {
 
 		J3*                           vm() const { return (J3*)vmkit::CompilationUnit::vm(); };
 
-		J3Method*                     method(uint16_t access, J3ObjectType* cl, 
-																				 const vmkit::Name* name, J3Signature* signature);
-
 		J3Class*                      defineClass(const vmkit::Name* name, J3ClassBytes* bytes);
 		J3Class*                      findLoadedClass(const vmkit::Name* name);
 		virtual J3Class*              loadClass(const vmkit::Name* name);

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=198500&r1=198499&r2=198500&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Sat Jan  4 09:43:59 2014
@@ -580,8 +580,8 @@ void J3Class::readClassBytes(J3Field* hi
 	for(size_t i=0; i<n; i++) {
 		uint16_t           access = reader.readU2();
 		const vmkit::Name* name = nameAt(reader.readU2());
-		const vmkit::Name* signature = nameAt(reader.readU2());
-		J3Method*          method = loader()->method(access, this, name, loader()->getSignature(this, signature));
+		J3Signature*       signature = loader()->getSignature(this, nameAt(reader.readU2()));
+		J3Method*          method = new(loader()->allocator()) J3Method(access, this, name, signature);
 		J3Attributes*      attributes = readAttributes(&reader);
 		
 		method->postInitialise(access, attributes);

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=198500&r1=198499&r2=198500&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc Sat Jan  4 09:43:59 2014
@@ -18,7 +18,6 @@
 
 using namespace j3;
 
-J3ClassLoader::J3MethodLess          J3ClassLoader::j3MethodLess;
 J3ClassLoader::J3InterfaceMethodLess J3ClassLoader::j3InterfaceMethodLess;
 
 J3ClassLoader::J3ClassLoader(J3* v, J3ObjectHandle* javaClassLoader, vmkit::BumpAllocator* allocator) 
@@ -27,7 +26,6 @@ J3ClassLoader::J3ClassLoader(J3* v, J3Ob
 		classes(vmkit::Name::less, allocator),
 		types(vmkit::Name::less, allocator),
 		interfaces(j3InterfaceMethodLess, allocator),
-		methods(j3MethodLess, allocator),
 		methodTypes(vmkit::Name::less, allocator),
 		nativeLibraries(allocator) {
 	_javaClassLoader = javaClassLoader;
@@ -35,7 +33,6 @@ J3ClassLoader::J3ClassLoader(J3* v, J3Ob
 	pthread_mutex_init(&_mutexClasses, 0);
 	pthread_mutex_init(&_mutexTypes, 0);
 	pthread_mutex_init(&_mutexInterfaces, 0);
-	pthread_mutex_init(&_mutexMethods, 0);
 	pthread_mutex_init(&_mutexMethodTypes, 0);
 }
 
@@ -194,44 +191,12 @@ J3Signature* J3ClassLoader::getSignature
 	return res;
 }
 
-J3Method* J3ClassLoader::method(uint16_t access, J3ObjectType* type, const vmkit::Name* name, J3Signature* signature) {
-	if(type->isArrayClass())
-		return method(access, vm()->objectClass, name, signature);
-	else {
-		J3Class* cl = type->asClass();
-		J3Method method(access, cl, name, signature), *res;
-
-		pthread_mutex_lock(&_mutexMethods);
-		std::map<J3Method*, J3Method*>::iterator it = methods.find(&method);
-
-		if(it == methods.end()) {
-			res = new(allocator()) J3Method(access, cl, name, signature);
-			methods[res] = res;
-		} else {
-			res = it->second;
-		}
-		pthread_mutex_unlock(&_mutexMethods);
-
-		return res;
-	}
-}
-
 bool J3ClassLoader::J3InterfaceMethodLess::operator()(j3::J3Method const* lhs, j3::J3Method const* rhs) const {
 	return lhs->name() < rhs->name()
 		|| (lhs->name() == rhs->name()
 				&& (lhs->signature() < rhs->signature()));
 }
 
-bool J3ClassLoader::J3MethodLess::operator()(j3::J3Method const* lhs, j3::J3Method const* rhs) const {
-	return lhs->name() < rhs->name()
-		|| (lhs->name() == rhs->name()
-				&& (lhs->signature() < rhs->signature()
-						|| (lhs->signature() == rhs->signature()
-								&& (lhs->cl() < rhs->cl()
-										|| (lhs->cl() == rhs->cl()
-												&& ((lhs->access() & J3Cst::ACC_STATIC) < (rhs->access() & J3Cst::ACC_STATIC)))))));
-}
-
 J3InitialClassLoader::J3InitialClassLoader(J3* v, const char* rtjar, vmkit::BumpAllocator* _alloc) 
 	: J3ClassLoader(v, 0, _alloc) {
 	const char* archives = vm()->options()->rtJar;





More information about the vmkit-commits mailing list