[vmkit-commits] [vmkit] r198228 - Create the native names in separated functions in J3ClassArray and J3Class

Gael Thomas gael.thomas at lip6.fr
Mon Dec 30 09:49:22 PST 2013


Author: gthomas
Date: Mon Dec 30 11:49:22 2013
New Revision: 198228

URL: http://llvm.org/viewvc/llvm-project?rev=198228&view=rev
Log:
Create the native names in separated functions in J3ClassArray and J3Class

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

Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=198228&r1=198227&r2=198228&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Mon Dec 30 11:49:22 2013
@@ -250,6 +250,7 @@ namespace j3 {
 		void          fillFields(std::vector<llvm::Type*>* staticBody, std::vector<llvm::Type*>* virtualBody, J3Field** fields, size_t n);
 
 		void          createLLVMTypes();
+		void          doNativeName();
 
 		void          doResolve(J3Field* hiddenFields, size_t nbHiddenFields);
 		void          doInitialise();
@@ -302,6 +303,8 @@ namespace j3 {
 
 		void                doResolve(J3Field* hiddenFields, size_t nbHiddenFields);
 		void                doInitialise();
+
+		void                doNativeName();
 	public:
 		J3ArrayClass(J3ClassLoader* loader, J3Type* component, 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=198228&r1=198227&r2=198228&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Mon Dec 30 11:49:22 2013
@@ -809,6 +809,23 @@ void J3Class::check(uint16_t idx, uint32
 		J3::classFormatError(this, L"wrong constant pool type %d at index %d for %d", id, idx, nbCtp);
 }
 
+void J3Class::doNativeName() {
+	J3Mangler mangler(this);
+
+	mangler.mangle(name());
+		
+	_nativeNameLength = mangler.length() + 3;
+	_nativeName = (char*)loader()->allocator()->allocate(_nativeNameLength + 1);
+
+	_nativeName[0] = 'L';
+	memcpy(_nativeName + 1, mangler.cStr(), mangler.length());
+	_nativeName[_nativeNameLength-2] = '_';
+	_nativeName[_nativeNameLength-1] = '2';
+	_nativeName[_nativeNameLength]   = 0;
+
+	loader()->addSymbol(_nativeName, this);
+}
+
 void J3Class::createLLVMTypes() {
 	J3Mangler mangler(this);
 
@@ -818,15 +835,7 @@ void J3Class::createLLVMTypes() {
 		llvm::PointerType::getUnqual(llvm::StructType::create(loader()->vm()->llvmContext(), mangler.cStr()));
 	_llvmType = llvm::PointerType::getUnqual(llvm::StructType::create(loader()->vm()->llvmContext(), mangler.cStr()+7));
 
-	mangler.mangle("_2");
-		
-	_nativeNameLength = mangler.length() - 6;
-	_nativeName = (char*)loader()->allocator()->allocate(_nativeNameLength + 1);
-
-	_nativeName[0] = 'L';
-	memcpy(_nativeName + 1, mangler.cStr()+7, _nativeNameLength); /* copy the 0 */
-
-	loader()->addSymbol(_nativeName, this);
+	doNativeName();
 }
 
 llvm::Type* J3Class::staticLLVMType() {
@@ -923,26 +932,28 @@ llvm::GlobalValue* J3ArrayClass::llvmDes
 	return llvm::cast<llvm::GlobalValue>(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3ArrayClass));
 }
 
+void J3ArrayClass::doNativeName() {
+	uint32_t len = component()->nativeNameLength();
+	_nativeNameLength = len + 2;
+	_nativeName = (char*)loader()->allocator()->allocate(_nativeNameLength + 1);
+	_nativeName[0] = '_';
+	_nativeName[1] = '3';
+	memcpy(_nativeName+2, component()->nativeName(), len);
+	_nativeName[_nativeNameLength] = 0;
+	loader()->addSymbol(_nativeName, this);
+}
+
 llvm::Type* J3ArrayClass::llvmType() {
 	if(!_llvmType) {
 		llvm::Type* body[2] = {
 			loader()->vm()->typeJ3ArrayObject,
 			llvm::ArrayType::get(component()->llvmType(), 0) /* has to be called first */
 		};
-		uint32_t len = component()->nativeNameLength();
-
-		_nativeNameLength = len + 2;
-		_nativeName = (char*)loader()->allocator()->allocate(_nativeNameLength + 1);
-		_nativeName[0] = '_';
-		_nativeName[1] = '3';
-		memcpy(_nativeName+2, component()->nativeName(), len);
-		_nativeName[_nativeNameLength] = 0;
-
+		
+		doNativeName();
 		_llvmType = llvm::PointerType::getUnqual(llvm::StructType::create(loader()->vm()->llvmContext(), 
 																																			body,
 																																			_nativeName));
-
-		loader()->addSymbol(_nativeName, this);
 	}
 	return _llvmType;
 }

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=198228&r1=198227&r2=198228&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3options.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3options.cc Mon Dec 30 11:49:22 2013
@@ -19,8 +19,8 @@ J3Options::J3Options() {
 	debugLoad = 0;
 	debugResolve = 0;
 	debugIniting = 0;
-	debugTranslate = 1;
-	debugLinking = 1;
+	debugTranslate = 0;
+	debugLinking = 0;
 
 	genDebugExecute = debugExecute ? 1 : 0;
 

Modified: vmkit/branches/mcjit/lib/j3/vm/j3thread.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3thread.cc?rev=198228&r1=198227&r2=198228&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3thread.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3thread.cc Mon Dec 30 11:49:22 2013
@@ -21,7 +21,6 @@ J3Thread::~J3Thread() {
 
 void J3Thread::doRun() {
 	J3ObjectHandle* handle = get()->javaThread();
-	fprintf(stderr, " *** target is %ls\n", handle->vt()->type()->name()->cStr());
 	get()->vm()->threadRun->invokeVirtual(handle);
 }
 
@@ -31,7 +30,6 @@ void J3Thread::run() {
 }
 
 void J3Thread::start(J3ObjectHandle* handle) {
-	fprintf(stderr, " start %ls\n", handle->vt()->type()->name()->cStr());
 	vmkit::BumpAllocator* allocator = vmkit::BumpAllocator::create();
 	J3Thread* thread = new J3Thread(get()->vm());
 	thread->assocJavaThread(handle);





More information about the vmkit-commits mailing list