[vmkit-commits] [vmkit] r198303 - Use char* to represent utf8

Gael Thomas gael.thomas at lip6.fr
Thu Jan 2 05:32:17 PST 2014


Author: gthomas
Date: Thu Jan  2 07:32:16 2014
New Revision: 198303

URL: http://llvm.org/viewvc/llvm-project?rev=198303&view=rev
Log:
Use char* to represent utf8

Added:
    vmkit/branches/mcjit/include/j3/j3utf16.h
Modified:
    vmkit/branches/mcjit/include/j3/j3.h
    vmkit/branches/mcjit/include/j3/j3classloader.h
    vmkit/branches/mcjit/include/j3/j3constants.h
    vmkit/branches/mcjit/include/vmkit/names.h
    vmkit/branches/mcjit/include/vmkit/util.h
    vmkit/branches/mcjit/include/vmkit/vmkit.h
    vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc
    vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
    vmkit/branches/mcjit/lib/j3/vm/j3.cc
    vmkit/branches/mcjit/lib/j3/vm/j3attribute.cc
    vmkit/branches/mcjit/lib/j3/vm/j3class.cc
    vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc
    vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
    vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc
    vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc
    vmkit/branches/mcjit/lib/j3/vm/j3constants.cc
    vmkit/branches/mcjit/lib/j3/vm/j3field.cc
    vmkit/branches/mcjit/lib/j3/vm/j3jni.cc
    vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc
    vmkit/branches/mcjit/lib/j3/vm/j3method.cc
    vmkit/branches/mcjit/lib/j3/vm/j3object.cc
    vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc
    vmkit/branches/mcjit/lib/vmkit/allocator.cc
    vmkit/branches/mcjit/lib/vmkit/compiler.cc
    vmkit/branches/mcjit/lib/vmkit/names.cc
    vmkit/branches/mcjit/lib/vmkit/util.cc
    vmkit/branches/mcjit/lib/vmkit/vmkit.cc

