[vmkit-commits] [vmkit] r83315 - in /vmkit/trunk: include/mvm/ lib/N3/Mono/ lib/N3/PNetLib/ lib/N3/VMCore/

Gael Thomas gael.thomas at lip6.fr
Mon Oct 5 10:36:52 PDT 2009


Author: gthomas
Date: Mon Oct  5 12:36:51 2009
New Revision: 83315

URL: http://llvm.org/viewvc/llvm-project?rev=83315&view=rev
Log:
Unify VirtualMachine and N3
Factorize construction of UTF8 in UTF8.h/UTF8.cpp
Use only N3 methods to build array of uint16, utf8 and strings


Removed:
    vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp
    vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
Modified:
    vmkit/trunk/include/mvm/UTF8.h
    vmkit/trunk/lib/N3/Mono/Mono.cpp
    vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp
    vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp
    vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp
    vmkit/trunk/lib/N3/PNetLib/PNetString.cpp
    vmkit/trunk/lib/N3/VMCore/Assembly.cpp
    vmkit/trunk/lib/N3/VMCore/Assembly.h
    vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
    vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp
    vmkit/trunk/lib/N3/VMCore/CLIString.h
    vmkit/trunk/lib/N3/VMCore/LockedMap.cpp
    vmkit/trunk/lib/N3/VMCore/LockedMap.h
    vmkit/trunk/lib/N3/VMCore/MSCorlib.inc
    vmkit/trunk/lib/N3/VMCore/N3.cpp
    vmkit/trunk/lib/N3/VMCore/N3.h
    vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
    vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
    vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
    vmkit/trunk/lib/N3/VMCore/VMArray.cpp
    vmkit/trunk/lib/N3/VMCore/VMArray.h
    vmkit/trunk/lib/N3/VMCore/VMCache.cpp
    vmkit/trunk/lib/N3/VMCore/VMClass.cpp
    vmkit/trunk/lib/N3/VMCore/VMClass.h
    vmkit/trunk/lib/N3/VMCore/VMObject.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.h
    vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp

Modified: vmkit/trunk/include/mvm/UTF8.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/UTF8.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/UTF8.h (original)
+++ vmkit/trunk/include/mvm/UTF8.h Mon Oct  5 12:36:51 2009
@@ -90,6 +90,48 @@
   void insert(const UTF8* val);
 };
 
+class UTF8Builder {
+	uint16 *buf;
+	uint32  cur;
+	uint32  size;
+
+public:
+	UTF8Builder(size_t size) {
+		size = (size < 4) ? 4 : size;
+		this->buf = new uint16[size];
+		this->size = size;
+	}
+
+	UTF8Builder *append(const UTF8 *utf8, uint32 start=0, uint32 length=0xffffffff) {
+		length = length == 0xffffffff ? utf8->size : length;
+		uint32 req = cur + length;
+
+		if(req > size) {
+			uint32 newSize = size<<1;
+			while(req < newSize)
+				newSize <<= 1;
+			uint16 *newBuf = new uint16[newSize];
+			memcpy(newBuf, buf, cur<<1);
+			delete []buf;
+			buf = newBuf;
+			size = newSize;
+		}
+
+		memcpy(buf + cur, &utf8->elements + start, length<<1);
+		cur = req;
+
+		return this;
+	}
+
+	const UTF8 *toUTF8(UTF8Map *map) {
+		return map->lookupOrCreateReader(buf, size);
+	}
+
+	~UTF8Builder() {
+		delete [] buf;
+	}
+};
+
 /// UTF8Buffer - Helper class to create char* buffers suitable for
 /// printf.
 ///

Modified: vmkit/trunk/lib/N3/Mono/Mono.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/Mono.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/Mono/Mono.cpp (original)
+++ vmkit/trunk/lib/N3/Mono/Mono.cpp Mon Oct  5 12:36:51 2009
@@ -110,9 +110,10 @@
 		*int_code_page |= 0x10000000;
 	free (codepage);
 	
-	if (want_name && *int_code_page == -1)
-		return (MonoString*)(((N3*)VMThread::get()->vm)->asciizToStr(cset));
-	else
+	if (want_name && *int_code_page == -1) {
+		N3 *vm = (N3*)VMThread::get()->vm;
+		return (MonoString*)(vm->arrayToString(vm->asciizToArray(cset)));
+	} else
 		return NULL;
 }
 
@@ -157,10 +158,11 @@
 extern "C" MonoString *
 System_Environment_get_NewLine (void)
 {
+	N3 *vm = (N3*)VMThread::get()->vm;
 #if defined (PLATFORM_WIN32)
-	return (MonoString*)((N3*)VMThread::get()->vm)->asciizToStr("\r\n");
+	return (MonoString*)(vm->arrayToString(vm->asciizToArray("\r\n")));
 #else
-	return (MonoString*)((N3*)VMThread::get()->vm)->asciizToStr("\n");
+	return (MonoString*)(vm->arrayToString(vm->asciizToArray("\n")));
 #endif
 }
 
@@ -279,7 +281,7 @@
 extern "C" void
 System_String__ctor(MonoString* str, ArrayUInt16* array, sint32 startIndex, sint32 count) {
   VirtualMachine* vm = VMThread::get()->vm;
-  const UTF8* utf8 = vm->readerConstructUTF8(&(array->elements[startIndex]), count);
+  const UTF8* utf8 = vm->bufToUTF8(&(array->elements[startIndex]), count);
   str->length = count;
   str->startChar = array->elements[startIndex];
   str->value = utf8;
@@ -331,8 +333,8 @@
 	}
   
   N3* vm = (N3*)VMThread::get()->vm;
-  const UTF8* utf8 = vm->readerConstructUTF8(dest, length);
-	return (MonoString*)vm->UTF8ToStr(utf8);
+  const ArrayUInt16* array = vm->bufToArray(dest, length);
+	return (MonoString*)vm->arrayToString(array);
 }
 
 extern "C" MonoString *

