[vmkit-commits] [vmkit] r199607 - Continue the aot.

Gael Thomas gael.thomas at lip6.fr
Sun Jan 19 10:07:50 PST 2014


Author: gthomas
Date: Sun Jan 19 12:07:49 2014
New Revision: 199607

URL: http://llvm.org/viewvc/llvm-project?rev=199607&view=rev
Log:
Continue the aot.

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

Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Sun Jan 19 12:07:49 2014
@@ -224,6 +224,8 @@ namespace j3 {
 	public:
 		J3Class(J3ClassLoader* loader, const vmkit::Name* name, J3ClassBytes* bytes, J3ObjectHandle* protectionDomain, const char* source);
 
+		void                aotCompile();
+
 		J3ObjectHandle*     clone(J3ObjectHandle* obj);
 
 		size_t              nbConstructors() { return _nbConstructors; }

Modified: vmkit/branches/mcjit/include/j3/j3codegen.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegen.h?rev=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3codegen.h (original)
+++ vmkit/branches/mcjit/include/j3/j3codegen.h Sun Jan 19 12:07:49 2014
@@ -185,13 +185,13 @@ namespace j3 {
 		llvm::Function*    patchPoint64;
 		llvm::Function*    patchPointVoid;
 
-		J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* method, bool withMethod, bool withCaller);
+		J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* method, bool withMethod, bool withCaller, bool onlyTranslate);
 		~J3CodeGen();
 
 		void* operator new(size_t n, vmkit::BumpAllocator* _allocator);
 		void  operator delete(void* ptr);
 	public:
-		static void translate(J3Method* method, bool withMethod=1, bool withCaller=1);
+		static void translate(J3Method* method, bool withMethod=1, bool withCaller=1, bool onlyTranslate=0);
 	};
 }
 

Modified: vmkit/branches/mcjit/include/j3/j3method.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3method.h (original)
+++ vmkit/branches/mcjit/include/j3/j3method.h Sun Jan 19 12:07:49 2014
@@ -105,7 +105,8 @@ namespace j3 {
 		J3Value             invokeVirtual(J3ObjectHandle* obj, J3Value* args);
 		J3Value             invokeVirtual(J3ObjectHandle* obj, va_list va);
 
-		void                ensureCompiled(bool withCaller);
+		void                aotCompile();
+		void                ensureCompiled(bool withCaller, bool onlyTranslate=0);
 		J3Signature::function_t cxxCaller();
 		void*               fnPtr();
 		void*               functionPointerOrStaticTrampoline();

Modified: vmkit/branches/mcjit/lib/j3/vm/j3.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3.cc?rev=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Sun Jan 19 12:07:49 2014
@@ -210,6 +210,8 @@ void J3::compileApplication() {
 				J3Class* c = loader->getTypeFromQualified(0, buf)->asClass();
 
 				fprintf(stderr, " find: %s\n", c->name()->cStr());
+
+				c->aotCompile();
 			}
 		}
 	}

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=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Sun Jan 19 12:07:49 2014
@@ -321,6 +321,18 @@ J3Class::J3Class(J3ClassLoader* loader,
 	status = LOADED;
 }
 
+void J3Class::aotCompile() {
+	resolve();
+
+	for(uint32_t i=0; i<nbMethods(); i++) {
+		methods()[i]->aotCompile();
+	}
+
+	for(uint32_t i=0; i<staticLayout()->nbMethods(); i++) {
+		staticLayout()->methods()[i]->aotCompile();
+	}
+}
+
 uint16_t J3Class::modifiers() {
 	return access();
 #if 0

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=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Sun Jan 19 12:07:49 2014
@@ -28,7 +28,7 @@ using namespace j3;
 
 #define _onEndPoint() ({ if(onEndPoint()) return; })
 
-J3CodeGen::J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* m, bool withMethod, bool withCaller) :
+J3CodeGen::J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* m, bool withMethod, bool withCaller, bool onlyTranslate) :
 	exceptions(this) {
 	
 	allocator = _allocator;
@@ -117,13 +117,14 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
 	if(needsCaller)
 		signature->generateCallerIR(access, this, module, "generic-caller");
 
-	loader->compileModule(module);
+	if(!onlyTranslate)
+		loader->compileModule(module);
 	
 	if(needsCaller)
 		signature->setCaller(access, (J3Signature::function_t)loader->ee()->getFunctionAddress("generic-caller"));
 
 	if(withMethod) {
-		void* fnPtr = (void*)loader->ee()->getFunctionAddress(llvmFunction->getName().data());
+		void* fnPtr = onlyTranslate ? 0 : (void*)loader->ee()->getFunctionAddress(llvmFunction->getName().data());
 		method->markCompiled(llvmFunction, fnPtr);
 	}
 }