Modified: vmkit/branches/mcjit/include/j3/j3.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3.h?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3.h (original)
+++ vmkit/branches/mcjit/include/j3/j3.h Thu Jan  2 07:32:16 2014
@@ -119,16 +119,16 @@ namespace j3 {
 		void                       run();
 		void                       start(int argc, char** argv);
 
-		void                       vinternalError(const wchar_t* msg, va_list va) __attribute__((noreturn));
+		void                       vinternalError(const char* msg, va_list va) __attribute__((noreturn));
 
 		static JNIEnv* jniEnv();
 
 		static void    classNotFoundException(const vmkit::Name* name) __attribute__((noreturn));
 		static void    noClassDefFoundError(const vmkit::Name* name) __attribute__((noreturn));
-		static void    classFormatError(J3Class* cl, const wchar_t* reason, ...) __attribute__((noreturn));
-		static void    noSuchMethodError(const wchar_t* msg, 
+		static void    classFormatError(J3Class* cl, const char* reason, ...) __attribute__((noreturn));
+		static void    noSuchMethodError(const char* msg, 
 																		 J3Class* clName, const vmkit::Name* name, const vmkit::Name* sign) __attribute__((noreturn));
-		static void    noSuchFieldError(const wchar_t* msg, 
+		static void    noSuchFieldError(const char* msg, 
 																		J3Class* clName, const vmkit::Name* name, J3Type* type) __attribute__((noreturn));
 		static void    linkageError(J3Method* method) __attribute__((noreturn));
 

Modified: vmkit/branches/mcjit/include/j3/j3classloader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3classloader.h (original)
+++ vmkit/branches/mcjit/include/j3/j3classloader.h Thu Jan  2 07:32:16 2014
@@ -24,11 +24,11 @@ namespace j3 {
 	class J3Class;
 
 	class J3ClassLoader : public vmkit::CompilationUnit {
-		struct J3MethodLess : public std::binary_function<wchar_t*,wchar_t*,bool> {
+		struct J3MethodLess {
 			bool operator()(const J3Method* lhs, const J3Method* rhs) const;
 		};
 
-		struct J3InterfaceMethodLess : public std::binary_function<wchar_t*,wchar_t*,bool> {
+		struct J3InterfaceMethodLess {
 			bool operator()(const J3Method* lhs, const J3Method* rhs) const;
 		};
 
@@ -80,13 +80,10 @@ namespace j3 {
 																				 const vmkit::Name* name, const vmkit::Name* sign);
 		J3Method*                     method(uint16_t access, const vmkit::Name* clName, 
 																				 const vmkit::Name* name, const vmkit::Name* sign); 
-		J3Method*                     method(uint16_t access, J3Class* cl, const wchar_t* name, const wchar_t* sign); 
-		J3Method*                     method(uint16_t access, const wchar_t* clName, const wchar_t* name, const wchar_t* sign); 
 
 		J3Class*                      defineClass(const vmkit::Name* name, J3ClassBytes* bytes);
 		J3Class*                      findLoadedClass(const vmkit::Name* name);
 		virtual J3Class*              loadClass(const vmkit::Name* name);
-		J3Class*                      loadClass(const wchar_t* name);
 
 		J3Type*                       getType(J3Class* from, const vmkit::Name* type);       /* find a type */
 		J3MethodType*                 getMethodType(J3Class* from, const vmkit::Name* sign); /* get a method type */

Modified: vmkit/branches/mcjit/include/j3/j3constants.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3constants.h?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3constants.h (original)
+++ vmkit/branches/mcjit/include/j3/j3constants.h Thu Jan  2 07:32:16 2014
@@ -24,21 +24,21 @@ namespace j3 {
 		static const int MAGIC = 0xcafebabe;
 
 #define onJavaConstantNames(_)																					\
-		_(clinitName,                 L"<clinit>")													\
-		_(clinitSign,                 L"()V")																\
-		_(initName,                   L"<init>")														\
+		_(clinitName,                 "<clinit>")														\
+		_(clinitSign,                 "()V")																\
+		_(initName,                   "<init>")															\
 																																				\
-		_(codeAttribute,              L"Code")															\
-		_(constantValueAttribute,     L"ConstantValue")											\
-		_(annotationsAttribute,       L"RuntimeVisibleAnnotations")					\
-		_(exceptionsAttribute,        L"Exceptions")												\
-		_(lineNumberTableAttribute,   L"LineNumberTable")										\
-		_(innerClassesAttribute,      L"InnerClasses")											\
-		_(sourceFileAttribute,        L"SourceFile")												\
-		_(signatureAttribute,         L"Signature")													\
-		_(enclosingMethodAttribute,   L"EnclosingMethod")										\
-		_(paramAnnotationsAttribute,  L"RuntimeVisibleParameterAnnotations") \
-		_(annotationDefaultAttribute, L"AnnotationDefault")
+		_(codeAttribute,              "Code")																\
+		_(constantValueAttribute,     "ConstantValue")											\
+		_(annotationsAttribute,       "RuntimeVisibleAnnotations")					\
+		_(exceptionsAttribute,        "Exceptions")													\
+		_(lineNumberTableAttribute,   "LineNumberTable")										\
+		_(innerClassesAttribute,      "InnerClasses")												\
+		_(sourceFileAttribute,        "SourceFile")													\
+		_(signatureAttribute,         "Signature")													\
+		_(enclosingMethodAttribute,   "EnclosingMethod")										\
+		_(paramAnnotationsAttribute,  "RuntimeVisibleParameterAnnotations") \
+		_(annotationDefaultAttribute, "AnnotationDefault")
 
 		static char    nativePrefix[];
 
@@ -79,20 +79,20 @@ namespace j3 {
 
 #undef DO_IS
 
-		static const wchar_t ID_Void =      'V';
-		static const wchar_t ID_Byte =      'B';
-		static const wchar_t ID_Char =      'C';
-		static const wchar_t ID_Double =    'D';
-		static const wchar_t ID_Float =     'F';
-		static const wchar_t ID_Integer =   'I';
-		static const wchar_t ID_Long =      'J';
-		static const wchar_t ID_Classname = 'L';
-		static const wchar_t ID_End =       ';';
-		static const wchar_t ID_Short =     'S';
-		static const wchar_t ID_Boolean =   'Z';
-		static const wchar_t ID_Array =     '[';
-		static const wchar_t ID_Left =      '(';
-		static const wchar_t ID_Right =     ')';
+		static const char ID_Void =        'V';
+		static const char ID_Byte =        'B';
+		static const char ID_Char =        'C';
+		static const char ID_Double =      'D';
+		static const char ID_Float =       'F';
+		static const char ID_Integer =     'I';
+		static const char ID_Long =        'J';
+		static const char ID_Classname =   'L';
+		static const char ID_End =         ';';
+		static const char ID_Short =       'S';
+		static const char ID_Boolean =     'Z';
+		static const char ID_Array =       '[';
+		static const char ID_Left =        '(';
+		static const char ID_Right =       ')';
 
 		static const uint8_t T_BOOLEAN =    4;
 		static const uint8_t T_CHAR =       5;

Added: vmkit/branches/mcjit/include/j3/j3utf16.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3utf16.h?rev=198303&view=auto
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3utf16.h (added)
+++ vmkit/branches/mcjit/include/j3/j3utf16.h Thu Jan  2 07:32:16 2014
@@ -0,0 +1,37 @@
+#ifndef _J3_UTF16_H_
+#define _J3_UTF16_H_
+
+namespace j3 {
+	class J3Utf16Converter {
+		const vmkit::Name* name;
+		size_t             pos;
+	public:
+		J3Utf16Converter(const vmkit::Name* _name) { name = _name; pos = 0; }
+
+		bool isEof() { return pos == name->length(); }
+
+		uint16_t nextUtf16() {
+			const char* str = name->cStr();
+			size_t   n = 0;
+			size_t   i = 0;
+			uint16_t x = str[pos++];
+
+			if(x & 0x80) {
+				uint16_t y = str[pos++];
+				if (x & 0x20) {
+					char z = str[pos++];
+					x = ((x & 0x0F) << 12) +
+						((y & 0x3F) << 6) +
+						(z & 0x3F);
+				} else {
+					x = ((x & 0x1F) << 6) +
+						(y & 0x3F);
+				}
+			}
+		
+			return x;
+		}
+	};
+}
+
+#endif

Modified: vmkit/branches/mcjit/include/vmkit/names.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/names.h?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/vmkit/names.h (original)
+++ vmkit/branches/mcjit/include/vmkit/names.h Thu Jan  2 07:32:16 2014
@@ -8,19 +8,19 @@
 
 namespace vmkit {
 	class Name : public PermanentObject {
-		uint32_t                      _length;
-		wchar_t                       _content[1];
+		size_t  _length;
+		char    _content[1];
 
 	public:
 		void* operator new(size_t unused, BumpAllocator* allocator, size_t length);
 
-		Name(uint32_t length, const wchar_t* content);
+		Name(size_t length, const char* content);
 
-		const wchar_t* cStr() const {
+		const char* cStr() const {
 			return _content;
 		}
 
-		uint32_t length() const {
+		size_t length() const {
 			return _length;
 		}
 
@@ -31,14 +31,15 @@ namespace vmkit {
 		BumpAllocator*  allocator;
 		pthread_mutex_t mutex;
 
-		std::map<const wchar_t*, const Name*, Util::wchar_t_less_t, 
-						 StdAllocator<std::pair<const wchar_t*, const Name*> > > names;
+		std::map<const char*, const Name*, Util::char_less_t, 
+						 StdAllocator<std::pair<const char*, const Name*> > > names;
 
+		const Name*   get(const char* s, size_t length);
 	public:
 		Names(BumpAllocator* allocator);
 
-		const Name*   get(const wchar_t* s);
-		const Name*   get(const char* s, size_t start=0, size_t length=-1);
+		const Name*   get(const char* s);
+		const Name*   get(const char* s, size_t start, size_t length);
 		const Name*   get(char c);
 
 	};

Modified: vmkit/branches/mcjit/include/vmkit/util.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/util.h?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/vmkit/util.h (original)
+++ vmkit/branches/mcjit/include/vmkit/util.h Thu Jan  2 07:32:16 2014
@@ -12,13 +12,8 @@ namespace vmkit {
 			bool operator()(const char* s1, const char* s2) const;
 		};
 
-		struct wchar_t_less_t {
-			bool operator()(const wchar_t* lhs, const wchar_t* rhs) const;
-		};
-
 		static struct char_less_t     char_less;
 		static struct char_less_t_dbg char_less_dbg;
-		static struct wchar_t_less_t  wchar_t_less;
 	};
 };
 

Modified: vmkit/branches/mcjit/include/vmkit/vmkit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/vmkit.h?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/vmkit/vmkit.h (original)
+++ vmkit/branches/mcjit/include/vmkit/vmkit.h Thu Jan  2 07:32:16 2014
@@ -33,7 +33,7 @@ namespace vmkit {
 
 		void                            addSymbol(llvm::GlobalValue* gv);
 
-		static void                     defaultInternalError(const wchar_t* msg, va_list va) __attribute__((noreturn));
+		static void                     defaultInternalError(const char* msg, va_list va) __attribute__((noreturn));
 	protected:
 		void* operator new(size_t n, BumpAllocator* allocator);
 
@@ -62,13 +62,13 @@ namespace vmkit {
 		llvm::GlobalValue*         introspectGlobalValue(llvm::Module* dest, const char* name);
 		llvm::Type*                introspectType(const char* name);
 
-		void log(const wchar_t* msg, ...);
+		void log(const char* msg, ...);
 
-		virtual void vinternalError(const wchar_t* msg, va_list va) __attribute__((noreturn));
+		virtual void vinternalError(const char* msg, va_list va) __attribute__((noreturn));
 		virtual void sigsegv(uintptr_t addr) __attribute__((noreturn));
 		virtual void sigend() __attribute__((noreturn));
 
-		static void internalError(const wchar_t* msg, ...) __attribute__((noreturn));		
+		static void internalError(const char* msg, ...) __attribute__((noreturn));		
 		static void throwException(void* obj) __attribute__((noreturn));
 	};
 };

Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc Thu Jan  2 07:32:16 2014
@@ -23,11 +23,11 @@ static const char* rtjar = OPENJDK_HOME"
 
 void J3Lib::bootstrap(J3* vm) {
 	J3ObjectHandle* prev = J3Thread::get()->tell();
-	J3Class* threadGroupClass = vm->initialClassLoader->loadClass(vm->names()->get(L"java/lang/ThreadGroup"));
+	J3Class* threadGroupClass = vm->initialClassLoader->loadClass(vm->names()->get("java/lang/ThreadGroup"));
 	J3Method*       sysThreadGroupInit = vm->initialClassLoader->method(0, 
 																																			threadGroupClass, 
 																																			vm->initName, 
-																																			vm->names()->get(L"()V"));
+																																			vm->names()->get("()V"));
 	J3ObjectHandle* sysThreadGroup = J3ObjectHandle::doNewObject(sysThreadGroupInit->cl());
 	sysThreadGroupInit->invokeSpecial(sysThreadGroup);
 
@@ -35,22 +35,25 @@ void J3Lib::bootstrap(J3* vm) {
 	J3Method*       appThreadGroupInit = vm->initialClassLoader->method(0, 
 																																			threadGroupClass,
 																																			vm->initName, 
-																																			vm->names()->get(L"(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"));
+																																			vm->names()->get("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"));
 	J3ObjectHandle* appThreadGroup = J3ObjectHandle::doNewObject(appThreadGroupInit->cl());
 	appThreadGroupInit->invokeSpecial(appThreadGroup, sysThreadGroup, vm->utfToString("main"));
 
 	J3Method*       threadInit = vm->initialClassLoader->method(0,
 																															vm->threadClass,
 																															vm->initName,
-																															vm->names()->get(L"(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"));
+																															vm->names()->get("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"));
 	J3ObjectHandle* mainThread = J3ObjectHandle::doNewObject(threadInit->cl());
 
 	J3Thread::get()->assocJavaThread(mainThread);
-	mainThread->setInteger(threadInit->cl()->findVirtualField(vm->names()->get(L"priority"), vm->typeInteger), 5);
+	mainThread->setInteger(threadInit->cl()->findVirtualField(vm->names()->get("priority"), vm->typeInteger), 5);
 
 	threadInit->invokeSpecial(mainThread, appThreadGroup, vm->utfToString("main"));
 						
-	vm->initialClassLoader->method(J3Cst::ACC_STATIC, L"java/lang/System", L"initializeSystemClass", L"()V")->invokeStatic();
+	vm->initialClassLoader->method(J3Cst::ACC_STATIC, 
+																 vm->names()->get("java/lang/System"), 
+																 vm->names()->get("initializeSystemClass"), 
+																 vm->names()->get("()V"))->invokeStatic();
 
 	J3Thread::get()->restore(prev);
 }

Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Thu Jan  2 07:32:16 2014
@@ -13,7 +13,7 @@ using namespace j3;
 #define enterJVM()
 #define leaveJVM()
 
-#define NYI() { J3Thread::get()->vm()->internalError(L"not yet implemented: '%s'", __PRETTY_FUNCTION__); }
+#define NYI() { J3Thread::get()->vm()->internalError("not yet implemented: '%s'", __PRETTY_FUNCTION__); }
 
 
 /*************************************************************************
@@ -56,7 +56,7 @@ jstring JNICALL JVM_InternString(JNIEnv*
 
 	J3ObjectHandle* value = str->getObject(vm->stringClassValue);
 	uint32_t length = value->arrayLength();
-	wchar_t copy[length+1];
+	char copy[length+1];
 
 	for(uint32_t i=0; i<length; i++)
 		copy[i] = value->getCharAt(i);
@@ -268,7 +268,7 @@ jclass JNICALL JVM_GetCallerClass(JNIEnv
 	enterJVM(); 
 
 	if(depth != -1)
-		J3::internalError(L"depth should be -1 while it is %d", depth);
+		J3::internalError("depth should be -1 while it is %d", depth);
 
 	depth = 3;
 	J3Method* caller = 0;
@@ -286,7 +286,7 @@ jclass JNICALL JVM_GetCallerClass(JNIEnv
 	}
 
 	if(!caller)
-		J3::internalError(L"unable to find caller class, what should I do?");
+		J3::internalError("unable to find caller class, what should I do?");
 
 	res = caller->cl()->javaClass();
 
@@ -309,25 +309,25 @@ jclass JNICALL JVM_FindPrimitiveClass(JN
 	J3Class* res;
 
   if(!strcmp(utf, "boolean"))
-		res = loader->loadClass(names->get(L"java/lang/Boolean"));
+		res = loader->loadClass(names->get("java/lang/Boolean"));
 	else if(!strcmp(utf, "byte"))
-		res = loader->loadClass(names->get(L"java/lang/Byte"));
+		res = loader->loadClass(names->get("java/lang/Byte"));
 	else if(!strcmp(utf, "char"))
-		res = loader->loadClass(names->get(L"java/lang/Character"));
+		res = loader->loadClass(names->get("java/lang/Character"));
 	else if(!strcmp(utf, "short"))
-		res = loader->loadClass(names->get(L"java/lang/Short"));
+		res = loader->loadClass(names->get("java/lang/Short"));
 	else if(!strcmp(utf, "int"))
-		res = loader->loadClass(names->get(L"java/lang/Integer"));
+		res = loader->loadClass(names->get("java/lang/Integer"));
 	else if(!strcmp(utf, "long"))
-		res = loader->loadClass(names->get(L"java/lang/Long"));
+		res = loader->loadClass(names->get("java/lang/Long"));
 	else if(!strcmp(utf, "float"))
-		res = loader->loadClass(names->get(L"java/lang/Float"));
+		res = loader->loadClass(names->get("java/lang/Float"));
 	else if(!strcmp(utf, "double"))
-		res = loader->loadClass(names->get(L"java/lang/Double"));
+		res = loader->loadClass(names->get("java/lang/Double"));
 	else if(!strcmp(utf, "void"))
-		res = loader->loadClass(names->get(L"java/lang/Void"));
+		res = loader->loadClass(names->get("java/lang/Void"));
 	else
-		J3::internalError(L"unsupported primitive: %s", utf);
+		J3::internalError("unsupported primitive: %s", utf);
 
 	leaveJVM(); 
 	return res->javaClass();
@@ -353,7 +353,7 @@ jclass JNICALL JVM_FindClassFromClassLoa
 	enterJVM();
 	J3* vm = J3Thread::get()->vm();
 	if(jloader)
-		J3::internalError(L"implement me: jloader");
+		J3::internalError("implement me: jloader");
 	J3ClassLoader* loader = J3Thread::get()->vm()->initialClassLoader;
 	const vmkit::Name* name = vm->names()->get(jname);
 	J3Class* cl = loader->loadClass(name);

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Thu Jan  2 07:32:16 2014
@@ -11,6 +11,7 @@
 #include "j3/j3trampoline.h"
 #include "j3/j3lib.h"
 #include "j3/j3field.h"
+#include "j3/j3utf16.h"
 
 #include "llvm/IR/Type.h"
 #include "llvm/IR/DerivedTypes.h"
@@ -104,33 +105,33 @@ void J3::run() {
 
 	nbArrayInterfaces    = 2;
 	arrayInterfaces      = (J3Type**)initialClassLoader->allocator()->allocate(2*sizeof(J3Type*));
-	arrayInterfaces[0]   = z_class(L"java/lang/Cloneable");
-	arrayInterfaces[1]   = z_class(L"java/io/Serializable");
+	arrayInterfaces[0]   = z_class("java/lang/Cloneable");
+	arrayInterfaces[1]   = z_class("java/io/Serializable");
 
 	charArrayClass           = typeChar->getArray();
-	objectClass              = z_class(L"java/lang/Object");
+	objectClass              = z_class("java/lang/Object");
 	
-	stringClass              = z_class(L"java/lang/String");
-	stringClassInit          = z_method(0, stringClass, initName, names()->get(L"([CZ)V"));
-	stringClassValue         = z_field(0, stringClass, L"value", charArrayClass);
+	stringClass              = z_class("java/lang/String");
+	stringClassInit          = z_method(0, stringClass, initName, names()->get("([CZ)V"));
+	stringClassValue         = z_field(0, stringClass, "value", charArrayClass);
 
-	classClass               = z_class(L"java/lang/Class");
-	J3Field hf(J3Cst::ACC_PRIVATE, names()->get(L"** vmData **"), typeLong);
+	classClass               = z_class("java/lang/Class");
+	J3Field hf(J3Cst::ACC_PRIVATE, names()->get("** vmData **"), typeLong);
 	classClass->resolve(&hf, 1);
-	classClassInit           = z_method(0, classClass, initName, names()->get(L"()V"));
+	classClassInit           = z_method(0, classClass, initName, names()->get("()V"));
 	classClassVMData         = classClass->findVirtualField(hf.name(), hf.type());
 
-	threadClass              = z_class(L"java/lang/Thread");
-	threadClassRun           = z_method(0, threadClass, L"run", L"()V");
+	threadClass              = z_class("java/lang/Thread");
+	threadClassRun           = z_method(0, threadClass, names()->get("run"), names()->get("()V"));
 	threadClassVMData        = initialClassLoader->loadClass(names()->get("java/lang/Thread"))
-		->findVirtualField(names()->get(L"eetop"), typeLong);
+		->findVirtualField(names()->get("eetop"), typeLong);
 
-	fieldClass               = z_class(L"java/lang/reflect/Field");
+	fieldClass               = z_class("java/lang/reflect/Field");
 	fieldClassInit           = z_method(0, fieldClass, initName, 
-																			names()->get(L"(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;IILjava/lang/String;[B)V"));
-	fieldClassClass          = z_field(0, fieldClass, L"clazz", classClass);
-	fieldClassSlot           = z_field(0, fieldClass, L"slot", typeInteger);
-	fieldClassAccess         = z_field(0, fieldClass, L"modifiers", typeInteger);
+																			names()->get("(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;IILjava/lang/String;[B)V"));
+	fieldClassClass          = z_field(0, fieldClass, "clazz", classClass);
+	fieldClassSlot           = z_field(0, fieldClass, "slot", typeInteger);
+	fieldClassAccess         = z_field(0, fieldClass, "modifiers", typeInteger);
 
 #if 0
 		J3Field*         fieldClassSlot;
@@ -165,11 +166,17 @@ J3ObjectHandle* J3::nameToString(const v
 	J3ObjectHandle* res = nameToCharArrays[name];
 	if(!res) {
 		J3ObjectHandle* prev = J3Thread::get()->tell();
-		res = initialClassLoader->globalReferences()->add(J3ObjectHandle::doNewArray(charArrayClass, name->length()));
+		uint16_t buf[name->length()];
+		size_t pos = 0;
+		J3Utf16Converter converter(name);
+
+		while(!converter.isEof())
+			buf[pos++] = converter.nextUtf16();
+
+		res = initialClassLoader->globalReferences()->add(J3ObjectHandle::doNewArray(charArrayClass, pos));
+		res->setRegionChar(0, buf, 0, pos);
 		J3Thread::get()->restore(prev);
 
-		for(uint32_t i=0; i<name->length(); i++)
-			res->setCharAt(i, name->cStr()[i]);
 		nameToCharArrays[name] = res;
 	}
 	pthread_mutex_unlock(&stringsMutex);
@@ -181,58 +188,58 @@ J3ObjectHandle* J3::utfToString(const ch
 }
 
 void J3::classCastException() {
-	internalError(L"implement me: class cast exception");
+	internalError("implement me: class cast exception");
 }
 
 void J3::nullPointerException() {
-	internalError(L"implement me: null pointer exception");
+	internalError("implement me: null pointer exception");
 }
 
 void J3::classNotFoundException(const vmkit::Name* name) {
-	internalError(L"ClassNotFoundException: %ls", name);
+	internalError("ClassNotFoundException: %s", name);
 }
 
 void J3::noClassDefFoundError(const vmkit::Name* name) {
-	internalError(L"NoClassDefFoundError: %ls", name);
+	internalError("NoClassDefFoundError: %s", name);
 }
 
-void J3::noSuchMethodError(const wchar_t* msg, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) {
-	internalError(L"%ls: %ls::%ls %ls", msg, cl->name()->cStr(), name->cStr(), sign->cStr());
+void J3::noSuchMethodError(const char* msg, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) {
+	internalError("%s: %s::%s %s", msg, cl->name()->cStr(), name->cStr(), sign->cStr());
 }
 
-void J3::noSuchFieldError(const wchar_t* msg, J3Class* cl, const vmkit::Name* name, J3Type* type) {
-	internalError(L"%ls: %ls::%ls %ls", msg, cl->name()->cStr(), name->cStr(), type->name()->cStr());
+void J3::noSuchFieldError(const char* msg, J3Class* cl, const vmkit::Name* name, J3Type* type) {
+	internalError("%s: %s::%s %s", msg, cl->name()->cStr(), name->cStr(), type->name()->cStr());
 }
 
-void J3::classFormatError(J3Class* cl, const wchar_t* reason, ...) {
-	wchar_t buf[65536];
+void J3::classFormatError(J3Class* cl, const char* reason, ...) {
+	char buf[65536];
 	va_list va;
 	va_start(va, reason);
-	vswprintf(buf, 65536, reason, va);
+	vsnprintf(buf, 65536, reason, va);
 	va_end(va);
-	internalError(L"ClassFormatError in '%ls' caused by '%ls'", cl->name()->cStr(), buf);
+	internalError("ClassFormatError in '%s' caused by '%s'", cl->name()->cStr(), buf);
 }
 
 void J3::linkageError(J3Method* method) {
-	internalError(L"unable to find native method '%ls::%ls%ls'", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr());
+	internalError("unable to find native method '%s::%s%s'", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr());
 }
 
 void J3::arrayStoreException() {
-	internalError(L"array store exception");
+	internalError("array store exception");
 }
 
 void J3::arrayIndexOutOfBoundsException() {
-	internalError(L"array bound check exception");
+	internalError("array bound check exception");
 }
 
 void J3::illegalMonitorStateException() {
-	internalError(L"illegal monitor state exception");
+	internalError("illegal monitor state exception");
 }
 
-void J3::vinternalError(const wchar_t* msg, va_list va) {
-	wchar_t buf[65536];
-	vswprintf(buf, 65536, msg, va);
-	fprintf(stderr, "Internal error: %ls\n", buf);
+void J3::vinternalError(const char* msg, va_list va) {
+	char buf[65536];
+	vsnprintf(buf, 65536, msg, va);
+	fprintf(stderr, "Internal error: %s\n", buf);
 	printStackTrace();
 	//	exit(1);
 	abort();
@@ -246,7 +253,7 @@ void J3::printStackTrace() {
 
 		if(sf) {
 			J3Method* m = ((J3MethodCode*)sf->unit()->getSymbol(sf->functionName()))->self;
-			fprintf(stderr, "    in %ls %ls::%ls index %d\n", m->sign()->cStr(), m->cl()->name()->cStr(), m->name()->cStr(),
+			fprintf(stderr, "    in %s %s::%s index %d\n", m->sign()->cStr(), m->cl()->name()->cStr(), m->name()->cStr(),
 							sf->sourceIndex());
 		} else {
 			Dl_info info;

Modified: vmkit/branches/mcjit/lib/j3/vm/j3attribute.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3attribute.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3attribute.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3attribute.cc Thu Jan  2 07:32:16 2014
@@ -5,7 +5,7 @@ using namespace j3;
 
 J3Attribute* J3Attributes::attribute(size_t n) { 
 	if(n >= _nbAttributes)
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return _attributes + n; 
 }
 

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Thu Jan  2 07:32:16 2014
@@ -46,7 +46,7 @@ J3VirtualTable* J3Type::vtAndResolve() {
 }
 
 void J3Type::dump() {
-	fprintf(stderr, "Type: %ls", name()->cStr());
+	fprintf(stderr, "Type: %s", name()->cStr());
 }
 
 J3ObjectHandle* J3Type::javaClass() {
@@ -65,7 +65,7 @@ J3ObjectHandle* J3Type::javaClass() {
 }
 
 void J3Type::doNativeName() {
-	J3::internalError(L"should not happen");
+	J3::internalError("should not happen");
 }
 
 char* J3Type::nativeName() {
@@ -112,7 +112,7 @@ J3Type* J3Type::resolve(J3Field* hiddenF
 	if(status < RESOLVED)
 		doResolve(hiddenFields, nbHiddenFields);
 	else
-		J3::internalError(L"trying to resolve class %ls with hidden fields while it is already loaded", name()->cStr());
+		J3::internalError("trying to resolve class %s with hidden fields while it is already loaded", name()->cStr());
 	return this;
 }
 
@@ -124,37 +124,37 @@ J3Type* J3Type::initialise() {
 
 J3Class* J3Type::asClass() {
 	if(!isClass())
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return (J3Class*)this;
 }
 
 J3Layout* J3Type::asLayout() {
 	if(!isLayout())
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return (J3Layout*)this;
 }
 
 J3StaticLayout* J3Type::asStaticLayout() {
 	if(!isStaticLayout())
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return (J3StaticLayout*)this;
 }
 
 J3Primitive* J3Type::asPrimitive() {
 	if(!isPrimitive())
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return (J3Primitive*)this;
 }
 
 J3ArrayClass* J3Type::asArrayClass() {
 	if(!isArrayClass())
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return (J3ArrayClass*)this;
 }
 
 J3ObjectType* J3Type::asObjectType() {
 	if(!isObjectType())
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	return (J3ObjectType*)this;
 }
 
@@ -169,11 +169,11 @@ llvm::Type* J3ObjectType::llvmType() {
 }
 
 J3Method* J3ObjectType::findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) {
-	J3::internalError(L"should not happe: %ls::%ls\n", J3ObjectType::name()->cStr(), name->cStr());
+	J3::internalError("should not happe: %s::%s\n", J3ObjectType::name()->cStr(), name->cStr());
 }
 
 J3Method* J3ObjectType::findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) {
-	J3::internalError(L"should not happen");
+	J3::internalError("should not happen");
 }
 
 J3ObjectType* J3ObjectType::nativeClass(J3ObjectHandle* handle) {
@@ -181,7 +181,7 @@ J3ObjectType* J3ObjectType::nativeClass(
 }
 
 void J3ObjectType::prepareInterfaceTable() {
-	//fprintf(stderr, "prepare interface table of %ls\n", name()->cStr());
+	//fprintf(stderr, "prepare interface table of %s\n", name()->cStr());
 
 	uint32_t total = 0;
 	J3InterfaceSlotDescriptor* slots = _interfaceSlotDescriptors;
@@ -192,10 +192,10 @@ void J3ObjectType::prepareInterfaceTable
 		if(type->isClass()) {
 			J3Class* ifce = vt()->checker()->secondaryTypes[i]->type()->asClass();
 			if(J3Cst::isInterface(ifce->access())) {
-				//fprintf(stderr, "  processing interface: %ls\n", ifce->name()->cStr());
+				//fprintf(stderr, "  processing interface: %s\n", ifce->name()->cStr());
 				for(uint32_t j=0; j<ifce->nbMethods(); j++) {
 					J3Method* base = ifce->methods()[j];
-					//fprintf(stderr, "    processing %s method %ls %ls\n", 
+					//fprintf(stderr, "    processing %s method %s %s\n", 
 					//J3Cst::isAbstract(base->access()) ? "abstract" : "concrete",
 					//base->sign()->cStr(), base->name()->cStr());
 					J3Method* method = findVirtualMethod(base->name(), base->sign(), J3Cst::isAbstract(base->access()));
@@ -229,12 +229,12 @@ void J3ObjectType::prepareInterfaceTable
 
 void J3ObjectType::dumpInterfaceSlotDescriptors() {
 	J3InterfaceSlotDescriptor* slots = _interfaceSlotDescriptors;
-	fprintf(stderr, "slot descriptors of %ls\n", name()->cStr());
+	fprintf(stderr, "slot descriptors of %s\n", name()->cStr());
 	for(uint32_t i=0; i<J3VirtualTable::nbInterfaceMethodTable; i++) {
 		if(slots[i].nbMethods) {
 			fprintf(stderr, "  slot[%d]:\n", i);
 			for(uint32_t j=0; j<slots[i].nbMethods; j++)
-				fprintf(stderr, "    %ls::%ls %ls\n", 
+				fprintf(stderr, "    %s::%s %s\n", 
 								slots[i].methods[j]->cl()->name()->cStr(),
 								slots[i].methods[j]->name()->cStr(),
 								slots[i].methods[j]->sign()->cStr());
@@ -264,8 +264,8 @@ J3Method* J3Layout::findMethod(const vmk
 	for(size_t i=0; i<nbMethods(); i++) {
 		J3Method* cur = methods()[i];
 
-		//printf("%ls - %ls\n", cur->name()->cStr(), cur->sign()->cStr());
-		//printf("%ls - %ls\n", name->cStr(), sign->cStr());
+		//printf("%s - %s\n", cur->name()->cStr(), cur->sign()->cStr());
+		//printf("%s - %s\n", name->cStr(), sign->cStr());
 		if(cur->name() == name && cur->sign() == sign) {
 			return cur;
 		}
@@ -277,8 +277,8 @@ J3Field* J3Layout::findField(const vmkit
 	for(size_t i=0; i<nbFields(); i++) {
 		J3Field* cur = fields() + i;
 
-		//printf("Compare %ls - %ls\n", cur->name()->cStr(), cur->type()->name()->cStr());
-		//printf("  with  %ls - %ls\n", name->cStr(), type->name()->cStr());
+		//printf("Compare %s - %s\n", cur->name()->cStr(), cur->type()->name()->cStr());
+		//printf("  with  %s - %s\n", name->cStr(), type->name()->cStr());
 		if(cur->name() == name && cur->type() == type) {
 			return cur;
 		}
@@ -298,13 +298,13 @@ J3Class::J3Class(J3ClassLoader* loader,
 
 J3ObjectHandle* J3Class::extractAttribute(J3Attribute* attr) {
 	if(attr)
-		J3::internalError(L"extract attribute");
+		J3::internalError("extract attribute");
 	else
 		return J3ObjectHandle::doNewArray(loader()->vm()->typeByte->getArray(), 0);
 }
 
 J3Method* J3Class::findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) {
-	//loader()->vm()->log(L"Lookup: %ls %ls in %ls (%d)", methName->cStr(), methSign->cStr(), name()->cStr(), nbVirtualMethods);
+	//loader()->vm()->log("Lookup: %s %s in %s (%d)", methName->cStr(), methSign->cStr(), name()->cStr(), nbVirtualMethods);
 	resolve();
 
 	J3Class* cur = this;
@@ -317,7 +317,7 @@ J3Method* J3Class::findVirtualMethod(con
 
 		if(cur == cur->super()) {
 			if(error)
-				J3::noSuchMethodError(L"no such method", this, name, sign);
+				J3::noSuchMethodError("no such method", this, name, sign);
 			else
 				return 0;
 		}
@@ -326,7 +326,7 @@ J3Method* J3Class::findVirtualMethod(con
 }
 
 J3Method* J3Class::findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) {
-	//loader()->vm()->log(L"Lookup: %ls %ls in %ls", methName->cStr(), methSign->cStr(), name()->cStr());
+	//loader()->vm()->log("Lookup: %s %s in %s", methName->cStr(), methSign->cStr(), name()->cStr());
 	resolve();
 
 	J3Class* cur = this;
@@ -339,7 +339,7 @@ J3Method* J3Class::findStaticMethod(cons
 
 		if(cur == cur->super()) {
 			if(error)
-				J3::noSuchMethodError(L"no such method", this, name, sign);
+				J3::noSuchMethodError("no such method", this, name, sign);
 			else
 				return 0;
 		}
@@ -348,7 +348,7 @@ J3Method* J3Class::findStaticMethod(cons
 }
 
 J3Field* J3Class::findVirtualField(const vmkit::Name* name, J3Type* type, bool error) {
-	//loader()->vm()->log(L"Lookup: %ls %ls in %ls", type->name()->cStr(), name->cStr(), J3Class::name()->cStr());
+	//loader()->vm()->log("Lookup: %s %s in %s", type->name()->cStr(), name->cStr(), J3Class::name()->cStr());
 	resolve();
 	J3Class* cur = this;
 
@@ -360,7 +360,7 @@ J3Field* J3Class::findVirtualField(const
 
 		if(cur == cur->super()) {
 			if(error)
-				J3::noSuchFieldError(L"no such field", this, name, type);
+				J3::noSuchFieldError("no such field", this, name, type);
 			else
 				return 0;
 		}
@@ -369,13 +369,13 @@ J3Field* J3Class::findVirtualField(const
 }
 
 J3Field* J3Class::findStaticField(const vmkit::Name* fname, J3Type* ftype, bool error) {
-	//fprintf(stderr, "Lookup static field %ls %ls::%ls\n", ftype->name()->cStr(), name()->cStr(), fname->cStr());
+	//fprintf(stderr, "Lookup static field %s %s::%s\n", ftype->name()->cStr(), name()->cStr(), fname->cStr());
 	resolve();
 
 	J3Field* res = staticLayout()->findField(fname, ftype);
 
 	if(!res)
-		J3::internalError(L"implement me");
+		J3::internalError("implement me");
 
 	return res;
 }
@@ -386,7 +386,7 @@ void J3Class::registerNative(const vmkit
 	if(!res)
 		res = findMethod(methName, methSign);
 	if(!res || !J3Cst::isNative(res->access()))
-		J3::noSuchMethodError(L"unable to find native method", this, methName, methSign);
+		J3::noSuchMethodError("unable to find native method", this, methName, methSign);
 
 	res->registerNative(fnPtr);
 }
@@ -400,7 +400,7 @@ void J3Class::doInitialise() {
 	lock();
 	if(status < INITED) {
 		if(loader()->vm()->options()->debugIniting)
-			fprintf(stderr, "Initing: %ls\n", name()->cStr());
+			fprintf(stderr, "Initing: %s\n", name()->cStr());
 		status = INITED;
 
 		super()->initialise();
@@ -424,7 +424,7 @@ void J3Class::doInitialise() {
 
 				uint32_t length = reader.readU4();
 				if(length != 2)
-					J3::classFormatError(this, L"bad length for ConstantAttribute");
+					J3::classFormatError(this, "bad length for ConstantAttribute");
 				
 				uint32_t idx = reader.readU2();
 
@@ -435,7 +435,7 @@ void J3Class::doInitialise() {
 					case J3Cst::CONSTANT_Integer: staticInstance()->setInteger(cur, integerAt(idx)); break;
 					case J3Cst::CONSTANT_String:  staticInstance()->setObject(cur, stringAt(idx)); break;
 					default:
-						J3::classFormatError(this, L"invalid ctp entry ConstantAttribute with type %d", getCtpType(idx));
+						J3::classFormatError(this, "invalid ctp entry ConstantAttribute with type %d", getCtpType(idx));
 				}
 			}
 		}
@@ -452,7 +452,7 @@ void J3Class::doResolve(J3Field* hiddenF
 	lock();
 	if(status < RESOLVED) {
 		if(loader()->vm()->options()->debugResolve)
-			fprintf(stderr, "Resolving: %ls\n", name()->cStr());
+			fprintf(stderr, "Resolving: %s\n", name()->cStr());
 
 		status = RESOLVED;
 		readClassBytes(hiddenFields, nbHiddenFields);
@@ -472,7 +472,7 @@ void J3Class::readClassBytes(J3Field* hi
 
 	uint32_t magic = reader.readU4();
 	if(magic != J3Cst::MAGIC)
-		J3::classFormatError(this, L"bad magic");
+		J3::classFormatError(this, "bad magic");
 			
 	/* uint16_t minor = */reader.readU2();
 	/* uint16_t major = */reader.readU2();
@@ -480,7 +480,7 @@ void J3Class::readClassBytes(J3Field* hi
 	nbCtp     = reader.readU2();
 	
 	if(nbCtp < 1)
-		J3::classFormatError(this, L"zero-sized constant pool");
+		J3::classFormatError(this, "zero-sized constant pool");
 	
 	ctpTypes    = (uint8_t*)loader()->allocator()->allocate(nbCtp * sizeof(uint8_t));
 	ctpValues   = (uint32_t*)loader()->allocator()->allocate(nbCtp * sizeof(uint32_t));
@@ -519,7 +519,7 @@ void J3Class::readClassBytes(J3Field* hi
 				ctpValues[i] |= reader.readU2();
 				break;
 			default:
-				J3::classFormatError(this, L"wrong constant pool entry type: %d", ctpTypes[i]);
+				J3::classFormatError(this, "wrong constant pool entry type: %d", ctpTypes[i]);
 		}
 	}
 	
@@ -528,7 +528,7 @@ void J3Class::readClassBytes(J3Field* hi
 	J3ObjectType* self = classAt(reader.readU2());
 	
 	if(self != this)
-		J3::classFormatError(this, L"wrong class file (describes class %ls)", self->name()->cStr());
+		J3::classFormatError(this, "wrong class file (describes class %s)", self->name()->cStr());
 	
 	uint16_t superIdx = reader.readU2();
 
@@ -578,7 +578,7 @@ void J3Class::readClassBytes(J3Field* hi
 			case 1:  pFields1[i1++] = f; break;
 			case 2:  pFields2[i2++] = f; break;
 			case 3:  pFields3[i3++] = f; break;
-			default: J3::internalError(L"should not happen");
+			default: J3::internalError("should not happen");
 		}
 	}
 
@@ -643,7 +643,7 @@ void J3Class::fillFields(J3Field** field
 		J3Field*  cur = fields[i];
 		J3Layout* layout = J3Cst::isStatic(fields[i]->access()) ? (J3Layout*)staticLayout() : this;
 
-		//fprintf(stderr, "   adding static field: %ls %ls::%ls\n", cur->type()->name()->cStr(), name()->cStr(), cur->name()->cStr());
+		//fprintf(stderr, "   adding static field: %s %s::%s\n", cur->type()->name()->cStr(), name()->cStr(), cur->name()->cStr());
 		cur->_offset = layout->structSize();
 		cur->_slot = layout->_nbFields;
 		layout->_structSize += 1 << fields[i]->type()->logSize();
@@ -715,7 +715,7 @@ J3Method* J3Class::interfaceOrMethodAt(u
 	
 	if(res) {
 		if((res->access() & J3Cst::ACC_STATIC) != (access & J3Cst::ACC_STATIC))
-			J3::classFormatError(this, L"inconsistent use of virtual and static methods"); 
+			J3::classFormatError(this, "inconsistent use of virtual and static methods"); 
 		return res;
 	}
 
@@ -747,7 +747,7 @@ J3Field* J3Class::fieldAt(uint16_t idx,
 
 	if(res) {
 		if((res->access() & J3Cst::ACC_STATIC) != (access & J3Cst::ACC_STATIC))
-			J3::classFormatError(this, L"inconstitent use of virtual and static field"); 
+			J3::classFormatError(this, "inconstitent use of virtual and static field"); 
 		return res;
 	}
 
@@ -803,7 +803,7 @@ const vmkit::Name*  J3Class::nameAt(uint
 
 void J3Class::check(uint16_t idx, uint32_t id) {
 	if(idx > nbCtp || (id != -1 && ctpTypes[idx] != id))
-		J3::classFormatError(this, L"wrong constant pool type %d at index %d for %d", id, idx, nbCtp);
+		J3::classFormatError(this, "wrong constant pool type %d at index %d for %d", id, idx, nbCtp);
 }
 
 void J3Class::doNativeName() {
@@ -832,15 +832,15 @@ J3ArrayClass::J3ArrayClass(J3ClassLoader
 	if(!name) {
 		const vmkit::Name* compName = component->name();
 		uint32_t           len = compName->length();
-		wchar_t            buf[len + 16];
+		char               buf[len + 16];
 		uint32_t           pos = 0;
 
-		//printf("     build array of %ls\n", component->name()->cStr());
+		//printf("     build array of %s\n", component->name()->cStr());
 		buf[pos++] = J3Cst::ID_Array;
 	
 		if(component->isClass())
 			buf[pos++] = J3Cst::ID_Classname;
-		memcpy(buf+pos, compName->cStr(), len * sizeof(wchar_t));
+		memcpy(buf+pos, compName->cStr(), len * sizeof(char));
 		pos += len;
 		if(component->isClass())
 			buf[pos++] = J3Cst::ID_End;

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc Thu Jan  2 07:32:16 2014
@@ -84,20 +84,16 @@ J3Class* J3ClassLoader::defineClass(cons
 }
 
 J3Class* J3ClassLoader::loadClass(const vmkit::Name* name) {
-	J3::internalError(L"implement me: loadClass from a Java class loader");
-}
-
-J3Class* J3ClassLoader::loadClass(const wchar_t* name) {
-	return loadClass(vm()->names()->get(name));
+	J3::internalError("implement me: loadClass from a Java class loader");
 }
 
 void J3ClassLoader::wrongType(J3Class* from, const vmkit::Name* type) {
-	J3::classFormatError(from, L"wrong type: %ls", type->cStr());
+	J3::classFormatError(from, "wrong type: %s", type->cStr());
 }
 
 J3Type* J3ClassLoader::getTypeInternal(J3Class* from, const vmkit::Name* typeName, uint32_t start, uint32_t* pend) {
 	J3Type*        res  = 0;
-	const wchar_t* type = typeName->cStr();
+	const char*    type = typeName->cStr();
 	uint32_t       len  = typeName->length();
 	uint32_t       pos  = start;
 	uint32_t       prof = 0;
@@ -120,7 +116,7 @@ J3Type* J3ClassLoader::getTypeInternal(J
 			case J3Cst::ID_Classname: 
 				{ 
 					uint32_t start = ++pos;
-					wchar_t buf[len + 1 - start], c;
+					char buf[len + 1 - start], c;
 					
 					memset(buf, 0, len + 1 - pos);
 					
@@ -162,7 +158,7 @@ J3Type* J3ClassLoader::getType(J3Class*
 		if(end != type->length())
 			wrongType(from, type);
 
-		//printf("Analyse %ls => %ls\n", type->cStr(), res->name()->cStr());
+		//printf("Analyse %s => %ls\n", type->cStr(), res->name()->cStr());
 		
 		pthread_mutex_lock(&_mutexTypes);
 		types[type] = res;
@@ -225,16 +221,6 @@ J3Method* J3ClassLoader::method(uint16_t
 	return method(access, loadClass(clName), name, sign);
 }
 
-J3Method* J3ClassLoader::method(uint16_t access, const wchar_t* clName, const wchar_t* name, const wchar_t* sign) {
-	vmkit::Names* names = vm()->names();
-	return method(access, names->get(clName), names->get(name), names->get(sign));
-}
-
-J3Method* J3ClassLoader::method(uint16_t access, J3Class* cl, const wchar_t* name, const wchar_t* sign) {
-	vmkit::Names* names = vm()->names();
-	return method(access, cl, names->get(name), names->get(sign));
-}
-
 bool J3ClassLoader::J3InterfaceMethodLess::operator()(j3::J3Method const* lhs, j3::J3Method const* rhs) const {
 	return lhs->name() < rhs->name()
 		|| (lhs->name() == rhs->name()
@@ -261,13 +247,13 @@ J3InitialClassLoader::J3InitialClassLoad
 	if (bytes) {
 		archive = new(allocator()) J3ZipArchive(bytes, allocator());
 		if(!archive) {
-			J3::internalError(L"unable to find system archive");
+			J3::internalError("unable to find system archive");
 		}
 	} else 
-		J3::internalError(L"unable to find system archive");
+		J3::internalError("unable to find system archive");
 
 	if(J3Lib::loadSystemLibraries(&nativeLibraries) == -1)
-		J3::internalError(L"unable to find java library");
+		J3::internalError("unable to find java library");
 }
 
 J3Class* J3InitialClassLoader::loadClass(const vmkit::Name* name) {
@@ -278,7 +264,7 @@ J3Class* J3InitialClassLoader::loadClass
 
 	char tmp[name->length()+16];
 		
-	//printf("L: %ls\n", name->cStr());
+	//printf("L: %s\n", name->cStr());
 	for(int i=0; i<name->length(); i++) {
 		char c = name->cStr()[i] & 0xff;
 		tmp[i] = c == '.' ? '/' : c;

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Thu Jan  2 07:32:16 2014
@@ -40,12 +40,12 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
 	vm = loader->vm();
 
 #if 0
-	if(m->cl()->name() == vm->names()->get(L"java/util/concurrent/atomic/AtomicInteger"))
+	if(m->cl()->name() == vm->names()->get("java/util/concurrent/atomic/AtomicInteger"))
 		vm->options()->debugTranslate = 4;
 #endif
 
 	if(vm->options()->debugTranslate)
-		fprintf(stderr, "  translating bytecode of: %ls::%ls%ls\n", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr());
+		fprintf(stderr, "  translating bytecode of: %s::%s%s\n", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr());
 
 	module = new llvm::Module(method->llvmFunctionName(), vm->llvmContext());
 	llvmFunction = buildFunction(method, 0);
@@ -169,7 +169,7 @@ llvm::Value* J3CodeGen::flatten(llvm::Va
 	else if(type == vm->typeChar)
 		return builder->CreateZExt(v, vm->typeInteger->llvmType());
 	else
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 }
 
 llvm::Value* J3CodeGen::unflatten(llvm::Value* v, J3Type* type) {
@@ -183,7 +183,7 @@ llvm::Value* J3CodeGen::unflatten(llvm::
 		return builder->CreateZExtOrTrunc(v, type->llvmType());
 	else {
 		type->dump();
-		J3::internalError(L"should not happen");
+		J3::internalError("should not happen");
 	}
 }
 
@@ -379,7 +379,7 @@ llvm::Value* J3CodeGen::nullCheck(llvm::
 	return obj;
 }
 
-#define nyi() J3::internalError(L"not yet implemented: '%s' (%d)", J3Cst::opcodeNames[bc], bc);
+#define nyi() J3::internalError("not yet implemented: '%s' (%d)", J3Cst::opcodeNames[bc], bc);
 
 void J3CodeGen::invoke(J3Method* target, llvm::Value* func) {
 	J3MethodType* type = target->methodType(cl);
@@ -557,7 +557,7 @@ void J3CodeGen::newArray(uint8_t atype)
 		case J3Cst::T_INT:     prim = vm->typeInteger; break;
 		case J3Cst::T_LONG:    prim = vm->typeLong; break;
 		default:
-			J3::classFormatError(cl, L"wrong atype: %d\n", atype);
+			J3::classFormatError(cl, "wrong atype: %d\n", atype);
 	}
 
 	newArray(prim->getArray());
@@ -700,7 +700,7 @@ void J3CodeGen::ldc(uint32_t idx) {
 																								builder->getInt16(idx)));
 			break;
 		default:
-			J3::classFormatError(cl, L"wrong ldc type: %d\n", cl->getCtpType(idx));
+			J3::classFormatError(cl, "wrong ldc type: %d\n", cl->getCtpType(idx));
 	}
 	stack.push(res);
 }
@@ -725,7 +725,7 @@ llvm::BasicBlock* J3CodeGen::forwardBran
 		//printf("split at %d (%s)\n", pc, id);
 		llvm::Instruction* insn = opInfos[pc].insn;
 		if(!insn)
-			J3::classFormatError(cl, L"jmp: not to an instruction");
+			J3::classFormatError(cl, "jmp: not to an instruction");
 		insn = insn->getNextNode();
 		//fprintf(stderr, "--- instruction ---\n");
 		//insn->dump();
@@ -857,7 +857,7 @@ void J3CodeGen::translate() {
 
 	if(vm->options()->genDebugExecute) {
 		char buf[256];
-		snprintf(buf, 256, "%ls::%ls", method->cl()->name()->cStr(), method->name()->cStr());
+		snprintf(buf, 256, "%s::%s", method->cl()->name()->cStr(), method->name()->cStr());
 #if 0
 
 		fprintf(stderr, "bitcast: ");
@@ -903,7 +903,7 @@ void J3CodeGen::translate() {
 		if(opInfos[javaPC].insn || opInfos[javaPC].bb) {
 			if(closeBB && !bb->getTerminator()) {
 				if(!opInfos[javaPC].bb)
-					J3::internalError(L"random split???");
+					J3::internalError("random split???");
 				builder->CreateBr(opInfos[javaPC].bb);
 			}
 		}
@@ -955,7 +955,7 @@ void J3CodeGen::translate() {
 
 		if(vm->options()->genDebugExecute) {
 			char buf[256];
-			snprintf(buf, 256, "    [%4d] executing: %-20s in %ls::%ls", javaPC, 
+			snprintf(buf, 256, "    [%4d] executing: %-20s in %s::%s", javaPC, 
 							 J3Cst::opcodeNames[bc], method->cl()->name()->cStr(), method->name()->cStr());
 			builder->CreateCall3(funcEchoDebugExecute,
 													 builder->getInt32(2),
@@ -1526,15 +1526,15 @@ void J3CodeGen::translate() {
 			case J3Cst::BC_impdep2:                       /* 0xff */
 			case J3Cst::BC_xxxunusedxxx1:                 /* 0xba */
 			default:
-				J3::classFormatError(cl, L"unknow opcode '%s' (%d)", J3Cst::opcodeNames[bc], bc);
+				J3::classFormatError(cl, "unknow opcode '%s' (%d)", J3Cst::opcodeNames[bc], bc);
 		}
 	}
-	J3::classFormatError(cl, L"the last bytecode does not return");
+	J3::classFormatError(cl, "the last bytecode does not return");
 }
 
 #if 0
 void J3CodeGen::explore() {
-	printf("  exploring bytecode of: %ls::%ls%ls\n", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr());
+	printf("  exploring bytecode of: %s::%s%s\n", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr());
 	while(codeReader->remaining()) {
 		uint8_t bc = codeReader->readU1();
 
@@ -1545,7 +1545,7 @@ void J3CodeGen::explore() {
 			case J3Cst::BC_##id: effect; break;
 #include "j3/j3bc.def"
 			default:
-				J3::internalError(L"unknow opcode '%s' (%d)", J3Cst::opcodeNames[bc], bc);
+				J3::internalError("unknow opcode '%s' (%d)", J3Cst::opcodeNames[bc], bc);
 		}
 	}
 }
@@ -1555,7 +1555,7 @@ void J3CodeGen::generateJava() {
 	J3Attribute* attr = method->attributes()->lookup(vm->codeAttribute);
 
 	if(!attr)
-		J3::classFormatError(cl, L"No Code attribute in %ls %ls", method->name()->cStr(), method->sign()->cStr());
+		J3::classFormatError(cl, "No Code attribute in %s %s", method->name()->cStr(), method->sign()->cStr());
 
 	J3Reader reader(cl->bytes());
 	reader.seek(attr->offset(), reader.SeekSet);
@@ -1563,7 +1563,7 @@ void J3CodeGen::generateJava() {
 	uint32_t length = reader.readU4();
 	
 	if(!reader.adjustSize(length))
-		J3::classFormatError(cl, L"Code attribute of %ls %ls is too large (%d)", method->name()->cStr(), method->sign()->cStr(), length);
+		J3::classFormatError(cl, "Code attribute of %s %s is too large (%d)", method->name()->cStr(), method->sign()->cStr(), length);
 
 	llvm::DIBuilder* dbgBuilder = new llvm::DIBuilder(*module);
 
@@ -1610,7 +1610,7 @@ void J3CodeGen::generateJava() {
 	builder->SetInsertPoint(bbRet);
 	if(vm->options()->genDebugExecute) {
 		char buf[256];
-		snprintf(buf, 256, "%ls::%ls", method->cl()->name()->cStr(), method->name()->cStr());
+		snprintf(buf, 256, "%s::%s", method->cl()->name()->cStr(), method->name()->cStr());
 		builder->CreateCall3(funcEchoDebugEnter,
 												 builder->getInt32(1),
 												 buildString("%s\n"),

Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegenexception.cc Thu Jan  2 07:32:16 2014
@@ -119,7 +119,7 @@ void J3ExceptionTable::read(J3Reader* re
 
 void J3ExceptionTable::dump(bool verbose) {
 	if(nbEntries) {
-		fprintf(stderr, "    ExceptionTable of %ls::%ls%ls:\n", 
+		fprintf(stderr, "    ExceptionTable of %s::%s%s:\n", 
 						codeGen->method->cl()->name()->cStr(), 
 						codeGen->method->name()->cStr(),
 						codeGen->method->sign()->cStr());

Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc Thu Jan  2 07:32:16 2014
@@ -85,7 +85,7 @@ void J3CodeGenVar::dump() {
 			v = refStack[i];
 		else {
 			t->dump();
-			J3::internalError(L"should not happen");
+			J3::internalError("should not happen");
 		}
 
 		v->dump();
@@ -99,7 +99,7 @@ void J3CodeGenVar::drop(uint32_t n) {
 
 llvm::AllocaInst** J3CodeGenVar::stackOf(llvm::Type* t) {
 	if(!t)
-		J3::internalError(L"unable to find the type of a local/stack");
+		J3::internalError("unable to find the type of a local/stack");
 
 	if(t->isIntegerTy(64)) {
 		return longStack;
@@ -113,7 +113,7 @@ llvm::AllocaInst** J3CodeGenVar::stackOf
 		return refStack;
 	} 
 		
-	J3::internalError(L"should not happen");
+	J3::internalError("should not happen");
 }
 
 void J3CodeGenVar::setAt(llvm::Value* value, uint32_t idx) {
@@ -132,14 +132,14 @@ void J3CodeGenVar::push(llvm::Value* val
 	//	value->dump();
 	//	fprintf(stderr, "\n");
 	if(topStack >= maxStack)
-		J3::classFormatError(codeGen->cl, L"too many push in... ");
+		J3::classFormatError(codeGen->cl, "too many push in... ");
 
 	setAt(value, topStack++);
 }
 
 llvm::Value* J3CodeGenVar::pop() {
 	if(!topStack)
-		J3::classFormatError(codeGen->cl, L"too many pop in... ");
+		J3::classFormatError(codeGen->cl, "too many pop in... ");
 
 	llvm::Value* res = at(--topStack);
 	return res;
@@ -147,7 +147,7 @@ llvm::Value* J3CodeGenVar::pop() {
 
 llvm::Value* J3CodeGenVar::top(uint32_t idx) {
 	if(topStack <= idx)
-		J3::classFormatError(codeGen->cl, L"too large top in... ");
+		J3::classFormatError(codeGen->cl, "too large top in... ");
 	
 	return at(topStack - idx - 1);
 }

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3constants.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3constants.cc Thu Jan  2 07:32:16 2014
@@ -11,13 +11,13 @@ using namespace j3;
 char    J3Cst::nativePrefix[] = "Java_";
 
 const vmkit::Name* J3Cst::rewrite(J3* vm, const vmkit::Name* clName, const vmkit::Name* orig) {
-	wchar_t res[clName->length() + orig->length() + 3];
+	char res[clName->length() + orig->length() + 3];
 
 	res[0] = ID_Left;
 	res[1] = ID_Classname;
-	memcpy(res+2, clName->cStr(), sizeof(wchar_t)*clName->length());
+	memcpy(res+2, clName->cStr(), sizeof(char)*clName->length());
 	res[2 + clName->length()] = ID_End;
-	memcpy(res+3+clName->length(), orig->cStr()+1, sizeof(wchar_t)*(orig->length()-1));
+	memcpy(res+3+clName->length(), orig->cStr()+1, sizeof(char)*(orig->length()-1));
 	res[2 + clName->length() + orig->length()] = 0;
 
 	return vm->names()->get(res);

Modified: vmkit/branches/mcjit/lib/j3/vm/j3field.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3field.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3field.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3field.cc Thu Jan  2 07:32:16 2014
@@ -36,6 +36,6 @@ J3ObjectHandle* J3Field::javaField() {
 }
 
 void J3Field::dump() {
-	printf("Field: %ls %ls::%ls (%d)\n", type()->name()->cStr(), layout()->name()->cStr(), name()->cStr(), access());
+	printf("Field: %s %s::%s (%d)\n", type()->name()->cStr(), layout()->name()->cStr(), name()->cStr(), access());
 }
 

Modified: vmkit/branches/mcjit/lib/j3/vm/j3jni.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3jni.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3jni.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3jni.cc Thu Jan  2 07:32:16 2014
@@ -10,7 +10,7 @@
 #define enterJVM() try {
 #define leaveJVM() } catch(void* e) { J3Thread::get()->setPendingException(J3Thread::get()->push((J3Object*)e)); }
 
-#define NYI() { J3Thread::get()->vm()->internalError(L"not yet implemented: '%s'", __PRETTY_FUNCTION__); }
+#define NYI() { J3Thread::get()->vm()->internalError("not yet implemented: '%s'", __PRETTY_FUNCTION__); }
 
 namespace j3 {
 

Modified: vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc Thu Jan  2 07:32:16 2014
@@ -2,6 +2,7 @@
 #include "j3/j3class.h"
 #include "j3/j3classloader.h"
 #include "j3/j3method.h"
+#include "j3/j3utf16.h"
 #include "j3/j3.h"
 
 using namespace j3;
@@ -18,7 +19,7 @@ J3Mangler::J3Mangler(J3Class* _from) {
 void J3Mangler::check(uint32_t n) {
 	next = cur + n;
 	if((next+1) >= (buf + max))
-		J3::internalError(L"unable to mangle: not enough space");
+		J3::internalError("unable to mangle: not enough space");
 }
 
 J3Mangler* J3Mangler::mangleType(J3Method* method) {
@@ -35,12 +36,6 @@ J3Mangler* J3Mangler::mangleType(J3Metho
 			memcpy(cur, type->ins(i)->nativeName(), type->ins(i)->nativeNameLength());
 			cur = next;
 		}
-
-#if 0
-		check(type->out()->nativeNameLength());
-		memcpy(cur, type->out()->nativeName(), type->out()->nativeNameLength());
-		cur = next;
-#endif
 	}
 	check(1);
 	*cur = 0;
@@ -70,9 +65,11 @@ J3Mangler* J3Mangler::mangle(const char*
 }
 
 J3Mangler* J3Mangler::mangle(const vmkit::Name* name) {
+	J3Utf16Converter converter(name);
+
 	next = cur;
-	for(size_t i=0; i<name->length(); i++) {
-		wchar_t c = name->cStr()[i];
+	while(!converter.isEof()) {
+		uint16_t c = converter.nextUtf16();
 
 		if(c > 256) {
 			check(6);

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Thu Jan  2 07:32:16 2014
@@ -52,14 +52,14 @@ void J3Method::markCompiled(llvm::Functi
 
 void* J3Method::fnPtr(bool withCaller) {
 	if(!isCompiled()) {
-		//fprintf(stderr, "materializing: %ls::%ls%ls\n", this, cl()->name()->cStr(), name()->cStr(), sign()->cStr());
+		//fprintf(stderr, "materializing: %s::%s%s\n", this, cl()->name()->cStr(), name()->cStr(), sign()->cStr());
 		if(!isResolved()) {
 			if(cl()->loader()->vm()->options()->debugLinking)
-				fprintf(stderr, "linking %ls::%ls\n", cl()->name()->cStr(), name()->cStr());
+				fprintf(stderr, "linking %s::%s\n", cl()->name()->cStr(), name()->cStr());
 
 			cl()->initialise();
 			if(!isResolved())
-				J3::noSuchMethodError(L"unable to find method", cl(), name(), sign());
+				J3::noSuchMethodError("unable to find method", cl(), name(), sign());
 		}
 
 		J3CodeGen::translate(this, 1, withCaller);
@@ -94,20 +94,20 @@ void* J3Method::getSymbolAddress() {
 
 void J3Method::setResolved(uint32_t index) { 
 	if(isResolved())
-		J3::internalError(L"trying to re-resolve a resolved method, should not happen");
+		J3::internalError("trying to re-resolve a resolved method, should not happen");
 	_index = index; 
 }
 
 void J3Method::postInitialise(uint32_t access, J3Attributes* attributes) {
 	if((access & J3Cst::ACC_STATIC) != (_access & J3Cst::ACC_STATIC))
-		J3::classFormatError(cl(), L"trying to modify the static flag of %ls", cl()->name()->cStr());
+		J3::classFormatError(cl(), "trying to modify the static flag of %s", cl()->name()->cStr());
 	_access = access;
 	_attributes = attributes;
 }
 
 J3Method* J3Method::resolve(J3ObjectHandle* obj) {
 	if(cl()->loader()->vm()->options()->debugLinking)
-		fprintf(stderr, "virtual linking %ls::%ls\n", cl()->name()->cStr(), name()->cStr());
+		fprintf(stderr, "virtual linking %s::%s\n", cl()->name()->cStr(), name()->cStr());
 	vmkit::Names* n = cl()->loader()->vm()->names();
 	return obj->vt()->type()->asObjectType()->findVirtualMethod(name(), sign());
 }
@@ -117,7 +117,7 @@ J3Value J3Method::internalInvoke(bool st
 
 	void* fn = fnPtr(1);
 
-	//fprintf(stderr, "Internal invoke %ls::%ls%ls\n", target->cl()->name()->cStr(), target->name()->cStr(), target->sign()->cStr());
+	//fprintf(stderr, "Internal invoke %s::%s%s\n", target->cl()->name()->cStr(), target->name()->cStr(), target->sign()->cStr());
 	
 	if(!methodType()->llvmSignature()->caller())
 		J3CodeGen::translate(this, 0, 1);
@@ -272,11 +272,11 @@ char* J3Method::llvmStubName(J3Class* fr
 }
 
 void J3Method::dump() {
-	printf("Method: %ls %ls::%ls\n", sign()->cStr(), cl()->name()->cStr(), name()->cStr());
+	printf("Method: %s %s::%s\n", sign()->cStr(), cl()->name()->cStr(), name()->cStr());
 }
 
 void J3Method::registerNative(void* fnPtr) {
 	if(_nativeFnPtr)
-		J3::noSuchMethodError(L"unable to dynamically modify a native function", cl(), name(), sign());
+		J3::noSuchMethodError("unable to dynamically modify a native function", cl(), name(), sign());
 	_nativeFnPtr = fnPtr;
 }

Modified: vmkit/branches/mcjit/lib/j3/vm/j3object.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3object.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Thu Jan  2 07:32:16 2014
@@ -25,13 +25,13 @@ void J3TypeChecker::dump() {
 	fprintf(stderr, "    offset: %u\n", offset);
 	for(uint32_t i=0; i<cacheOffset; i++) {
 		if(display[i])
-			fprintf(stderr, "    display[%u]: %ls\n", i, display[i]->type()->name()->cStr());
+			fprintf(stderr, "    display[%u]: %s\n", i, display[i]->type()->name()->cStr());
 	}
 	for(uint32_t i=0; i<nbSecondaryTypes; i++) {
-		fprintf(stderr, "    secondary[%u]: %ls\n", i, secondaryTypes[i]->type()->name()->cStr());
+		fprintf(stderr, "    secondary[%u]: %s\n", i, secondaryTypes[i]->type()->name()->cStr());
 	}
 	if(display[cacheOffset])
-		fprintf(stderr, "    cache: %ls\n", display[cacheOffset]->type()->name()->cStr());
+		fprintf(stderr, "    cache: %s\n", display[cacheOffset]->type()->name()->cStr());
 }
 
 /*
@@ -136,7 +136,7 @@ J3VirtualTable* J3VirtualTable::create(J
 			isSecondary = 1;
 		super = baseClass->super()->getArray(dim);
 		super->resolve();
-		//printf("%ls super is %ls (%d)\n", cl->name()->cStr(), super->name()->cStr(), isSecondary);
+		//printf("%s super is %ls (%d)\n", cl->name()->cStr(), super->name()->cStr(), isSecondary);
 
 		uint32_t n = baseClass->vt()->checker()->nbSecondaryTypes;
 		secondaries = (J3Type**)alloca(n*sizeof(J3Type*));
@@ -171,17 +171,17 @@ void* J3VirtualTable::operator new(size_
 J3VirtualTable::J3VirtualTable(J3Type* type, J3Type* super, J3Type** interfaces, uint32_t nbInterfaces, bool isSecondary) {
 	_type = type;
 
-	//	printf("***   Building the vt of %ls based on %ls at %p\n", type->name()->cStr(), super->name()->cStr(), this);
+	//	printf("***   Building the vt of %s based on %ls at %p\n", type->name()->cStr(), super->name()->cStr(), this);
 
 	if(super == type) {
 		checker()->offset = 0;
 		checker()->display[checker()->offset] = this;
 		if(nbInterfaces)
-			J3::internalError(L"a root J3VirtualTable should not have interfaces");
+			J3::internalError("a root J3VirtualTable should not have interfaces");
 	} else {
 		uint32_t parentDisplayLength = super->vt()->checker()->offset + 1;
 
-		//printf("%ls (%p) secondary: %p %p (%d)\n", type->name()->cStr(), this, checker()->secondaryTypes, checker()->display[6], parentDisplayLength);
+		//printf("%s (%p) secondary: %p %p (%d)\n", type->name()->cStr(), this, checker()->secondaryTypes, checker()->display[6], parentDisplayLength);
 
 		if(parentDisplayLength >= J3TypeChecker::cacheOffset)
 			isSecondary = 1;
@@ -191,7 +191,7 @@ J3VirtualTable::J3VirtualTable(J3Type* t
 		checker()->nbSecondaryTypes = super->vt()->checker()->nbSecondaryTypes + nbInterfaces + isSecondary;
 		checker()->secondaryTypes = (J3VirtualTable**)super->loader()->allocator()->allocate(checker()->nbSecondaryTypes*sizeof(J3VirtualTable*));
 		
-		//printf("%ls: %d - %d %d\n", type->name()->cStr(), isSecondary, parentDisplayLength, J3TypeChecker::displayLength);
+		//printf("%s: %d - %d %d\n", type->name()->cStr(), isSecondary, parentDisplayLength, J3TypeChecker::displayLength);
 		if(isSecondary) {
 			checker()->offset = J3TypeChecker::cacheOffset;
 			checker()->secondaryTypes[0] = this;
@@ -255,7 +255,7 @@ bool J3VirtualTable::isAssignableTo(J3Vi
 }
 
 void J3VirtualTable::dump() {
-	fprintf(stderr, "VirtualTable: %s%ls (%p)\n", 
+	fprintf(stderr, "VirtualTable: %s%s (%p)\n", 
 					type()->isLayout() && !type()->isClass() ? "static_" : "",
 					type()->name()->cStr(), this);
 	checker()->dump();
@@ -290,11 +290,11 @@ J3Object* J3Object::doNew(J3Class* cl) {
 }
 
 void J3Object::monitorEnter(J3Object* obj) {
-	J3::internalError(L"implement me: monitorenter");
+	J3::internalError("implement me: monitorenter");
 }
 
 void J3Object::monitorExit(J3Object* obj) {
-	J3::internalError(L"implement me: monitorexit");
+	J3::internalError("implement me: monitorexit");
 }
 
 uint32_t J3Object::hashCode() {
@@ -354,7 +354,7 @@ J3Monitor* J3Object::monitor() {
 				monitor->prepare(this, record->header, record); 
 			} else {            /* not locked at all */
 				if((header & 7) != 1)
-					J3::internalError(L"should not happen");
+					J3::internalError("should not happen");
 				monitor->prepare(this, header, 0);
 			}
 			_header = (uintptr_t)monitor | 2;

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=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc Thu Jan  2 07:32:16 2014
@@ -19,7 +19,7 @@ void* J3Trampoline::interfaceTrampoline(
 		res = desc->methods[0]->fnPtr(0);
 		handle->vt()->_interfaceMethodTable[index] = res;
 	} else
-		J3::internalError(L"implement me: interface Trampoline with collision");
+		J3::internalError("implement me: interface Trampoline with collision");
 
 	J3Thread::get()->restore(prev);
 

Modified: vmkit/branches/mcjit/lib/vmkit/allocator.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/allocator.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/allocator.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/allocator.cc Thu Jan  2 07:32:16 2014
@@ -73,7 +73,7 @@ void* BumpAllocator::allocate(size_t siz
 void* BumpAllocator::map(size_t n) {
 	void* res = mmap(0, n, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0);
 	if(res == MAP_FAILED)
-		Thread::get()->vm()->internalError(L"unable to map %ld bytes", n);
+		Thread::get()->vm()->internalError("unable to map %ld bytes", n);
 	return res;
 }
 
@@ -82,11 +82,11 @@ void BumpAllocator::unmap(void* p, size_
 }
 
 void PermanentObject::operator delete(void* ptr) {
-	Thread::get()->vm()->internalError(L"should not happen");
+	Thread::get()->vm()->internalError("should not happen");
 }
   
 void PermanentObject::operator delete[](void* ptr) {
-	Thread::get()->vm()->internalError(L"should not happen");
+	Thread::get()->vm()->internalError("should not happen");
 }
 
 ThreadAllocator::ThreadAllocator(uintptr_t minThreadStruct, uintptr_t minFullSize) {

Modified: vmkit/branches/mcjit/lib/vmkit/compiler.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/compiler.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/compiler.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/compiler.cc Thu Jan  2 07:32:16 2014
@@ -23,7 +23,7 @@
 using namespace vmkit;
 
 void* Symbol::getSymbolAddress() {
-	Thread::get()->vm()->internalError(L"implement me: getSymbolAddress");
+	Thread::get()->vm()->internalError("implement me: getSymbolAddress");
 }
 
 void* CompilationUnit::operator new(size_t n, BumpAllocator* allocator) {
@@ -54,7 +54,7 @@ CompilationUnit::CompilationUnit(BumpAll
 		.create();
 
 	if (!ee())
-		Thread::get()->vm()->internalError(L"Error while creating execution engine: %s\n", err.c_str());
+		Thread::get()->vm()->internalError("Error while creating execution engine: %s\n", err.c_str());
 
 	ee()->finalizeObject();
 
@@ -125,7 +125,7 @@ Symbol* CompilationUnit::getSymbol(const
 	if(it == _symbolTable.end()) {
 		uint8_t* addr = (uint8_t*)dlsym(SELF_HANDLE, id);
 		if(!addr)
-			Thread::get()->vm()->internalError(L"unable to resolve native symbol: %s", id);
+			Thread::get()->vm()->internalError("unable to resolve native symbol: %s", id);
 		res = new(allocator()) vmkit::NativeSymbol(addr);
 		size_t len = strlen(id);
 		char* buf = (char*)allocator()->allocate(len+1);
@@ -150,7 +150,7 @@ void CompilationUnit::compileModule(llvm
 	vmkit::Safepoint* sf = Safepoint::get(this, module);
 
 	if(!sf)
-		vm()->internalError(L"unable to find safepoints");
+		vm()->internalError("unable to find safepoints");
 		
 	while(sf->addr()) {
 		sf->setUnit(this);

Modified: vmkit/branches/mcjit/lib/vmkit/names.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/names.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/names.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/names.cc Thu Jan  2 07:32:16 2014
@@ -7,30 +7,30 @@ using namespace vmkit;
 
 T_ptr_less_t<const Name*> Name::less;
 
-Name::Name(uint32_t length, const wchar_t* content) {
+Name::Name(size_t length, const char* content) {
 	_length = length;
-	memcpy(_content, content, sizeof(wchar_t)*(length+1));
+	memcpy(_content, content, sizeof(char)*length);
+	_content[length] = 0;
 }
 
 void* Name::operator new(size_t unused, BumpAllocator* allocator, size_t n) {
-	return PermanentObject::operator new(sizeof(Name) + n * sizeof(wchar_t), allocator);
+	return PermanentObject::operator new(sizeof(Name) + n * sizeof(uint8_t), allocator);
 }
 
-Names::Names(BumpAllocator* _allocator) : names(Util::wchar_t_less, _allocator) {
+Names::Names(BumpAllocator* _allocator) : names(Util::char_less, _allocator) {
 	pthread_mutex_init(&mutex, 0);
 	allocator = _allocator;
 }
 
-const Name* Names::get(const wchar_t* str) {
+const Name* Names::get(const char* str, size_t length) {
 	pthread_mutex_lock(&mutex);
-	//printf("---- internalize %ls\n", str);
+	//printf("---- internalize %s\n", str);
 
 	const Name* res;
-	std::map<const wchar_t*, const Name*>::iterator it = names.find(str);
+	std::map<const char*, const Name*>::iterator it = names.find(str);
 
 	if(it == names.end()) {
-		size_t len = wcslen(str);
-		Name* tmp = new(allocator, len) Name(len, str);
+		Name* tmp = new(allocator, length) Name(length, str);
 
 		names[tmp->cStr()] = tmp;
 
@@ -42,38 +42,52 @@ const Name* Names::get(const wchar_t* st
 	return res;
 }
 
+const Name* Names::get(const char* str) {
+	return get(str, strlen(str));
+}
+
 const Name* Names::get(const char* str, size_t start, size_t length) {
 	//printf("%s %lu %lu\n", str, start, length);
 	if(length == -1)
-		length = strlen(str);
-	wchar_t  buf[length + 1];
-	size_t   n = 0;
-	size_t   i = 0;
-
-	while (i < length) {
-		wchar_t x = str[i++];
-		if(x & 0x80) {
-			wchar_t y = str[i++];
-			if (x & 0x20) {
-				wchar_t z = str[i++];
-				x = ((x & 0x0F) << 12) +
-					((y & 0x3F) << 6) +
-					(z & 0x3F);
-			} else {
-				x = ((x & 0x1F) << 6) +
-					(y & 0x3F);
-			}
-		}
-		buf[n++] = x;
+		return get(str+start);
+	else {
+		char buf[length+1];
+		memcpy(buf, str+start, length);
+		buf[length] = 0;
+		return get(buf, length);
 	}
+}
 
-	buf[n] = 0;
+#if 0
+		char buf[length + 1];
+		size_t   n = 0;
+		size_t   i = 0;
+
+		while (i < length) {
+			char x = str[i++];
+			if(x & 0x80) {
+				char y = str[i++];
+				if (x & 0x20) {
+					char z = str[i++];
+					x = ((x & 0x0F) << 12) +
+						((y & 0x3F) << 6) +
+						(z & 0x3F);
+				} else {
+					x = ((x & 0x1F) << 6) +
+						(y & 0x3F);
+				}
+			}
+			buf[n++] = x;
+		}
+		
+		buf[n] = 0;
 
-	return get(buf);
+		return get(buf);
 }
+#endif
 
 const Name* Names::get(char c) {
-	wchar_t buf[2];
+	char buf[2];
 	buf[0] = c;
 	buf[1] = 0;
 	return get(buf);

Modified: vmkit/branches/mcjit/lib/vmkit/util.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/util.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/util.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/util.cc Thu Jan  2 07:32:16 2014
@@ -8,7 +8,6 @@ using namespace vmkit;
 
 struct Util::char_less_t     Util::char_less;
 struct Util::char_less_t_dbg Util::char_less_dbg;
-struct Util::wchar_t_less_t  Util::wchar_t_less;
 
 bool Util::char_less_t::operator()(const char* lhs, const char* rhs) const {
 	//printf("Compare: %s - %s - %d\n", lhs, rhs, strcmp(lhs, rhs));
@@ -20,7 +19,3 @@ bool Util::char_less_t_dbg::operator()(c
 	return strcmp(lhs, rhs) < 0; 
 }
 
-bool Util::wchar_t_less_t::operator()(const wchar_t* lhs, const wchar_t* rhs) const {
-	//printf("Compare: %ls - %ls - %d\n", lhs, rhs, wcscmp(lhs, rhs));
-	return wcscmp(lhs, rhs) < 0;
-}

Modified: vmkit/branches/mcjit/lib/vmkit/vmkit.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/vmkit.cc?rev=198303&r1=198302&r2=198303&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/vmkit.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/vmkit.cc Thu Jan  2 07:32:16 2014
@@ -76,14 +76,14 @@ llvm::LLVMContext& VMKit::llvmContext()
 llvm::Type* VMKit::introspectType(const char* name) {
 	llvm::Type* res = self()->getTypeByName(name);
 	if(!res)
-		internalError(L"unable to find internal type: %s", name);
+		internalError("unable to find internal type: %s", name);
 	return res;
 }
 
 llvm::Function* VMKit::introspectFunction(llvm::Module* dest, const char* name) {
 	llvm::Function* orig = (llvm::Function*)mangleMap[name];
 	if(!orig)
-		internalError(L"unable to find internal function: %s", name);
+		internalError("unable to find internal function: %s", name);
 
 	return (llvm::Function*)dest->getOrInsertFunction(orig->getName(), orig->getFunctionType());
 }
@@ -91,7 +91,7 @@ llvm::Function* VMKit::introspectFunctio
 llvm::GlobalValue* VMKit::introspectGlobalValue(llvm::Module* dest, const char* name) {
 	llvm::GlobalValue* orig = mangleMap[name];
 	if(!orig)
-		internalError(L"unable to find internal global value: %s", name);
+		internalError("unable to find internal global value: %s", name);
 	return (llvm::GlobalValue*)dest->getOrInsertGlobal(orig->getName(), orig->getType());
 }
 
@@ -114,11 +114,11 @@ void VMKit::vmkitBootstrap(Thread* initi
 
 	llvm::OwningPtr<llvm::MemoryBuffer> buf;
 	if (llvm::MemoryBuffer::getFile(selfBitCodePath, buf))
-		VMKit::internalError(L"Error while opening bitcode file %s", selfBitCodePath);
+		VMKit::internalError("Error while opening bitcode file %s", selfBitCodePath);
 	_self = llvm::getLazyBitcodeModule(buf.take(), llvm::getGlobalContext(), &err);
 
 	if(!self())
-		VMKit::internalError(L"Error while reading bitcode file %s: %s", selfBitCodePath, err.c_str());
+		VMKit::internalError("Error while reading bitcode file %s: %s", selfBitCodePath, err.c_str());
 
 	for(llvm::Module::iterator cur=self()->begin(); cur!=self()->end(); cur++)
 		addSymbol(cur);
@@ -132,7 +132,7 @@ void VMKit::vmkitBootstrap(Thread* initi
 	ptrTypeInfo = typeInfoGV ? dlsym(SELF_HANDLE, typeInfoGV->getName().data()) : 0;
 
 	if(!ptrTypeInfo)
-		internalError(L"unable to find typeinfo for void*"); 
+		internalError("unable to find typeinfo for void*"); 
 
 	initialThread->start();
 	initialThread->join();
@@ -143,27 +143,27 @@ llvm::Function* VMKit::getGCRoot(llvm::M
 	return llvm::Intrinsic::getDeclaration(mod, llvm::Intrinsic::gcroot);
 }
 
-void VMKit::log(const wchar_t* msg, ...) {
+void VMKit::log(const char* msg, ...) {
 	va_list va;
 	va_start(va, msg);
 	fprintf(stderr, "[vmkit]: ");
-	vfwprintf(stderr, msg, va);
+	vfprintf(stderr, msg, va);
 	fprintf(stderr, "\n");
 	va_end(va);
 }
 
-void VMKit::vinternalError(const wchar_t* msg, va_list va) {
+void VMKit::vinternalError(const char* msg, va_list va) {
 	defaultInternalError(msg, va);
 }
 
-void VMKit::defaultInternalError(const wchar_t* msg, va_list va) {
+void VMKit::defaultInternalError(const char* msg, va_list va) {
 	fprintf(stderr, "Fatal error: ");
-	vfwprintf(stderr, msg, va);
+	vfprintf(stderr, msg, va);
 	fprintf(stderr, "\n");
 	abort();
 }
 
-void VMKit::internalError(const wchar_t* msg, ...) {
+void VMKit::internalError(const char* msg, ...) {
 	va_list va;
 	va_start(va, msg);
 	if(Thread::get() && Thread::get()->vm())
@@ -176,11 +176,11 @@ void VMKit::internalError(const wchar_t*
 }
 
 void VMKit::sigsegv(uintptr_t addr) {
-	internalError(L"sigsegv at %p", (void*)addr);
+	internalError("sigsegv at %p", (void*)addr);
 }
 
 void VMKit::sigend() {
-	internalError(L"sig terminate");
+	internalError("sig terminate");
 }
 
 static int fake = 0;





More information about the vmkit-commits mailing list