Modified: vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp (original)
+++ vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp Mon Oct  5 12:36:51 2009
@@ -21,8 +21,8 @@
 
 void MSCorlib::loadStringClass(N3* vm) {
   VMClass* type = (VMClass*)vm->coreAssembly->loadTypeFromName(
-                                           vm->asciizConstructUTF8("String"),
-                                           vm->asciizConstructUTF8("System"),
+                                           vm->asciizToUTF8("String"),
+                                           vm->asciizToUTF8("System"),
                                            false, false, false, true);
   MSCorlib::pString = type;
   MSCorlib::pObject->resolveType(true, false, NULL);
@@ -43,8 +43,8 @@
   VMClass* realClrType = 0;
   #define INIT(var, nameSpace, name, type, prim) {\
   var = (VMClass*)vm->coreAssembly->loadTypeFromName( \
-                                           vm->asciizConstructUTF8(name),     \
-                                           vm->asciizConstructUTF8(nameSpace),\
+                                           vm->asciizToUTF8(name),     \
+                                           vm->asciizToUTF8(nameSpace),\
                                            false, false, false, true); \
   var->isPrimitive = prim; \
   if (type) { \
@@ -65,7 +65,7 @@
   
   {
   MSCorlib::clrType->resolveType(false, false, NULL);
-  MSCorlib::typeClrType = realClrType->lookupField(vm->asciizConstructUTF8("_impl"), runtimeTypeHandle, false, false);
+  MSCorlib::typeClrType = realClrType->lookupField(vm->asciizToUTF8("_impl"), runtimeTypeHandle, false, false);
   }
 
 /*
@@ -74,8 +74,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::assemblyReflection);
-  MSCorlib::ctorAssemblyReflection = MSCorlib::assemblyReflection->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::assemblyAssemblyReflection = MSCorlib::assemblyReflection->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorAssemblyReflection = MSCorlib::assemblyReflection->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::assemblyAssemblyReflection = MSCorlib::assemblyReflection->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
   
   {
@@ -83,8 +83,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::propertyType);
-  MSCorlib::ctorPropertyType = MSCorlib::propertyType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::propertyPropertyType = MSCorlib::propertyType->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorPropertyType = MSCorlib::propertyType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::propertyPropertyType = MSCorlib::propertyType->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
   
   {
@@ -92,8 +92,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::methodType);
-  MSCorlib::ctorMethodType = MSCorlib::methodType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::methodMethodType = MSCorlib::methodType->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorMethodType = MSCorlib::methodType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::methodMethodType = MSCorlib::methodType->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
   
   {
@@ -104,13 +104,13 @@
   args.push_back(MSCorlib::pIntPtr);
   args.push_back(MSCorlib::pSInt64);
   args.push_back(MSCorlib::pSInt64);
-  MSCorlib::ctorResourceStreamType = MSCorlib::resourceStreamType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
+  MSCorlib::ctorResourceStreamType = MSCorlib::resourceStreamType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
   }
   
   VMCommonClass* voidPtr = vm->coreAssembly->constructPointer(MSCorlib::pVoid, 1);
 #define INIT(var, cl, type) {\
     cl->resolveType(false, false); \
-    var = cl->lookupField(vm->asciizConstructUTF8("value_"), type, false, false); \
+    var = cl->lookupField(vm->asciizToUTF8("value_"), type, false, false); \
   }
   
   INIT(MSCorlib::ctorBoolean,  MSCorlib::pBoolean, MSCorlib::pBoolean);
@@ -164,8 +164,8 @@
 
 void MSCorlib::loadBootstrap(N3* vm) {
   VMClass* cl = (VMClass*)vm->coreAssembly->loadTypeFromName(
-                                        vm->asciizConstructUTF8("Thread"),
-                                        vm->asciizConstructUTF8("System.Threading"),
+                                        vm->asciizToUTF8("Thread"),
+                                        vm->asciizToUTF8("System.Threading"),
                                         true, true, true, true);
   VMObject* th = (*cl)();
   VMThread* myth = VMThread::get();

Modified: vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp Mon Oct  5 12:36:51 2009
@@ -45,6 +45,7 @@
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"
+#include "CLIString.h"
 
 #include "PNetPath.inc"
 
@@ -164,16 +165,16 @@
   char* val = ILGetCultureName();
   N3* vm = (N3*)(VMThread::get()->vm);
   if (val) {
-    VMObject* ret = vm->asciizToStr(val);
+    VMObject* ret = vm->arrayToString(vm->asciizToArray(val));
     free(val);
     return ret;
   } else {
-    VMObject* ret = vm->asciizToStr("iv");
+    VMObject* ret = vm->arrayToString(vm->asciizToArray("iv"));
     return ret;
   }
 }
 
-static const UTF8* newBuilder(N3* vm, PNetString* value, uint32 length) {
+static const ArrayUInt16* newBuilder(N3* vm, PNetString* value, uint32 length) {
   uint32 valueLength = value ? value->length : 0;
   const UTF8* utf8 = value ? value->value : 0;
   uint32 roundLength = (7 + length) & 0xfffffff8;
@@ -190,20 +191,19 @@
     }
   }
 
-  return vm->readerConstructUTF8(buf, strLength);
-
+  return vm->bufToArray(buf, strLength);
 }
 
 extern "C" VMObject* System_String_NewBuilder(PNetString* value, 
                                                uint32 length) {
   N3* vm = (N3*)(VMThread::get()->vm);
-  PNetString* str = (PNetString*)vm->UTF8ToStr(newBuilder(vm, value, length));
+  PNetString* str = (PNetString*)vm->arrayToString(newBuilder(vm, value, length));
   return str;
 }
 
 extern "C" VMObject* Platform_SysCharInfo_GetNewLine() {
   N3* vm = (N3*)(VMThread::get()->vm);
-  return vm->asciizToStr("\n");
+  return vm->arrayToString(vm->asciizToArray("\n"));
 }
 
 extern "C" void System_String_CopyToChecked(PNetString* str, sint32 sstart, 
@@ -297,7 +297,7 @@
     memcpy(buf, utf8Dest->elements, len1 * sizeof(uint16));
     memcpy(buf + len1, utf8Dest->elements, len2 * sizeof(uint16));
 
-    const UTF8* utf8 = VMThread::get()->vm->readerConstructUTF8(buf, 
+    const UTF8* utf8 = VMThread::get()->vm->bufToUTF8(buf, 
                                                                 len1 + len2);
     dest->value = utf8;
     dest->length = dest->value->size;
@@ -375,7 +375,7 @@
   }
 
   buf[index] = value;
-  PNetString* str = (PNetString*)vm->UTF8ToStr(vm->readerConstructUTF8(buf, length));
+  PNetString* str = (PNetString*)vm->arrayToString(vm->bufToArray(buf, length));
   obj->buildString = str;
   
   return obj;
@@ -407,7 +407,7 @@
                (buildLength - index) * sizeof(uint16));
   }
 
-  PNetString* val = (PNetString*)vm->UTF8ToStr(vm->readerConstructUTF8(buf, length));
+  PNetString* val = (PNetString*)vm->arrayToString(vm->bufToArray(buf, length));
   obj->buildString = val;
 
   return obj;
@@ -425,7 +425,7 @@
   memcpy(buf, utf8->elements, length * sizeof(uint16));
 
   buf[length] = value;
-  PNetString* val = (PNetString*)vm->UTF8ToStr(vm->readerConstructUTF8(buf, length + 1));
+  PNetString* val = (PNetString*)vm->arrayToString(vm->bufToArray(buf, length + 1));
   obj->buildString = val;
   return obj;
 }
@@ -446,7 +446,7 @@
   memcpy(buf, buildUtf8->elements, buildLength * sizeof(uint16));
   memcpy(&(buf[buildLength]), strUtf8->elements, strLength * sizeof(uint16));
 
-  PNetString* val = (PNetString*)vm->UTF8ToStr(vm->readerConstructUTF8(buf, length));
+  PNetString* val = (PNetString*)vm->arrayToString(vm->bufToArray(buf, length));
   obj->buildString = val;
   return obj;
 }
@@ -522,7 +522,7 @@
   memcpy(buf, u1->elements, len1 * sizeof(uint16));
   memcpy(&(buf[len1]), u2->elements, len2 * sizeof(uint16));
   
-  PNetString* val = (PNetString*)vm->UTF8ToStr(vm->readerConstructUTF8(buf, len1 + len2));
+  PNetString* val = (PNetString*)vm->arrayToString(vm->bufToArray(buf, len1 + len2));
   
   return val;
 }
@@ -541,7 +541,7 @@
   memcpy(&(buf[len1]), u2->elements, len2 * sizeof(uint16));
   memcpy(&(buf[len1 + len2]), u3->elements, len3 * sizeof(uint16));
   
-  PNetString* val = (PNetString*)vm->UTF8ToStr(vm->readerConstructUTF8(buf, len1 + len2 + len3));
+  PNetString* val = (PNetString*)vm->arrayToString(vm->bufToArray(buf, len1 + len2 + len3));
   
   return val;
 }
@@ -570,7 +570,7 @@
     memcpy(&(buf[j]), &(utf8->elements[index + length]), (strLength - (index + length)) * sizeof(uint16));
   }
 
-  const UTF8* res = VMThread::get()->vm->readerConstructUTF8(buf, j);
+  const UTF8* res = VMThread::get()->vm->bufToUTF8(buf, j);
   str->value = res;
   str->length = j;
 }
@@ -581,7 +581,7 @@
     array->elements[i] = ch;
   }
 
-  const UTF8* utf8 = VMThread::get()->vm->readerConstructUTF8(array->elements, array->size);
+  const UTF8* utf8 = VMThread::get()->vm->bufToUTF8(array->elements, array->size);
   str->value = utf8;
   str->length = array->size;
   str->capacity = array->size;
@@ -610,7 +610,7 @@
   
   index[0] = 0;
   ++index;
-  VMCommonClass* cl = ass->loadTypeFromName(vm->asciizConstructUTF8(index), vm->asciizConstructUTF8(asciiz), true, true, true, onError);
+  VMCommonClass* cl = ass->loadTypeFromName(vm->asciizToUTF8(index), vm->asciizToUTF8(asciiz), true, true, true, onError);
   if (!cl) VMThread::get()->vm->error("implement me");
   return cl->getClassDelegatee();
 }
@@ -679,8 +679,8 @@
       char* asciiz = prop->name->UTF8ToAsciiz();
       char* buf = (char*)alloca(strlen(asciiz) + 5);
       sprintf(buf, "get_%s", asciiz);
-      VirtualMachine* vm = VMThread::get()->vm;
-      VMMethod* meth = prop->type->lookupMethod(vm->asciizConstructUTF8(buf), prop->parameters, true, false);
+      N3* vm = VMThread::get()->vm;
+      VMMethod* meth = prop->type->lookupMethod(vm->asciizToUTF8(buf), prop->parameters, true, false);
       assert(meth);
       return meth->getMethodDelegatee();
     }
@@ -880,7 +880,7 @@
   uint32 manRows   = manTable->rowsNumber;
   sint32 pos = -1;
   uint32 i = 0;
-  VirtualMachine* vm = VMThread::get()->vm;
+  N3* vm = VMThread::get()->vm;
   
   while ((pos == -1) && (i < manRows)) {
     uint32 nameOffset = manTable->readIndexInRow(i + 1, CONSTANT_MANIFEST_RESOURCE_NAME, ass->bytes);
@@ -912,12 +912,12 @@
 
   uint16* buf = (uint16*)alloca(length * sizeof(uint16));
 
-  VirtualMachine* vm = VMThread::get()->vm;
+  N3* vm = VMThread::get()->vm;
 
   memcpy(buf, utf8->elements, length * sizeof(uint16));
   ILUnicodeStringToLower((void*)buf, (void*)utf8->elements, length);
-  const UTF8* res = vm->readerConstructUTF8(buf, length);
-  return ((N3*)vm)->UTF8ToStr(res);
+  const ArrayUInt16* res = vm->bufToArray(buf, length);
+  return ((N3*)vm)->arrayToString(res);
 }
 
 extern "C" VMObject* System_String_Replace(PNetString* str, uint16 c1, uint16 c2) {
@@ -932,8 +932,8 @@
   }
   
   N3* vm = (N3*)VMThread::get()->vm;
-  const UTF8* res = vm->readerConstructUTF8(buf, length);
-  return vm->UTF8ToStr(res);
+  const ArrayUInt16* res = vm->bufToArray(buf, length);
+  return vm->arrayToString(res);
 }
 
 extern "C" uint32 System_Reflection_ClrResourceStream_ResourceRead(Assembly* assembly, uint64 position, ArrayUInt8* buffer, uint32 offset, uint32 count) {
@@ -991,8 +991,8 @@
     buf[i + start] = ch;
   }
   
-  VirtualMachine* vm = VMThread::get()->vm;
-  const UTF8* val = vm->readerConstructUTF8(buf, length);
+  N3* vm = VMThread::get()->vm;
+  const UTF8* val = vm->bufToUTF8(buf, length);
   str->value = val;
   str->length = length;
 }

Modified: vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp Mon Oct  5 12:36:51 2009
@@ -21,8 +21,8 @@
 
 void MSCorlib::loadStringClass(N3* vm) {
   VMClass* type = (VMClass*)vm->coreAssembly->loadTypeFromName(
-                                           vm->asciizConstructUTF8("String"),
-                                           vm->asciizConstructUTF8("System"),
+                                           vm->asciizToUTF8("String"),
+                                           vm->asciizToUTF8("System"),
                                            false, false, false, true);
   MSCorlib::pString = type;
   MSCorlib::pObject->resolveType(true, false, NULL);
@@ -40,8 +40,8 @@
 void MSCorlib::initialise(N3* vm) {
   #define INIT(var, nameSpace, name, type, prim) {\
   var = (VMClass*)vm->coreAssembly->loadTypeFromName( \
-                                           vm->asciizConstructUTF8(name),     \
-                                           vm->asciizConstructUTF8(nameSpace),\
+                                           vm->asciizToUTF8(name),     \
+                                           vm->asciizToUTF8(nameSpace),\
                                            false, false, false, true); \
   var->isPrimitive = prim; \
   if (type) { \
@@ -63,8 +63,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::clrType);
-  MSCorlib::ctorClrType = MSCorlib::clrType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::typeClrType = MSCorlib::clrType->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorClrType = MSCorlib::clrType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::typeClrType = MSCorlib::clrType->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
 
   {
@@ -72,8 +72,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::assemblyReflection);
-  MSCorlib::ctorAssemblyReflection = MSCorlib::assemblyReflection->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::assemblyAssemblyReflection = MSCorlib::assemblyReflection->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorAssemblyReflection = MSCorlib::assemblyReflection->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::assemblyAssemblyReflection = MSCorlib::assemblyReflection->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
   
   {
@@ -81,8 +81,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::propertyType);
-  MSCorlib::ctorPropertyType = MSCorlib::propertyType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::propertyPropertyType = MSCorlib::propertyType->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorPropertyType = MSCorlib::propertyType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::propertyPropertyType = MSCorlib::propertyType->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
   
   {
@@ -90,8 +90,8 @@
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::methodType);
-  MSCorlib::ctorMethodType = MSCorlib::methodType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
-  MSCorlib::methodMethodType = MSCorlib::methodType->lookupField(vm->asciizConstructUTF8("privateData"), MSCorlib::pIntPtr, false, false);
+  MSCorlib::ctorMethodType = MSCorlib::methodType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
+  MSCorlib::methodMethodType = MSCorlib::methodType->lookupField(vm->asciizToUTF8("privateData"), MSCorlib::pIntPtr, false, false);
   }
   
   {
@@ -102,13 +102,13 @@
   args.push_back(MSCorlib::pIntPtr);
   args.push_back(MSCorlib::pSInt64);
   args.push_back(MSCorlib::pSInt64);
-  MSCorlib::ctorResourceStreamType = MSCorlib::resourceStreamType->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, false, false);
+  MSCorlib::ctorResourceStreamType = MSCorlib::resourceStreamType->lookupMethod(vm->asciizToUTF8(".ctor"), args, false, false);
   }
   
   VMCommonClass* voidPtr = vm->coreAssembly->constructPointer(MSCorlib::pVoid, 1);
 #define INIT(var, cl, type) {\
     cl->resolveType(false, false, NULL); \
-    var = cl->lookupField(vm->asciizConstructUTF8("value_"), type, false, false); \
+    var = cl->lookupField(vm->asciizToUTF8("value_"), type, false, false); \
   }
   
   INIT(MSCorlib::ctorBoolean,  MSCorlib::pBoolean, MSCorlib::pBoolean);
@@ -169,15 +169,15 @@
 
 static void mapInitialThread(N3* vm) {
   VMClass* cl = (VMClass*)vm->coreAssembly->loadTypeFromName(
-                                        vm->asciizConstructUTF8("Thread"),
-                                        vm->asciizConstructUTF8("System.Threading"),
+                                        vm->asciizToUTF8("Thread"),
+                                        vm->asciizToUTF8("System.Threading"),
                                         true, true, true, true);
   VMObject* th = (*cl)();
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(cl);
   args.push_back(MSCorlib::pIntPtr);
-  VMMethod* meth = cl->lookupMethod(vm->asciizConstructUTF8(".ctor"), args, 
+  VMMethod* meth = cl->lookupMethod(vm->asciizToUTF8(".ctor"), args, 
                                     false, false);
   VMThread* myth = VMThread::get();
   (*meth)(th, myth);

Modified: vmkit/trunk/lib/N3/PNetLib/PNetString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetString.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetString.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetString.cpp Mon Oct  5 12:36:51 2009
@@ -37,18 +37,18 @@
   return obj;
 }
 
-char* CLIString::strToAsciiz() {
-  return ((PNetString*)this)->value->UTF8ToAsciiz();
+const UTF8* CLIString::strToUTF8(N3* vm) {
+  return (UTF8*)((PNetString*)this)->value;
 }
 
-const UTF8* CLIString::strToUTF8(N3* vm) {
-  return ((PNetString*)this)->value;
+ArrayUInt16* CLIString::strToArray(N3* vm) const {
+  return (ArrayUInt16*)((PNetString*)this)->value;
 }
 
 GlobalVariable* CLIString::llvmVar() {
   PNetString* str = (PNetString*)this;
   if (!str->_llvmVar) {
-    VirtualMachine* vm = VMThread::get()->vm;
+    N3* vm = VMThread::get()->vm;
     if (!str->_llvmVar) {
       const Type* pty = mvm::MvmModule::ptrType;
       Constant* cons = 

Modified: vmkit/trunk/lib/N3/VMCore/Assembly.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Assembly.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Assembly.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Assembly.cpp Mon Oct  5 12:36:51 2009
@@ -18,7 +18,6 @@
 #include "MSCorlib.h"
 #include "N3.h"
 #include "Reader.h"
-#include "VirtualMachine.h"
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"
@@ -702,13 +701,13 @@
   }
 }
 
-const UTF8* Assembly::readUTF16(VirtualMachine* vm, uint32 len, 
+const ArrayUInt16* Assembly::readUTF16(N3* vm, uint32 len, 
                                 Reader* reader) {
   return readUTF16(vm, len, reader->bytes, reader->cursor);
 }
 
-const UTF8* Assembly::readUTF16(VirtualMachine* vm, uint32 len, 
-                                ArrayUInt8* bytes, uint32 &offset) {
+const ArrayUInt16* Assembly::readUTF16(N3* vm, uint32 len, 
+																			 ArrayUInt8* bytes, uint32 &offset) {
   uint32 realLen = len >> 1;
   uint16* buf = (uint16*)alloca(len);
   uint32 i = 0;
@@ -717,16 +716,14 @@
     buf[i] = cur;
     ++i;
   }
-  const UTF8* utf8 = UTF8::readerConstruct(vm, buf, realLen);
-
-  return utf8;
+	return vm->bufToArray(buf, realLen); 
 }
 
-const UTF8* Assembly::readUTF8(VirtualMachine* vm, uint32 len, Reader* reader) {
+const UTF8* Assembly::readUTF8(N3* vm, uint32 len, Reader* reader) {
   return readUTF8(vm, len, reader->bytes, reader->cursor);
 }
 
-const UTF8* Assembly::readUTF8(VirtualMachine* vm, uint32 len,
+const UTF8* Assembly::readUTF8(N3* vm, uint32 len,
                                ArrayUInt8* bytes, uint32 &offset) {
   uint16* buf = (uint16*)alloca(len * sizeof(uint16));
   uint32 n = 0;
@@ -759,7 +756,7 @@
   return utf8;
 }
 
-const UTF8* Assembly::readString(VirtualMachine* vm, uint32 offset) {
+const UTF8* Assembly::readString(N3* vm, uint32 offset) {
   uint32 end = offset;
   uint32 cur = 0;
   while ((cur = READ_U1(bytes, end)) != 0) {}
@@ -1840,7 +1837,7 @@
   return NULL;
 }
 
-const UTF8* Assembly::readUserString(uint32 token) {
+const ArrayUInt16* Assembly::readUserString(uint32 token) {
   uint32 offset = CLIHeader->usStream->realOffset + token;
 
   uint8 size = READ_U1(bytes, offset);
@@ -1855,8 +1852,7 @@
     }
   }
 
-  const UTF8* res = readUTF16((N3*)(VMThread::get()->vm), size, bytes, offset);
-  return res;
+  return readUTF16((N3*)(VMThread::get()->vm), size, bytes, offset);
 }
 
 uint32 Assembly::getRVAFromField(uint32 token) {

Modified: vmkit/trunk/lib/N3/VMCore/Assembly.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Assembly.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Assembly.h (original)
+++ vmkit/trunk/lib/N3/VMCore/Assembly.h Mon Oct  5 12:36:51 2009
@@ -28,6 +28,7 @@
 
 namespace n3 {
 
+class ArrayUInt16;
 class ArrayUInt8;
 class ArrayObject;
 class Assembly;
@@ -40,7 +41,6 @@
 class Property;
 class Reader;
 class UTF8;
-class VirtualMachine;
 class VMClass;
 class VMGenericClass;
 class VMClassArray;
@@ -187,13 +187,13 @@
 
 	Assembly(mvm::BumpPtrAllocator &Alloc, const UTF8* name);
 
-  static const UTF8* readUTF8(VirtualMachine* vm, uint32 len, Reader* reader);
-  static const UTF8* readUTF16(VirtualMachine* vm, uint32 len, Reader* reader);
-  static const UTF8* readUTF8(VirtualMachine* vm, uint32 len, ArrayUInt8* bytes,
+  static const UTF8* readUTF8(N3* vm, uint32 len, Reader* reader);
+  static const UTF8* readUTF8(N3* vm, uint32 len, ArrayUInt8* bytes,
                               uint32& offset);
-  static const UTF8* readUTF16(VirtualMachine* vm, uint32 len, 
-                               ArrayUInt8* bytes, uint32& offset);
-  const UTF8* readString(VirtualMachine* vm, uint32 offset);
+  static const ArrayUInt16* readUTF16(N3* vm, uint32 len, Reader* reader);
+  static const ArrayUInt16* readUTF16(N3* vm, uint32 len, 
+																			ArrayUInt8* bytes, uint32& offset);
+  const UTF8*        readString(N3* vm, uint32 offset);
   void read();
   void readTables(Reader* reader);
 
@@ -253,7 +253,7 @@
   uint32 getTypedefTokenFromMethod(uint32 token);
   VMMethod* readMemberRefAsMethod(uint32 token, std::vector<VMCommonClass*>* genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod);
 
-  const UTF8* readUserString(uint32 token); 
+  const ArrayUInt16* readUserString(uint32 token); 
   uint32 getExplicitLayout(uint32 token);
   uint32 getRVAFromField(uint32 token);
   

Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Mon Oct  5 12:36:51 2009
@@ -25,7 +25,6 @@
 #include "N3.h"
 #include "N3ModuleProvider.h"
 #include "Reader.h"
-#include "VirtualMachine.h"
 #include "VMArray.h"
 #include "VMCache.h"
 #include "VMClass.h"
@@ -478,12 +477,12 @@
 
   if (meth->classDef->isArray) {
     uint8 func = 0;
-    VirtualMachine* vm = VMThread::get()->vm;
-    if (meth->name == vm->asciizConstructUTF8("Set")) {
+    N3* vm = VMThread::get()->vm;
+    if (meth->name == vm->asciizToUTF8("Set")) {
       func = 0;
-    } else if (meth->name == vm->asciizConstructUTF8("Get")) {
+    } else if (meth->name == vm->asciizToUTF8("Get")) {
       func = 1;
-    } else if (meth->name == vm->asciizConstructUTF8("Address")) {
+    } else if (meth->name == vm->asciizToUTF8("Address")) {
       func = 2;
     } else {
       vm->error("implement me %s", meth->name->printString());

Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Mon Oct  5 12:36:51 2009
@@ -19,7 +19,7 @@
 #include "CLIAccess.h"
 #include "CLIJit.h"
 #include "CLIString.h"
-#include "VirtualMachine.h"
+#include "N3.h"
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"

Modified: vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp Mon Oct  5 12:36:51 2009
@@ -53,10 +53,9 @@
   assert(0 && "implement index out of bounds exception");
 }
 
-extern "C" VMObject* newString(const UTF8* utf8) {
-  CLIString * str = 
-    (CLIString*)(((N3*)VMThread::get()->vm)->UTF8ToStr(utf8));
-  return str;
+extern "C" VMObject* newString(const ArrayUInt16* utf8) {
+	N3 *vm = (N3*)VMThread::get()->vm;
+  return vm->arrayToString(utf8);
 }
 
 extern "C" bool n3InstanceOf(VMObject* obj, VMCommonClass* cl) {
@@ -147,7 +146,7 @@
                                     strlen(nameAsciiz) + 
                                     strlen(nameSpaceAsciiz));
       sprintf(buf, "%s.%s.%s", nameSpaceAsciiz, nameAsciiz, methAsciiz);
-      const UTF8* newName = VMThread::get()->vm->asciizConstructUTF8(buf);
+      const UTF8* newName = VMThread::get()->vm->asciizToUTF8(buf);
       dmeth = ocl->lookupMethod(newName, orig->parameters, false, true);
     }
     

Modified: vmkit/trunk/lib/N3/VMCore/CLIString.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIString.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIString.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIString.h Mon Oct  5 12:36:51 2009
@@ -21,6 +21,7 @@
 
 class UTF8;
 class N3;
+class ArrayUInt16;
 
 class CLIString : public VMObject {
 public:
@@ -34,9 +35,8 @@
 
   
   static CLIString* stringDup(const UTF8*& utf8, N3* vm);
-  char* strToAsciiz();
-  const UTF8* strToUTF8(N3* vm);
-
+  const  UTF8* strToUTF8(N3* vm);
+	ArrayUInt16 *strToArray(N3 *vm) const;
 };
 
 } // end namespace jnjvm

Modified: vmkit/trunk/lib/N3/VMCore/LockedMap.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LockedMap.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/LockedMap.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/LockedMap.cpp Mon Oct  5 12:36:51 2009
@@ -19,97 +19,3 @@
 #include <string.h>
 
 using namespace n3;
-
-
-static uint32 asciizHasher(const char* asciiz, sint32 size) {
-  uint32 r0 = 0, r1 = 0;
-  for (sint32 i = 0; i < size; i++) {
-    char c = asciiz[i];
-    r0 += c;
-    r1 ^= c;
-  }
-  return (r1 & 255) + ((r0 & 255) << 8);
-}
-
-static uint32 readerHasher(const uint16* buf, sint32 size) {
-  uint32 r0 = 0, r1 = 0;
-  for (sint32 i = 0; i < size; i++) {
-    uint16 c = buf[i];
-    r0 += c;
-    r1 ^= c;
-  }
-  return (r1 & 255) + ((r0 & 255) << 8);
-}
-
-static bool asciizEqual(const UTF8* val, const char* asciiz, sint32 size) {
-  sint32 len = val->size;
-  if (len != size) return false;
-  else {
-    for (sint32 i = 0; i < len; i++) {
-      if (asciiz[i] != val->at(i)) return false;
-    }
-    return true;
-  }
-}
-
-static bool readerEqual(const UTF8* val, const uint16* buf, sint32 size) {
-  sint32 len = val->size;
-  if (len != size) return false;
-  else return !(memcmp(val->elements, buf, len * sizeof(uint16)));
-}
-
-
-const UTF8* UTF8Map::lookupOrCreateAsciiz(const char* asciiz) {
-  sint32 size = strlen(asciiz);
-  uint32 key = asciizHasher(asciiz, size);
-  const UTF8* res = 0;
-  lock->lock();
-  
-  std::pair<UTF8Map::iterator, UTF8Map::iterator> p = map.equal_range(key);
-  
-  for (UTF8Map::iterator i = p.first; i != p.second; i++) {
-    if (asciizEqual(i->second, asciiz, size)) {
-      res = i->second;
-      break;
-    }
-  }
-
-  if (res == 0) {
-    UTF8* tmp = (UTF8 *)UTF8::acons(size, MSCorlib::arrayChar);
-    for (sint32 i = 0; i < size; i++) {
-      tmp->setAt(i, asciiz[i]);
-    }
-    res = (const UTF8*)tmp;
-    map.insert(std::make_pair(key, res));
-  }
-  
-  lock->unlock();
-  return res;
-}
-
-const UTF8* UTF8Map::lookupOrCreateReader(const uint16* buf, uint32 len) {
-  sint32 size = (sint32)len;
-  uint32 key = readerHasher(buf, size);
-  const UTF8* res = 0;
-  lock->lock();
-  
-  std::pair<UTF8Map::iterator, UTF8Map::iterator> p = map.equal_range(key);
-
-  for (UTF8Map::iterator i = p.first; i != p.second; i++) {
-    if (readerEqual(i->second, buf, size)) {
-      res = i->second;
-      break;
-    }
-  }
-
-  if (res == 0) {
-    UTF8* tmp = UTF8::acons(size, MSCorlib::arrayChar);
-    memcpy(tmp->elements, buf, len * sizeof(uint16));
-    res = (const UTF8*)tmp;
-    map.insert(std::make_pair(key, res));
-  }
-  
-  lock->unlock();
-  return res;
-}
-

Modified: vmkit/trunk/lib/N3/VMCore/LockedMap.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LockedMap.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/LockedMap.h (original)
+++ vmkit/trunk/lib/N3/VMCore/LockedMap.h Mon Oct  5 12:36:51 2009
@@ -24,6 +24,8 @@
 #include "CLIString.h"
 #include "VMArray.h"
 
+#include "UTF8.h"
+
 namespace n3 {
 
 class Assembly;
@@ -158,35 +160,6 @@
 	FunctionMap() : LockedMap<llvm::Function*, VMMethod, std::less<llvm::Function*>, N3 >(new mvm::LockNormal()) {}
 };
 
-
-
-class UTF8Map : public mvm::PermanentObject {
-public:
-  typedef std::multimap<const uint32, const UTF8*>::iterator iterator;
-  
-  mvm::Lock* lock;
-  std::multimap<uint32, const UTF8*, std::less<uint32>,
-                gc_allocator<std::pair<const uint32, const UTF8*> > > map;
-
-  const UTF8* lookupOrCreateAsciiz(const char* asciiz); 
-  const UTF8* lookupOrCreateReader(const uint16* buf, uint32 size);
-  
-  UTF8Map() {
-    lock = new mvm::LockNormal();
-  }
-  
-  virtual void TRACER {
-    //lock->MARK_AND_TRACE;
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->MARK_AND_TRACE;
-    }
-  }
-
-  virtual void print(mvm::PrintBuffer* buf) const {
-    buf->write("UTF8 Hashtable<>");
-  }
-};
-
 } // end namespace n3
 
 #endif

Modified: vmkit/trunk/lib/N3/VMCore/MSCorlib.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/MSCorlib.inc?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/MSCorlib.inc (original)
+++ vmkit/trunk/lib/N3/VMCore/MSCorlib.inc Mon Oct  5 12:36:51 2009
@@ -86,7 +86,7 @@
   // The caller of the CLI function;
   cur = (void**)cur[0];
  
-  VirtualMachine* vm = VMThread::get()->vm;
+  N3* vm = VMThread::get()->vm;
 
   VMMethod* meth = vm->IPToMethod<VMMethod>(FRAME_IP(cur));
 
@@ -105,7 +105,7 @@
   // The CLI function.
   cur = (void**)cur[0];
   
-  VirtualMachine* vm = VMThread::get()->vm;
+  N3* vm = VMThread::get()->vm;
 
   VMMethod* meth = vm->IPToMethod<VMMethod>(FRAME_IP(cur));
 

Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.cpp Mon Oct  5 12:36:51 2009
@@ -8,42 +8,184 @@
 //===----------------------------------------------------------------------===//
 
 
-#include "llvm/LLVMContext.h"
+#include <vector>
+#include <stdarg.h>
+
+#include "llvm/Function.h"
 #include "llvm/Module.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/Support/CommandLine.h"
 
+#include "mvm/Object.h"
+#include "mvm/PrintBuffer.h"
+#include "mvm/Threads/Cond.h"
+#include "mvm/Threads/Locks.h"
 #include "mvm/JIT.h"
 
 #include "types.h"
+
 #include "Assembly.h"
-#include "CLIJit.h"
-#include "CLIString.h"
 #include "LinkN3Runtime.h"
 #include "LockedMap.h"
 #include "MSCorlib.h"
 #include "N3.h"
 #include "N3ModuleProvider.h"
 #include "Reader.h"
-#include "VirtualMachine.h"
+#include "VMArray.h"
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"
+#include "CLIJit.h"
+#include "CLIString.h"
+
 
 using namespace n3;
 
-void N3::print(mvm::PrintBuffer* buf) const {
-  buf->write("N3 virtual machine<>");
+#define DECLARE_EXCEPTION(EXCP) \
+  const char* N3::EXCP = #EXCP
+
+DECLARE_EXCEPTION(SystemException);
+DECLARE_EXCEPTION(OverFlowException);
+DECLARE_EXCEPTION(OutOfMemoryException);
+DECLARE_EXCEPTION(IndexOutOfRangeException);
+DECLARE_EXCEPTION(NullReferenceException);
+DECLARE_EXCEPTION(SynchronizationLocException);
+DECLARE_EXCEPTION(ThreadInterruptedException);
+DECLARE_EXCEPTION(MissingMethodException);
+DECLARE_EXCEPTION(MissingFieldException);
+DECLARE_EXCEPTION(ArrayTypeMismatchException);
+DECLARE_EXCEPTION(ArgumentException);
+
+/*
+DECLARE_EXCEPTION(ArithmeticException);
+DECLARE_EXCEPTION(InvocationTargetException);
+DECLARE_EXCEPTION(ArrayStoreException);
+DECLARE_EXCEPTION(ClassCastException);
+DECLARE_EXCEPTION(ArrayIndexOutOfBoundsException);
+DECLARE_EXCEPTION(SecurityException);
+DECLARE_EXCEPTION(ClassFormatError);
+DECLARE_EXCEPTION(ClassCircularityError);
+DECLARE_EXCEPTION(NoClassDefFoundError);
+DECLARE_EXCEPTION(UnsupportedClassVersionError);
+DECLARE_EXCEPTION(NoSuchFieldError);
+DECLARE_EXCEPTION(NoSuchMethodError);
+DECLARE_EXCEPTION(InstantiationError);
+DECLARE_EXCEPTION(IllegalAccessError);
+DECLARE_EXCEPTION(IllegalAccessException);
+DECLARE_EXCEPTION(VerifyError);
+DECLARE_EXCEPTION(ExceptionInInitializerError);
+DECLARE_EXCEPTION(LinkageError);
+DECLARE_EXCEPTION(AbstractMethodError);
+DECLARE_EXCEPTION(UnsatisfiedLinkError);
+DECLARE_EXCEPTION(InternalError);
+DECLARE_EXCEPTION(StackOverflowError);
+DECLARE_EXCEPTION(ClassNotFoundException);
+*/
+
+#undef DECLARE_EXCEPTION
+
+void ThreadSystem::print(mvm::PrintBuffer* buf) const {
+  buf->write("ThreadSystem<>");
+}
+
+ThreadSystem* ThreadSystem::allocateThreadSystem() {
+  ThreadSystem* res = gc_new(ThreadSystem)();
+  res->nonDaemonThreads = 1;
+  res->nonDaemonLock = new mvm::LockNormal();
+  res->nonDaemonVar  = new mvm::Cond();
+  return res;
 }
 
-VMObject* N3::asciizToStr(const char* asciiz) {
-  const UTF8* var = asciizConstructUTF8(asciiz);
-  return UTF8ToStr(var);
+N3::N3(mvm::BumpPtrAllocator &allocator, const char *name) : mvm::VirtualMachine(allocator) {
+  this->module =            0;
+  this->TheModuleProvider = 0;
+	this->name =              name;
+
+  this->scanner =           new mvm::UnpreciseStackScanner(); 
+  this->LLVMModule =        new llvm::Module(name, llvm::getGlobalContext());
+  this->module =            new mvm::MvmModule(this->LLVMModule);
+
+  this->LLVMModule->setDataLayout(mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation());
+  this->protectModule =     new mvm::LockNormal();
+
+  this->functions =         new(allocator, "FunctionMap") FunctionMap();
+  this->hashStr =           new(allocator, "StringMap")   StringMap();
+  this->loadedAssemblies =  new(allocator, "AssemblyMap") AssemblyMap();
+
+  this->TheModuleProvider = new N3ModuleProvider(this->LLVMModule, this->functions);
 }
 
-VMObject* N3::UTF8ToStr(const UTF8* utf8) {
-  VMObject* res = CLIString::stringDup(utf8, this);
-  //VMObject* res = hashStr->lookupOrCreate(utf8, this, CLIString::stringDup);
-  return res;
+N3::~N3() {
+  delete module;
+  delete TheModuleProvider;
+}
+
+void N3::error(const char* className, const char* fmt, va_list ap) {
+  fprintf(stderr, "Internal exception of type %s during bootstrap: ", className);
+  vfprintf(stderr, fmt, ap);
+  throw 1;
+}
+
+void N3::indexOutOfBounds(const VMObject* obj, sint32 entry) {
+  error(IndexOutOfRangeException, "%d", entry);
+}
+
+void N3::negativeArraySizeException(sint32 size) {
+  error(OverFlowException, "%d", size);
+}
+
+void N3::nullPointerException(const char* fmt, ...) {
+  va_list ap;
+  va_start(ap, fmt);
+  error(NullReferenceException, fmt, va_arg(ap, char*));
+}
+
+
+void N3::illegalMonitorStateException(const VMObject* obj) {
+  error(SynchronizationLocException, "");
+}
+
+void N3::interruptedException(const VMObject* obj) {
+  error(ThreadInterruptedException, "");
+}
+
+void N3::outOfMemoryError(sint32 n) {
+  error(OutOfMemoryException, "");
+}
+
+void N3::arrayStoreException() {
+  error(ArrayTypeMismatchException, "");
+}
+
+void N3::illegalArgumentException(const char* name) {
+  error(ArgumentException, name);
+}
+
+void N3::unknownError(const char* fmt, ...) {
+  va_list ap;
+  va_start(ap, fmt);
+  error(SystemException, fmt, ap);
+}
+
+void N3::error(const char* fmt, ...) {
+  va_list ap;
+  va_start(ap, fmt);
+  error(SystemException, fmt, ap);
+}
+
+void N3::error(const char* name, const char* fmt, ...) {
+  va_list ap;
+  va_start(ap, fmt);
+  error(name, fmt, ap);
+}
+
+
+
+
+using namespace n3;
+
+void N3::print(mvm::PrintBuffer* buf) const {
+  buf->write("N3 virtual machine<>");
 }
 
 static Assembly* assemblyDup(const UTF8*& name, N3* vm) {
@@ -59,23 +201,11 @@
   return loadedAssemblies->lookup(name);
 }
 
-N3::N3(mvm::BumpPtrAllocator &allocator, const char *name) : VirtualMachine(allocator) {
-	this->name =              name;
-
-  this->scanner =           new mvm::UnpreciseStackScanner(); 
-  this->LLVMModule =        new llvm::Module(name, llvm::getGlobalContext());
-  this->module =            new mvm::MvmModule(this->LLVMModule);
-
-  this->LLVMModule->setDataLayout(mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation());
-  this->protectModule =     new mvm::LockNormal();
-
-  this->functions =         new(allocator, "FunctionMap") FunctionMap();
-  this->hashStr =           new(allocator, "StringMap")   StringMap();
-  this->loadedAssemblies =  new(allocator, "AssemblyMap") AssemblyMap();
-
-  this->TheModuleProvider = new N3ModuleProvider(this->LLVMModule, this->functions);
+VMMethod* N3::lookupFunction(Function* F) {
+  return functions->lookup(F);
 }
 
+
 N3* N3::allocateBootstrap() {
   mvm::BumpPtrAllocator *a = new mvm::BumpPtrAllocator();
   N3 *vm= new(*a, "VM") N3(*a, "bootstrapN3");
@@ -190,7 +320,7 @@
 }
 
 void N3::executeAssembly(const char* _name, ArrayObject* args) {
-  const UTF8* name = asciizConstructUTF8(_name);
+  const UTF8* name = asciizToUTF8(_name);
   Assembly* assembly = loadAssembly(name, 0);
   if (assembly == 0) {
     error("Can not find assembly %s", _name);
@@ -233,7 +363,7 @@
   ClArgumentsInfo& info = vm->argumentsInfo;  
   ArrayObject* args = ArrayObject::acons(info.argc - 2, MSCorlib::arrayString);
   for (int i = 2; i < info.argc; ++i) {
-    args->setAt(i - 2, (VMObject*)vm->asciizToStr(info.argv[i]));
+    args->setAt(i - 2, (VMObject*)vm->arrayToString(vm->asciizToArray(info.argv[i])));
   }
   
   try{
@@ -250,4 +380,41 @@
   vm->threadSystem->nonDaemonLock->unlock();
 }
 
+
+
+ArrayUInt16* N3::asciizToArray(const char* asciiz) {
+	uint32 len = strlen(asciiz);
+	ArrayUInt16 *res = (ArrayUInt16*)MSCorlib::arrayChar->doNew(len);
+	for(uint32 i=0; i<len; i++)
+		res->elements[i] = asciiz[i];
+	return res;
+}
+
+ArrayUInt16* N3::bufToArray(const uint16* buf, uint32 size) {
+	ArrayUInt16 *res = (ArrayUInt16*)MSCorlib::arrayChar->doNew(size);
+	memcpy(res->elements, buf, size<<1);
+	return res;
+}
+
+ArrayUInt16* N3::UTF8ToArray(const UTF8 *utf8) {
+  return bufToArray(utf8->elements, utf8->size);
+}
+
+const UTF8* N3::asciizToUTF8(const char* asciiz) {
+  return hashUTF8->lookupOrCreateAsciiz(asciiz);
+}
+
+const UTF8* N3::bufToUTF8(const uint16* buf, uint32 len) {
+  return hashUTF8->lookupOrCreateReader(buf, len);
+}
+
+const UTF8* N3::arrayToUTF8(const ArrayUInt16 *array) {
+  return bufToUTF8(array->elements, array->size);
+}
+
+CLIString *N3::arrayToString(const ArrayUInt16 *array) {
+	const UTF8 *utf8 = arrayToUTF8(array);
+  return (CLIString*)CLIString::stringDup(utf8, this);
+}
+
 #include "MSCorlib.inc"

Modified: vmkit/trunk/lib/N3/VMCore/N3.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.h (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.h Mon Oct  5 12:36:51 2009
@@ -13,7 +13,17 @@
 
 #include "types.h"
 
-#include "VirtualMachine.h"
+#include <vector>
+
+#include "llvm/Function.h"
+
+#include "mvm/JIT.h"
+#include "mvm/Object.h"
+#include "mvm/PrintBuffer.h"
+#include "mvm/Threads/Cond.h"
+#include "mvm/Threads/Locks.h"
+
+#include "types.h"
 
 namespace n3 {
 
@@ -21,7 +31,6 @@
 class ArrayUInt8;
 class Assembly;
 class AssemblyMap;
-class FunctionMap;
 class N3;
 class N3ModuleProvider;
 class StringMap;
@@ -32,6 +41,28 @@
 class VMCommonClass;
 class VMField;
 class VMMethod;
+class FunctionMap;
+class N3ModuleProvider;
+class UTF8;
+class UTF8Map;
+class VMMethod;
+class VMObject;
+class VMThread;
+class ArrayUInt16;
+class CLIString;
+
+class ThreadSystem : public mvm::Object {
+public:
+  static VirtualTable* VT;
+  uint16 nonDaemonThreads;
+  mvm::Lock* nonDaemonLock;
+  mvm::Cond* nonDaemonVar;
+
+  virtual void print(mvm::PrintBuffer* buf) const;
+  virtual void TRACER;
+
+  static ThreadSystem* allocateThreadSystem();
+};
 
 class ClArgumentsInfo {
 public:
@@ -48,40 +79,86 @@
 };
 
 
-class N3 : public VirtualMachine {
+class N3 : public mvm::VirtualMachine {
 public:
+	// instance fields
+  const char*              name;
+
+  ClArgumentsInfo          argumentsInfo;
+  AssemblyMap*             loadedAssemblies;
+  std::vector<const char*> assemblyPath;
+  Assembly*                coreAssembly;
+
+  ThreadSystem*            threadSystem; 
+  VMThread*                bootstrapThread;
+
+  StringMap*               hashStr;
+  UTF8Map*                 hashUTF8;
+
+  mvm::Lock*               protectModule;
+  FunctionMap*             functions;
+
+  mvm::MvmModule*          module;
+  llvm::Module*            LLVMModule;
+  N3ModuleProvider*        TheModuleProvider;
+
+	// constructors / destructors
+	N3(mvm::BumpPtrAllocator &allocator, const char *name);
+  ~N3();
+
+	// virtual methods
   virtual void print(mvm::PrintBuffer* buf) const;
   virtual void TRACER;
+  virtual void runApplication(int argc, char** argv);
+  virtual void compile(const char* name);
+  virtual void waitForExit();
+
+	// non virtual methods
+  ArrayUInt8*   openAssembly(const UTF8* name, const char* extension);
+  Assembly*     loadAssembly(const UTF8* name, const char* extension);
+  void          executeAssembly(const char* name, ArrayObject* args);
+  void          runMain(int argc, char** argv);
+
+  VMMethod*     lookupFunction(llvm::Function* F);
+
+  llvm::Module* getLLVMModule() { return LLVMModule; }  
+  
 
-  VMObject*     asciizToStr(const char* asciiz);
-  VMObject*     UTF8ToStr(const UTF8* utf8);
   Assembly*     constructAssembly(const UTF8* name);
   Assembly*     lookupAssembly(const UTF8* name);
-  
-  ClArgumentsInfo argumentsInfo;
-  const char* name;
-  StringMap * hashStr;
-  AssemblyMap* loadedAssemblies;
-  std::vector<const char*> assemblyPath;
-  Assembly* coreAssembly;
 
-private:
-	N3(mvm::BumpPtrAllocator &allocator, const char *name);
+	// usefull string, uint16 and utf8 functions
 
-public:
+	ArrayUInt16*     asciizToArray(const char *asciiz);          // done
+	ArrayUInt16*     bufToArray(const uint16 *buf, uint32 len);  // done
+	ArrayUInt16*     UTF8ToArray(const UTF8 *utf8);              // done
+	const UTF8*      asciizToUTF8(const char *asciiz);           // done
+	const UTF8*      bufToUTF8(const uint16 *buf, uint32 len);   // done
+	const UTF8*      arrayToUTF8(const ArrayUInt16 *array);      // done
+	CLIString*       arrayToString(const ArrayUInt16 *array);
+
+  /*
+  void          illegalAccessException(const char* msg);
+  void          initializerError(const VMObject* excp);
+  void          invocationTargetException(const VMObject* obj);
+  void          classCastException(const char* msg);
+  void          errorWithExcp(const char* className, const VMObject* excp);*/
+  void          illegalArgumentException(const char* msg);
+  void          arrayStoreException();
+  void          illegalMonitorStateException(const VMObject* obj);
+  void          interruptedException(const VMObject* obj);
+  void          nullPointerException(const char* fmt, ...);
+  void          outOfMemoryError(sint32 n);
+  void          indexOutOfBounds(const VMObject* obj, sint32 entry);
+  void          negativeArraySizeException(int size);
+  void          unknownError(const char* fmt, ...); 
+
+  void          error(const char* fmt, ...);
+  void          error(const char* className, const char* fmt, ...);
+  void          error(const char* className, const char* fmt, va_list ap);
 
-  static N3* allocateBootstrap();
-  static N3* allocate(const char* name, N3* parent);
-  
-  ArrayUInt8* openAssembly(const UTF8* name, const char* extension);
- 
-  Assembly* loadAssembly(const UTF8* name, const char* extension);
-  void executeAssembly(const char* name, ArrayObject* args);
-  void runMain(int argc, char** argv);
-  virtual void waitForExit();
-  static void mainCLIStart(VMThread* th);
-  
-  static N3* bootstrapVM;
+	// static fields
+  static N3*         bootstrapVM;
  
   static const UTF8* clinitName;
   static const UTF8* ctorName;
@@ -100,7 +177,48 @@
   static const UTF8* floatName;
   static const UTF8* doubleName;
   static const UTF8* testInfinity;
-  
+
+  // Exceptions name
+  static const char* SystemException;
+  static const char* OverFlowException;
+  static const char* OutOfMemoryException;
+  static const char* IndexOutOfRangeException;
+  static const char* SynchronizationLocException;
+  static const char* NullReferenceException;
+  static const char* ThreadInterruptedException;
+  static const char* MissingMethodException;
+  static const char* MissingFieldException;
+  static const char* ArrayTypeMismatchException;
+  static const char* ArgumentException;
+  /*static const char* ArithmeticException;
+  static const char* ClassNotFoundException;
+  static const char* InvocationTargetException;
+  static const char* ClassCastException;
+  static const char* ArrayIndexOutOfBoundsException;
+  static const char* SecurityException;
+  static const char* ClassFormatError;
+  static const char* ClassCircularityError;
+  static const char* NoClassDefFoundError;
+  static const char* UnsupportedClassVersionError;
+  static const char* NoSuchFieldError;
+  static const char* NoSuchMethodError;
+  static const char* InstantiationError;
+  static const char* IllegalAccessError;
+  static const char* IllegalAccessException;
+  static const char* VerifyError;
+  static const char* ExceptionInInitializerError;
+  static const char* LinkageError;
+  static const char* AbstractMethodError;
+  static const char* UnsatisfiedLinkError;
+  static const char* InternalError;
+  static const char* StackOverflowError;
+  */
+  // Exceptions
+
+	// static methods
+  static N3* allocateBootstrap();
+  static N3* allocate(const char* name, N3* parent);
+  static void mainCLIStart(VMThread* th);
 };
 
 } // end namespace n3

Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Mon Oct  5 12:36:51 2009
@@ -23,7 +23,6 @@
 #include "N3.h"
 #include "N3ModuleProvider.h"
 #include "Reader.h"
-#include "VirtualMachine.h"
 #include "VMArray.h"
 #include "VMCache.h"
 #include "VMClass.h"
@@ -220,7 +219,7 @@
   vm->assemblyPath.push_back("");
   vm->assemblyPath.push_back(MSCorlib::libsPath);
   
-  const UTF8* mscorlib = vm->asciizConstructUTF8("mscorlib");
+  const UTF8* mscorlib = vm->asciizToUTF8("mscorlib");
   Assembly* ass = vm->loadAssembly(mscorlib, "dll");
   if (ass == 0)
     VMThread::get()->vm->error("can not load mscorlib.dll. Abort");
@@ -228,8 +227,8 @@
   vm->coreAssembly = ass;
 
   // Array initialization
-  const UTF8* System = vm->asciizConstructUTF8("System");
-  const UTF8* utf8OfChar = vm->asciizConstructUTF8("Char");
+  const UTF8* System = vm->asciizToUTF8("System");
+  const UTF8* utf8OfChar = vm->asciizToUTF8("Char");
   
   MSCorlib::arrayChar = ass->constructArray(utf8OfChar, System, 1);
   ((UTF8*)System)->classOf = MSCorlib::arrayChar;
@@ -238,8 +237,8 @@
 
 #define INIT(var, nameSpace, name, type, prim) {\
   var = (VMClass*)vm->coreAssembly->loadTypeFromName( \
-                                           vm->asciizConstructUTF8(name),     \
-                                           vm->asciizConstructUTF8(nameSpace),\
+                                           vm->asciizToUTF8(name),     \
+                                           vm->asciizToUTF8(nameSpace),\
                                            false, false, false, true); \
   var->isPrimitive = prim; \
   if (type) { \
@@ -275,41 +274,43 @@
   MSCorlib::arrayChar->baseClass = MSCorlib::pChar;
   VMClassArray::SuperArray = MSCorlib::pArray;
   MSCorlib::arrayChar->super = MSCorlib::pArray;
-  
+
   MSCorlib::loadStringClass(vm);
 
-  MSCorlib::arrayString = ass->constructArray(vm->asciizConstructUTF8("String"),
+  MSCorlib::arrayString = ass->constructArray(vm->asciizToUTF8("String"),
                                         System, 1);
   MSCorlib::arrayString->baseClass = MSCorlib::pString;
   
-  MSCorlib::arrayByte = ass->constructArray(vm->asciizConstructUTF8("Byte"),
+  MSCorlib::arrayByte = ass->constructArray(vm->asciizToUTF8("Byte"),
                                         System, 1);
   MSCorlib::arrayByte->baseClass = MSCorlib::pUInt8;
   
-  MSCorlib::arrayObject = ass->constructArray(vm->asciizConstructUTF8("Object"),
+  MSCorlib::arrayObject = ass->constructArray(vm->asciizToUTF8("Object"),
                                         System, 1);
   MSCorlib::arrayObject->baseClass = MSCorlib::pObject;
   
 
-  N3::clinitName = vm->asciizConstructUTF8(".cctor");
-  N3::ctorName = vm->asciizConstructUTF8(".ctor");
-  N3::invokeName = vm->asciizConstructUTF8("Invoke");
-  N3::math = vm->asciizConstructUTF8("Math");
-  N3::system = vm->asciizConstructUTF8("System");
-  N3::sqrt = vm->asciizConstructUTF8("Sqrt");
-  N3::sin = vm->asciizConstructUTF8("Sin");
-  N3::cos = vm->asciizConstructUTF8("Cos");
-  N3::exp = vm->asciizConstructUTF8("Exp");
-  N3::log = vm->asciizConstructUTF8("Log");
-  N3::floor = vm->asciizConstructUTF8("Floor");
-  N3::log10 = vm->asciizConstructUTF8("Log10");
-  N3::isNan = vm->asciizConstructUTF8("IsNaN");
-  N3::pow = vm->asciizConstructUTF8("Pow");
-  N3::floatName = vm->asciizConstructUTF8("Float");
-  N3::doubleName = vm->asciizConstructUTF8("Double");
-  N3::testInfinity = vm->asciizConstructUTF8("TestInfinity");
+  N3::clinitName = vm->asciizToUTF8(".cctor");
+  N3::ctorName = vm->asciizToUTF8(".ctor");
+  N3::invokeName = vm->asciizToUTF8("Invoke");
+  N3::math = vm->asciizToUTF8("Math");
+  N3::system = vm->asciizToUTF8("System");
+  N3::sqrt = vm->asciizToUTF8("Sqrt");
+  N3::sin = vm->asciizToUTF8("Sin");
+  N3::cos = vm->asciizToUTF8("Cos");
+  N3::exp = vm->asciizToUTF8("Exp");
+  N3::log = vm->asciizToUTF8("Log");
+  N3::floor = vm->asciizToUTF8("Floor");
+  N3::log10 = vm->asciizToUTF8("Log10");
+  N3::isNan = vm->asciizToUTF8("IsNaN");
+  N3::pow = vm->asciizToUTF8("Pow");
+  N3::floatName = vm->asciizToUTF8("Float");
+  N3::doubleName = vm->asciizToUTF8("Double");
+  N3::testInfinity = vm->asciizToUTF8("TestInfinity");
   
 
+	MSCorlib::pArray->resolveType(1, 0, 0);
+
   MSCorlib::initialise(vm);
    
 }
@@ -323,11 +324,11 @@
   return 0;
 }
 
-void VirtualMachine::runApplication(int argc, char** argv) {
+void N3::runApplication(int argc, char** argv) {
   ((N3*)this)->runMain(argc, argv);
 }
 
-void VirtualMachine::compile(const char* argv) {
+void N3::compile(const char* argv) {
   assert(0 && "This virtual machine does not perform static compilation yet!\n");
 }
 

Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Mon Oct  5 12:36:51 2009
@@ -15,9 +15,9 @@
 #include "Assembly.h"
 #include "CLIJit.h"
 #include "N3ModuleProvider.h"
-#include "VirtualMachine.h"
 #include "VMClass.h"
 #include "VMThread.h"
+#include "N3.h"
 
 using namespace llvm;
 using namespace n3;
@@ -40,7 +40,7 @@
         CLIJit::compile(meth->classDef, meth);
         void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(meth->methPtr);
         meth->code = res;
-        VirtualMachine* vm = VMThread::get()->vm;
+        N3* vm = VMThread::get()->vm;
         vm->addMethodInFunctionMap(meth, res);
       }
       meth->classDef->release();

Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Mon Oct  5 12:36:51 2009
@@ -1577,8 +1577,8 @@
       case LDSTR : {
         uint32 value = readU4(bytecodes, i);
         uint32 index = value & 0xfffffff;
-        const UTF8* utf8 = compilingClass->assembly->readUserString(index);
-        Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (int64_t)utf8),
+        const ArrayUInt16* array = compilingClass->assembly->readUserString(index);
+        Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (int64_t)array),
                                                module->ptrType);
         Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock);
         /*CLIString * str = 

Modified: vmkit/trunk/lib/N3/VMCore/VMArray.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMArray.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMArray.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMArray.cpp Mon Oct  5 12:36:51 2009
@@ -9,11 +9,11 @@
 
 #include <stdlib.h>
 
-#include "VirtualMachine.h"
 #include "VMArray.h"
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"
+#include "N3.h"
 
 
 using namespace n3;
@@ -166,54 +166,7 @@
 }
 
 
-AT(UTF8, uint16)
-INITIALISE(UTF8)
-
 #undef AT
 #undef INITIALISE
 #undef ACONS
 #undef ARRAYCLASS
-
-UTF8* UTF8::acons(sint32 n, VMClassArray* atype) {
-  if (n < 0)
-    VMThread::get()->vm->negativeArraySizeException(n);
-  else if (n > VMArray::MaxArraySize)
-    VMThread::get()->vm->outOfMemoryError(n);
-  uint32 size = sizeof(VMObject) + sizeof(sint32) + n * sizeof(uint16);
-  UTF8* res = (UTF8*)gc::operator new(size, UTF8::VT);
-  res->initialise(atype, n);
-  return res;
-}
-
-void UTF8::print(mvm::PrintBuffer* buf) const {
-  for (int i = 0; i < size; i++)
-    buf->writeChar((char)elements[i]);
-}
-
-const UTF8* UTF8::extract(VirtualMachine *vm, uint32 start, uint32 end) const {
-  uint32 len = end - start;
-  uint16* buf = (uint16*)alloca(sizeof(uint16) * len);
-
-  for (uint32 i = 0; i < len; i++) {
-    buf[i] = at(i + start);
-  }
-
-  return readerConstruct(vm, buf, len);
-}
-
-const UTF8* UTF8::asciizConstruct(VirtualMachine* vm, const char* asciiz) {
-  return vm->asciizConstructUTF8(asciiz);
-}
-
-const UTF8* UTF8::readerConstruct(VirtualMachine* vm, uint16* buf, uint32 n) {
-  return vm->readerConstructUTF8(buf, n);
-}
-
-char* UTF8::UTF8ToAsciiz() const {
-  mvm::NativeString* buf = mvm::NativeString::alloc(size + 1);
-  for (sint32 i = 0; i < size; ++i) {
-    buf->setAt(i, elements[i]);
-  }
-  buf->setAt(size, 0);
-  return buf->cString();
-}

Modified: vmkit/trunk/lib/N3/VMCore/VMArray.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMArray.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMArray.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMArray.h Mon Oct  5 12:36:51 2009
@@ -19,12 +19,13 @@
 
 #include "VMObject.h"
 
+#include "UTF8.h"
+
 namespace n3 {
 
 class VMClassArray;
 class VMCommonClass;
 class VMObject;
-class VirtualMachine;
 
 class VMArray : public VMObject {
 public:
@@ -84,27 +85,6 @@
   virtual void TRACER;
 };
 
-class UTF8 : public VMObject {
-public:
-  static VirtualTable* VT;
-  sint32 size;
-  uint16 elements[1];
-
-  static const llvm::Type* llvmType;
-  static UTF8* acons(sint32 n, VMClassArray* cl);
-  void initialise(VMCommonClass* atype, sint32 n);
-  
-  unsigned short int at(sint32) const;
-  void setAt(sint32, uint16);
-  
-  virtual void print(mvm::PrintBuffer* buf) const;
-
-  char* UTF8ToAsciiz() const;
-  static const UTF8* asciizConstruct(VirtualMachine *vm, const char* asciiz);
-  static const UTF8* readerConstruct(VirtualMachine *vm, uint16* buf, uint32 n);
-
-  const UTF8* extract(VirtualMachine *vm, uint32 start, uint32 len) const;
-};
 
 } // end namespace n3
 

Modified: vmkit/trunk/lib/N3/VMCore/VMCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Mon Oct  5 12:36:51 2009
@@ -21,7 +21,6 @@
 #include "CLIJit.h"
 #include "MSCorlib.h"
 #include "N3.h"
-#include "VirtualMachine.h"
 #include "VMArray.h"
 #include "VMCache.h"
 #include "VMClass.h"

Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Mon Oct  5 12:36:51 2009
@@ -25,7 +25,6 @@
 #include "CLIJit.h"
 #include "MSCorlib.h"
 #include "N3.h"
-#include "VirtualMachine.h"
 #include "VMArray.h"
 #include "VMClass.h"
 #include "VMThread.h"
@@ -160,7 +159,7 @@
 }
 
 
-void VMCommonClass::initialise(VirtualMachine* vm, bool isArray) {
+void VMCommonClass::initialise(N3* vm, bool isArray) {
   this->lockVar = new mvm::LockRecursive();
   this->condVar = new mvm::Cond();
   this->delegatee = 0;
@@ -181,7 +180,7 @@
     sprintf(res, "%s[]", res);
   }
 
-  return VMThread::get()->vm->asciizConstructUTF8(res);
+  return VMThread::get()->vm->asciizToUTF8(res);
 }
 
 const UTF8* VMClassPointer::constructPointerName(const UTF8* name, uint32 dims) {
@@ -193,7 +192,7 @@
     sprintf(res, "%s*", res);
   }
 
-  return VMThread::get()->vm->asciizConstructUTF8(res);
+  return VMThread::get()->vm->asciizToUTF8(res);
 }
 
 
@@ -221,6 +220,7 @@
 typedef void (*clinit_t)(void);
 
 void VMCommonClass::clinitClass(VMGenericMethod* genMethod) {
+	//	printf("----- clinit: %s\n", mvm::PrintBuffer::objectToString(this));
   VMCommonClass* cl = this; 
   if (cl->status < ready) {
     cl->aquire();
@@ -401,6 +401,7 @@
 }
 
 void VMCommonClass::resolveVirtual(VMGenericClass* genClass, VMGenericMethod *genMethod) {
+	//	printf("Resolve virtual: %s\n", mvm::PrintBuffer::objectToString(this));
   VMCommonClass* cl = this;
   
   if (cl->status < virtual_resolved) {
@@ -415,7 +416,9 @@
       if (cl->isArray) {
         VMClassArray* arrayCl = (VMClassArray*)cl;
         VMCommonClass* baseClass =  arrayCl->baseClass;
+				//				printf("Resolveing base class: %s\n", mvm::PrintBuffer::objectToString(baseClass));
         baseClass->resolveType(false, false, genMethod);
+				//  			printf("Resolveing base class: %s done\n", mvm::PrintBuffer::objectToString(baseClass));
         arrayCl->makeType();
         cl->status = virtual_resolved;
       } else if (cl->isPointer) {
@@ -476,11 +479,13 @@
 }
 
 void VMCommonClass::resolveType(bool stat, bool clinit, VMGenericMethod* genMethod) {
+	//	printf("Resolve type: %s %d %d\n", mvm::PrintBuffer::objectToString(this), stat, clinit);
   resolveVirtual(dynamic_cast<VMGenericClass*>(this), genMethod);
   if (stat) resolveStatic(clinit, genMethod);
 }
 
 void VMCommonClass::resolveStatic(bool clinit, VMGenericMethod* genMethod) {
+	//	printf("Resolve static: %s %d\n", mvm::PrintBuffer::objectToString(this), clinit);
   VMCommonClass* cl = this;
   if (cl->status < static_resolved) {
     cl->aquire();
@@ -489,6 +494,8 @@
       cl->release();
     } else if (status < virtual_resolved) {
       cl->release();
+			//			printf("Will throw an exception: %s....\n", mvm::PrintBuffer::objectToString(this));
+			//			((char *)0)[0] = 22;
       VMThread::get()->vm->unknownError("try to resolve static of a not virtual-resolved class");
     } else if (status == virtual_resolved) {
       if (cl->isArray) {
@@ -561,7 +568,7 @@
   
   VMMethod* res = lookupMethodDontThrow(name, args, isStatic, recurse);
   if (!res) {
-    VMThread::get()->vm->error(VirtualMachine::MissingMethodException, 
+    VMThread::get()->vm->error(N3::MissingMethodException, 
                                "unable to find %s in %s",
                                mvm::PrintBuffer::objectToString(name), mvm::PrintBuffer::objectToString(this));
   }
@@ -608,7 +615,7 @@
   
   VMField* res = lookupFieldDontThrow(name, type, isStatic, recurse);
   if (!res) {
-    VMThread::get()->vm->error(VirtualMachine::MissingFieldException, 
+    VMThread::get()->vm->error(N3::MissingFieldException, 
                                "unable to find %s in %s",
                                mvm::PrintBuffer::objectToString(name), mvm::PrintBuffer::objectToString(this));
   }

Modified: vmkit/trunk/lib/N3/VMCore/VMClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.h Mon Oct  5 12:36:51 2009
@@ -31,13 +31,13 @@
 class Param;
 class Property;
 class UTF8;
-class VirtualMachine;
 class VMClass;
 class VMField;
 class VMMethod;
 class VMObject;
 class VMGenericClass;
 class VMGenericMethod;
+class N3;
 
 typedef enum VMClassState {
   hashed = 0, loaded, prepared, readed, virtual_resolved, static_resolved, clinitParent, inClinit, ready
@@ -56,7 +56,7 @@
   std::vector<VMClass*> interfaces;
   std::vector<uint32> interfacesToken;
   VMCommonClass* super;
-  VirtualMachine* vm;
+  N3* vm;
   const UTF8* name;
   const UTF8* nameSpace;
   mvm::Lock* lockVar;
@@ -86,7 +86,7 @@
   void broadcastClass();
   bool ownerClass();
 
-  void initialise(VirtualMachine* vm, bool isArray);
+  void initialise(N3* vm, bool isArray);
 
   const llvm::Type* naturalType;  // true type
   const llvm::Type* virtualType;  // true type or box

Modified: vmkit/trunk/lib/N3/VMCore/VMObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMObject.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMObject.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMObject.cpp Mon Oct  5 12:36:51 2009
@@ -14,7 +14,7 @@
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"
-#include "VirtualMachine.h"
+#include "N3.h"
 
 using namespace n3;
 

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.cpp Mon Oct  5 12:36:51 2009
@@ -20,7 +20,7 @@
 #include "VMClass.h"
 #include "VMObject.h"
 #include "VMThread.h"
-#include "VirtualMachine.h"
+#include "N3.h"
 
 using namespace n3;
 
@@ -43,7 +43,7 @@
 
 extern void AddStandardCompilePasses(llvm::FunctionPassManager*);
 
-VMThread* VMThread::allocate(VMObject* thread, VirtualMachine* vm) {
+VMThread* VMThread::allocate(VMObject* thread, N3* vm) {
   VMThread* key = new VMThread();
   key->vmThread = thread;
   key->vm = vm;

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.h?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.h Mon Oct  5 12:36:51 2009
@@ -21,7 +21,7 @@
 
 namespace n3 {
 
-class VirtualMachine;
+class N3;
 class VMClass;
 class VMGenericClass;
 class VMObject;
@@ -31,7 +31,7 @@
 public:
   static VirtualTable *VT;
   VMObject* vmThread;
-  VirtualMachine* vm;
+  N3* vm;
   mvm::Lock* lock;
   mvm::Cond* varcond;
   VMObject* pendingException;
@@ -54,7 +54,7 @@
   static VMThread* get() {
     return TheThread;
   }
-  static VMThread* allocate(VMObject* thread, VirtualMachine* vm);
+  static VMThread* allocate(VMObject* thread, N3* vm);
   static VMObject* currentThread();
   
   static VMObject* getCLIException();

Removed: vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp?rev=83314&view=auto

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualMachine.cpp (removed)
@@ -1,166 +0,0 @@
-//===------ VirtualMachine.cpp - Virtual machine description --------------===//
-//
-//                                N3
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <vector>
-#include <stdarg.h>
-
-#include "llvm/Function.h"
-#include "llvm/Module.h"
-
-#include "mvm/Object.h"
-#include "mvm/PrintBuffer.h"
-#include "mvm/Threads/Cond.h"
-#include "mvm/Threads/Locks.h"
-
-#include "types.h"
-
-#include "Assembly.h"
-#include "LockedMap.h"
-#include "N3ModuleProvider.h"
-#include "VirtualMachine.h"
-#include "VMArray.h"
-#include "VMClass.h"
-
-using namespace n3;
-
-#define DECLARE_EXCEPTION(EXCP) \
-  const char* VirtualMachine::EXCP = #EXCP
-
-DECLARE_EXCEPTION(SystemException);
-DECLARE_EXCEPTION(OverFlowException);
-DECLARE_EXCEPTION(OutOfMemoryException);
-DECLARE_EXCEPTION(IndexOutOfRangeException);
-DECLARE_EXCEPTION(NullReferenceException);
-DECLARE_EXCEPTION(SynchronizationLocException);
-DECLARE_EXCEPTION(ThreadInterruptedException);
-DECLARE_EXCEPTION(MissingMethodException);
-DECLARE_EXCEPTION(MissingFieldException);
-DECLARE_EXCEPTION(ArrayTypeMismatchException);
-DECLARE_EXCEPTION(ArgumentException);
-
-/*
-DECLARE_EXCEPTION(ArithmeticException);
-DECLARE_EXCEPTION(InvocationTargetException);
-DECLARE_EXCEPTION(ArrayStoreException);
-DECLARE_EXCEPTION(ClassCastException);
-DECLARE_EXCEPTION(ArrayIndexOutOfBoundsException);
-DECLARE_EXCEPTION(SecurityException);
-DECLARE_EXCEPTION(ClassFormatError);
-DECLARE_EXCEPTION(ClassCircularityError);
-DECLARE_EXCEPTION(NoClassDefFoundError);
-DECLARE_EXCEPTION(UnsupportedClassVersionError);
-DECLARE_EXCEPTION(NoSuchFieldError);
-DECLARE_EXCEPTION(NoSuchMethodError);
-DECLARE_EXCEPTION(InstantiationError);
-DECLARE_EXCEPTION(IllegalAccessError);
-DECLARE_EXCEPTION(IllegalAccessException);
-DECLARE_EXCEPTION(VerifyError);
-DECLARE_EXCEPTION(ExceptionInInitializerError);
-DECLARE_EXCEPTION(LinkageError);
-DECLARE_EXCEPTION(AbstractMethodError);
-DECLARE_EXCEPTION(UnsatisfiedLinkError);
-DECLARE_EXCEPTION(InternalError);
-DECLARE_EXCEPTION(StackOverflowError);
-DECLARE_EXCEPTION(ClassNotFoundException);
-*/
-
-#undef DECLARE_EXCEPTION
-void ThreadSystem::print(mvm::PrintBuffer* buf) const {
-  buf->write("ThreadSystem<>");
-}
-
-ThreadSystem* ThreadSystem::allocateThreadSystem() {
-  ThreadSystem* res = gc_new(ThreadSystem)();
-  res->nonDaemonThreads = 1;
-  res->nonDaemonLock = new mvm::LockNormal();
-  res->nonDaemonVar  = new mvm::Cond();
-  return res;
-}
-
-const UTF8* VirtualMachine::asciizConstructUTF8(const char* asciiz) {
-  return hashUTF8->lookupOrCreateAsciiz(asciiz);
-}
-
-const UTF8* VirtualMachine::readerConstructUTF8(const uint16* buf, uint32 len) {
-  return hashUTF8->lookupOrCreateReader(buf, len);
-}
-
-void VirtualMachine::error(const char* className, const char* fmt, va_list ap) {
-  fprintf(stderr, "Internal exception of type %s during bootstrap: ", className);
-  vfprintf(stderr, fmt, ap);
-  throw 1;
-}
-
-void VirtualMachine::indexOutOfBounds(const VMObject* obj, sint32 entry) {
-  error(IndexOutOfRangeException, "%d", entry);
-}
-
-void VirtualMachine::negativeArraySizeException(sint32 size) {
-  error(OverFlowException, "%d", size);
-}
-
-void VirtualMachine::nullPointerException(const char* fmt, ...) {
-  va_list ap;
-  va_start(ap, fmt);
-  error(NullReferenceException, fmt, va_arg(ap, char*));
-}
-
-
-void VirtualMachine::illegalMonitorStateException(const VMObject* obj) {
-  error(SynchronizationLocException, "");
-}
-
-void VirtualMachine::interruptedException(const VMObject* obj) {
-  error(ThreadInterruptedException, "");
-}
-
-void VirtualMachine::outOfMemoryError(sint32 n) {
-  error(OutOfMemoryException, "");
-}
-
-void VirtualMachine::arrayStoreException() {
-  error(ArrayTypeMismatchException, "");
-}
-
-void VirtualMachine::illegalArgumentException(const char* name) {
-  error(ArgumentException, name);
-}
-
-void VirtualMachine::unknownError(const char* fmt, ...) {
-  va_list ap;
-  va_start(ap, fmt);
-  error(SystemException, fmt, ap);
-}
-
-void VirtualMachine::error(const char* fmt, ...) {
-  va_list ap;
-  va_start(ap, fmt);
-  error(SystemException, fmt, ap);
-}
-
-void VirtualMachine::error(const char* name, const char* fmt, ...) {
-  va_list ap;
-  va_start(ap, fmt);
-  error(name, fmt, ap);
-}
-
-VirtualMachine::~VirtualMachine() {
-  delete module;
-  delete TheModuleProvider;
-}
-
-VirtualMachine::VirtualMachine(mvm::BumpPtrAllocator &allocator)
-	: mvm::VirtualMachine(allocator) {
-  module = 0;
-  TheModuleProvider = 0;
-}
-
-VMMethod* VirtualMachine::lookupFunction(Function* F) {
-  return functions->lookup(F);
-}

Removed: vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualMachine.h?rev=83314&view=auto

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualMachine.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualMachine.h (removed)
@@ -1,144 +0,0 @@
-//===------- VirtualMachine.h - Virtual machine description ---------------===//
-//
-//                              N3
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef N3_VIRTUAL_MACHINE_H
-#define N3_VIRTUAL_MACHINE_H
-
-#include <vector>
-
-#include "llvm/Function.h"
-
-#include "mvm/JIT.h"
-#include "mvm/Object.h"
-#include "mvm/PrintBuffer.h"
-#include "mvm/VirtualMachine.h"
-#include "mvm/Threads/Cond.h"
-#include "mvm/Threads/Locks.h"
-
-#include "types.h"
-
-namespace n3 {
-
-class FunctionMap;
-class N3ModuleProvider;
-class UTF8;
-class UTF8Map;
-class VMMethod;
-class VMObject;
-class VMThread;
-
-class ThreadSystem : public mvm::Object {
-public:
-  static VirtualTable* VT;
-  uint16 nonDaemonThreads;
-  mvm::Lock* nonDaemonLock;
-  mvm::Cond* nonDaemonVar;
-
-  virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void TRACER;
-
-  static ThreadSystem* allocateThreadSystem();
-};
-
-class VirtualMachine : public mvm::VirtualMachine {
-public:
-  ThreadSystem* threadSystem; 
- 
-  const UTF8*   asciizConstructUTF8(const char* asciiz);
-  const UTF8*   readerConstructUTF8(const uint16* buf, uint32 len);
-  UTF8Map * hashUTF8;
-
-  
-  // Exceptions name
-  static const char* SystemException;
-  static const char* OverFlowException;
-  static const char* OutOfMemoryException;
-  static const char* IndexOutOfRangeException;
-  static const char* SynchronizationLocException;
-  static const char* NullReferenceException;
-  static const char* ThreadInterruptedException;
-  static const char* MissingMethodException;
-  static const char* MissingFieldException;
-  static const char* ArrayTypeMismatchException;
-  static const char* ArgumentException;
-  /*static const char* ArithmeticException;
-  static const char* ClassNotFoundException;
-  static const char* InvocationTargetException;
-  static const char* ClassCastException;
-  static const char* ArrayIndexOutOfBoundsException;
-  static const char* SecurityException;
-  static const char* ClassFormatError;
-  static const char* ClassCircularityError;
-  static const char* NoClassDefFoundError;
-  static const char* UnsupportedClassVersionError;
-  static const char* NoSuchFieldError;
-  static const char* NoSuchMethodError;
-  static const char* InstantiationError;
-  static const char* IllegalAccessError;
-  static const char* IllegalAccessException;
-  static const char* VerifyError;
-  static const char* ExceptionInInitializerError;
-  static const char* LinkageError;
-  static const char* AbstractMethodError;
-  static const char* UnsatisfiedLinkError;
-  static const char* InternalError;
-  static const char* StackOverflowError;
-  */
-  // Exceptions
-  
-  /*
-  void illegalAccessException(const char* msg);
-  void initializerError(const VMObject* excp);
-  void invocationTargetException(const VMObject* obj);
-  void classCastException(const char* msg);
-  void errorWithExcp(const char* className, const VMObject* excp);*/
-  void illegalArgumentException(const char* msg);
-  void arrayStoreException();
-  void illegalMonitorStateException(const VMObject* obj);
-  void interruptedException(const VMObject* obj);
-  void nullPointerException(const char* fmt, ...);
-  void outOfMemoryError(sint32 n);
-  void indexOutOfBounds(const VMObject* obj, sint32 entry);
-  void negativeArraySizeException(int size);
-  void unknownError(const char* fmt, ...); 
-  void error(const char* fmt, ...);
-  void error(const char* className, const char* fmt, ...);
-  void error(const char* className, const char* fmt, va_list ap);
-
-  
-  virtual void TRACER;
-  virtual void print(mvm::PrintBuffer* buf) const {
-    buf->write("Virtual Machine<>");
-  }
-
-  ~VirtualMachine();
-  VirtualMachine(mvm::BumpPtrAllocator &allocator);
-  
-  mvm::Lock* protectModule;
-  FunctionMap* functions;
-  mvm::MvmModule* module;
-  llvm::Module* LLVMModule;
-  N3ModuleProvider* TheModuleProvider;
-  VMThread* bootstrapThread;
-
-  virtual void runApplication(int argc, char** argv);
-  virtual void compile(const char* name);
-  virtual void waitForExit() {
-    // Currently unimplemented.
-  }
-
-  VMMethod* lookupFunction(llvm::Function* F);
-
-  llvm::Module* getLLVMModule() { return LLVMModule; }
-
-};
-
-} // end namespace n3
-
-#endif

Modified: vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp?rev=83315&r1=83314&r2=83315&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp Mon Oct  5 12:36:51 2009
@@ -15,7 +15,6 @@
 #include "LockedMap.h"
 #include "N3.h"
 #include "Reader.h"
-#include "VirtualMachine.h"
 #include "VMArray.h"
 #include "VMCache.h"
 #include "VMClass.h"
@@ -214,18 +213,6 @@
   pendingException->MARK_AND_TRACE;
 }
 
-void VirtualMachine::TRACER {
-  threadSystem->MARK_AND_TRACE;
-  hashUTF8->CALL_TRACER;
-  functions->CALL_TRACER;
-  if (bootstrapThread) {
-    bootstrapThread->CALL_TRACER;
-    for (VMThread* th = (VMThread*)bootstrapThread->next(); 
-         th != bootstrapThread; th = (VMThread*)th->next())
-      th->CALL_TRACER;
-  }
-}
-
 void Param::TRACER {
   method->CALL_TRACER;
   name->MARK_AND_TRACE;
@@ -257,7 +244,15 @@
 }
 
 void N3::TRACER {
-  VirtualMachine::CALL_TRACER;
+  threadSystem->MARK_AND_TRACE;
+  hashUTF8->CALL_TRACER;
+  functions->CALL_TRACER;
+  if (bootstrapThread) {
+    bootstrapThread->CALL_TRACER;
+    for (VMThread* th = (VMThread*)bootstrapThread->next(); 
+         th != bootstrapThread; th = (VMThread*)th->next())
+      th->CALL_TRACER;
+  }
   hashUTF8->CALL_TRACER;
   hashStr->CALL_TRACER;
   loadedAssemblies->CALL_TRACER;





More information about the vmkit-commits mailing list