@@ -138,11 +139,11 @@ void* J3CodeGen::operator new(size_t n,
 void J3CodeGen::operator delete(void* ptr) {
 }
 
-void J3CodeGen::translate(J3Method* method, bool withMethod, bool withCaller) {
+void J3CodeGen::translate(J3Method* method, bool withMethod, bool withCaller, bool onlyTranslate) {
 	J3Thread::get()->vm()->lockCompiler();
 	
 	vmkit::BumpAllocator* allocator = vmkit::BumpAllocator::create();
-	delete new(allocator) J3CodeGen(allocator, method, withMethod, withCaller);
+	delete new(allocator) J3CodeGen(allocator, method, withMethod, withCaller, onlyTranslate);
 	vmkit::BumpAllocator::destroy(allocator);
 
 	J3Thread::get()->vm()->unlockCompiler();
@@ -452,7 +453,6 @@ void J3CodeGen::invokeVirtual(uint32_t i
 
 void J3CodeGen::invokeStatic(uint32_t idx) {
 	J3Method* target = cl->methodAt(idx, J3Cst::ACC_STATIC);
-	initialiseJ3ObjectType(target->cl());
 	invoke(J3Cst::ACC_STATIC, target, buildFunction(target));
 }
 

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=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Sun Jan 19 12:07:49 2014
@@ -52,11 +52,15 @@ J3Signature::function_t J3Method::cxxCal
 	return signature()->caller(access());
 }
 
-void J3Method::ensureCompiled(bool withCaller) {
+void J3Method::aotCompile() {
+	fprintf(stderr, "compiling: %s::%s%s\n", cl()->name()->cStr(), name()->cStr(), signature()->name()->cStr());
+	ensureCompiled(0, 1);
+}
+
+void J3Method::ensureCompiled(bool withCaller, bool onlyTranslate) {
 	if(!fnPtr() || (withCaller && !cxxCaller())) {
 		// fprintf(stderr, "materializing: %s::%s%s\n", this, cl()->name()->cStr(), name()->cStr(), signature()->cStr());
-		cl()->initialise();
-		J3CodeGen::translate(this, !fnPtr(), withCaller);
+		J3CodeGen::translate(this, !fnPtr(), withCaller, onlyTranslate);
  	}
 }
 
@@ -104,6 +108,7 @@ J3Method* J3Method::resolve(J3ObjectHand
 }
 
 J3Value J3Method::internalInvoke(J3ObjectHandle* handle, J3Value* inArgs) {
+	cl()->initialise();
 	ensureCompiled(1);  /* force the generation of the code and thus of the functionType */
 
 	J3Value* reIn;
@@ -127,6 +132,7 @@ J3Value J3Method::internalInvoke(J3Objec
 }
 
 J3Value J3Method::internalInvoke(J3ObjectHandle* handle, va_list va) {
+	cl()->initialise();
 	ensureCompiled(1);  /* force the generation of the code and thus of the functionType */
 
 	llvm::FunctionType* fType = signature()->functionType(J3Cst::ACC_STATIC);      /* static signature for va */

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=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc Sun Jan 19 12:07:49 2014
@@ -39,6 +39,7 @@ void J3Trampoline::interfaceTrampoline(J
 void J3Trampoline::staticTrampoline(J3Object* obj, J3Method* target) {
 	J3TrampolineArg arg = J3Thread::get()->_trampolineArg;
 
+	target->cl()->initialise();
 	target->ensureCompiled(0);
 
 	trampoline_restart(target->fnPtr(), &arg);

Modified: vmkit/branches/mcjit/lib/vmkit/vmkit.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/vmkit.cc?rev=199607&r1=199606&r2=199607&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/vmkit.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/vmkit.cc Sun Jan 19 12:07:49 2014
@@ -37,7 +37,12 @@ VMKit::VMKit(vmkit::BumpAllocator* alloc
 	llvm::llvm_start_multithreaded();
 	_allocator = allocator;
 	pthread_mutex_init(&safepointMapLock, 0);
+
+	//pthread_mutexattr_t attr;
+	//pthread_mutexattr_init(&attr);
+	//pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 	pthread_mutex_init(&_compilerLock, 0);
+	//pthread_mutexattr_destroy(&attr);
 }
 
 void* VMKit::operator new(size_t n, vmkit::BumpAllocator* allocator) {





More information about the vmkit-commits mailing list