[vmkit-commits] [vmkit] r54951 - in /vmkit/trunk/lib/N3: PNetLib/PNetLib.cpp PNetLib/PNetMSCorlib.cpp VMCore/Assembly.cpp VMCore/Assembly.h VMCore/CLIJit.cpp VMCore/CLIJit.h VMCore/CLIJitMeta.cpp VMCore/CLISignature.cpp VMCore/N3.cpp VMCore/N3ModuleProvider.cpp VMCore/NativeUtil.cpp VMCore/Opcodes.cpp VMCore/VMArray.cpp VMCore/VMArray.h VMCore/VMCache.cpp VMCore/VMClass.cpp VMCore/VMClass.h VMCore/VMThread.cpp VMCore/VMThread.h

Tilmann Scheller tilmann.scheller at googlemail.com
Mon Aug 18 15:22:16 PDT 2008


Author: tilmann
Date: Mon Aug 18 17:22:15 2008
New Revision: 54951

URL: http://llvm.org/viewvc/llvm-project?rev=54951&view=rev
Log:
remove global variables for current generic class and method, pass them around by parameters instead
various fixes pointed out by Nicolas Geoffray

Modified:
    vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp
    vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.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/CLIJit.h
    vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
    vmkit/trunk/lib/N3/VMCore/CLISignature.cpp
    vmkit/trunk/lib/N3/VMCore/N3.cpp
    vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
    vmkit/trunk/lib/N3/VMCore/NativeUtil.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/VMThread.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.h

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

==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetLib.cpp Mon Aug 18 17:22:15 2008
@@ -712,11 +712,11 @@
 
 extern "C" VMObject* System_Reflection_ClrMethod_Invoke(VMObject* Method, VMObject* obj, sint32 invokeAttr, VMObject* binder, ArrayObject* args, VMObject* culture) {
   VMMethod* meth = (VMMethod*)(*MSCorlib::methodMethodType)(Method).PointerVal;
-  meth->getSignature();
-  meth->compiledPtr();
+  meth->getSignature(NULL);
+  meth->compiledPtr(NULL);
   llvm::Function* func = CLIJit::compile(meth->classDef, meth);
   VMClass* type = meth->classDef;
-  type->resolveStatic(true);
+  type->resolveStatic(true, NULL);
   uint32 virt = meth->virt;
 
   if ((obj != 0) && virt) {

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

==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp Mon Aug 18 17:22:15 2008
@@ -25,9 +25,9 @@
                                            vm->asciizConstructUTF8("System"),
                                            false, false, false, true);
   MSCorlib::pString = type;
-  MSCorlib::pObject->resolveType(true, false);
+  MSCorlib::pObject->resolveType(true, false, NULL);
   MSCorlib::pObject->resolveVT();
-  type->resolveType(true, false);
+  type->resolveType(true, false, NULL);
   type->resolveVT();
 
   uint64 size = mvm::jit::getTypeSize(type->virtualType->getContainedType(0)) + sizeof(const UTF8*) + sizeof(llvm::GlobalVariable*);
@@ -59,7 +59,7 @@
 #undef INIT
   
   {
-  MSCorlib::clrType->resolveType(false, false);
+  MSCorlib::clrType->resolveType(false, false, NULL);
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::clrType);
@@ -68,7 +68,7 @@
   }
 
   {
-  MSCorlib::assemblyReflection->resolveType(false, false);
+  MSCorlib::assemblyReflection->resolveType(false, false, NULL);
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::assemblyReflection);
@@ -77,7 +77,7 @@
   }
   
   {
-  MSCorlib::propertyType->resolveType(false, false);
+  MSCorlib::propertyType->resolveType(false, false, NULL);
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::propertyType);
@@ -86,7 +86,7 @@
   }
   
   {
-  MSCorlib::methodType->resolveType(false, false);
+  MSCorlib::methodType->resolveType(false, false, NULL);
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::methodType);
@@ -95,7 +95,7 @@
   }
   
   {
-  MSCorlib::resourceStreamType->resolveType(false, false);
+  MSCorlib::resourceStreamType->resolveType(false, false, NULL);
   std::vector<VMCommonClass*> args;
   args.push_back(MSCorlib::pVoid);
   args.push_back(MSCorlib::resourceStreamType);
@@ -107,7 +107,7 @@
   
   VMCommonClass* voidPtr = vm->coreAssembly->constructPointer(MSCorlib::pVoid, 1);
 #define INIT(var, cl, type) {\
-    cl->resolveType(false, false); \
+    cl->resolveType(false, false, NULL); \
     var = cl->lookupField(vm->asciizConstructUTF8("value_"), type, false, false); \
   }
   

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Assembly.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Assembly.cpp Mon Aug 18 17:22:15 2008
@@ -394,10 +394,10 @@
 
 VMField*  Assembly::constructField(VMClass* cl, const UTF8* name,
                                    VMCommonClass* signature,
-                                   uint32 token) {
+                                   uint32 token, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMField* field; 
   
-  if (VMThread::get()->currGenericClass == 0) {
+  if (genClass == 0) {
     // we are not reading a generic class 
     field = loadedTokenFields->lookupOrCreate(token, this, fieldDup);
   } else {
@@ -428,10 +428,11 @@
 }
 
 VMMethod* Assembly::constructMethod(VMClass* cl, const UTF8* name, 
-                                    uint32 token, bool generic) {
+                                    uint32 token, bool generic,
+                                    std::vector<VMCommonClass*>* genMethodInstantiation, VMGenericClass* genClass) {
   VMMethod* meth;
   
-  if (VMThread::get()->currGenericClass == 0 && generic == false) {
+  if (genClass == 0 && generic == false) {
     // we are not reading a generic class 
     meth = loadedTokenMethods->lookupOrCreate(token, this, methodDup);
   } else {
@@ -441,11 +442,11 @@
     
     if (generic) {
       // we are reading a generic method
-      if (VMThread::get()->genMethodInstantiation == NULL) {
+      if (genMethodInstantiation == NULL) {
         cl->genericMethods.push_back(meth);
       } else {
         VMGenericMethod* genMethod = genMethodDup(token, this);
-        genMethod->genericParams = *VMThread::get()->genMethodInstantiation;
+        genMethod->genericParams = *genMethodInstantiation;
         meth = genMethod;
         if (isStatic(meth->flags)) {
           cl->staticMethods.push_back(meth);
@@ -887,7 +888,7 @@
   return i + 1 + (CONSTANT_TypeDef << 24);
 }
 
-VMCommonClass* Assembly::readTypeSpec(N3* vm, uint32 index) {
+VMCommonClass* Assembly::readTypeSpec(N3* vm, uint32 index, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 blobOffset = CLIHeader->blobStream->realOffset;
   Table* typeTable  = CLIHeader->tables[CONSTANT_TypeSpec];
   uint32* typeArray = (uint32*)alloca(sizeof(uint32) * typeTable->rowSize);
@@ -896,7 +897,7 @@
   uint32 signOffset = typeArray[CONSTANT_TYPESPEC_SIGNATURE];
   
   uint32 offset = blobOffset + signOffset;
-  return extractTypeInSignature(offset);
+  return extractTypeInSignature(offset, genClass, genMethod);
   
 }
 
@@ -1100,14 +1101,14 @@
 }
 
 VMCommonClass* Assembly::loadType(N3* vm, uint32 token, bool resolve,
-                            bool resolveStatic, bool clinit, bool dothrow) {
-	return loadType(vm, token, resolve, resolveStatic, clinit, dothrow, (std::vector<VMCommonClass*>) 0);
+                            bool resolveStatic, bool clinit, bool dothrow, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+	return loadType(vm, token, resolve, resolveStatic, clinit, dothrow, (std::vector<VMCommonClass*>) 0, genClass, genMethod);
 }
 
 
 VMCommonClass* Assembly::loadType(N3* vm, uint32 token, bool resolve,
                             bool resolveStatic, bool clinit, bool dothrow,
-                            std::vector<VMCommonClass*> genArgs) {
+                            std::vector<VMCommonClass*> genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   
   VMCommonClass* type = lookupClassFromToken(token);
   if (!type || type->status == hashed) {
@@ -1119,7 +1120,7 @@
     } else if (table == CONSTANT_TypeRef) {
       type = readTypeRef(vm, index);
     } else if (table == CONSTANT_TypeSpec) {
-      type = readTypeSpec(vm, index);
+      type = readTypeSpec(vm, index, genClass, genMethod);
     } else {
       VMThread::get()->vm->error("implement me %x", token);
     }
@@ -1134,16 +1135,12 @@
     type->release();
   }
 
-  if (resolve) type->resolveType(resolveStatic, clinit);
+  if (resolve) type->resolveType(resolveStatic, clinit, genMethod);
 
   return type;
 }
 
-void Assembly::readClass(VMCommonClass* cl) {
-  // temporarily store the class being read in case it is a generic class
-  VMGenericClass* old = VMThread::get()->currGenericClass;
-  VMThread::get()->currGenericClass = dynamic_cast<VMGenericClass*>(cl);
-	
+void Assembly::readClass(VMCommonClass* cl, VMGenericMethod* genMethod) {
   uint32 index = cl->token & 0xffff;
   Table* typeTable = CLIHeader->tables[CONSTANT_TypeDef];
   uint32 typeSize = typeTable->rowsNumber;
@@ -1158,7 +1155,7 @@
   Table* methodTable  = CLIHeader->tables[CONSTANT_MethodDef];
   uint32 methodSize   = methodTable->rowsNumber;
   
-  getProperties(cl);
+  getProperties(cl, dynamic_cast<VMGenericClass*>(cl), genMethod);
 
   if (methodList && methodTable != 0 && methodList <= methodSize) {
     uint32 endMethod = (index == typeSize) ? 
@@ -1169,7 +1166,7 @@
     uint32 nbMethods = endMethod - methodList;
 
     for (uint32 i = 0; i < nbMethods; ++i) {
-      VMMethod* meth = readMethodDef(i + methodList, cl);
+      VMMethod* meth = readMethodDef(i + methodList, cl, NULL, dynamic_cast<VMGenericClass*>(cl));
       
       if (meth != NULL) {
         if (isStatic(meth->flags)) {
@@ -1189,7 +1186,7 @@
     uint32 nbFields = endField - fieldList;
 
     for (uint32 i = 0; i < nbFields; ++i) {
-      VMField* field = readField(i + fieldList, cl);
+      VMField* field = readField(i + fieldList, cl, dynamic_cast<VMGenericClass*>(cl), genMethod);
       if (isStatic(field->flags)) {
         cl->staticFields.push_back(field);
       } else {
@@ -1197,9 +1194,6 @@
       }
     }
   }
-  
-  // we have stopped reading a generic class
-  VMThread::get()->currGenericClass = old;
 }
 
 void Assembly::readCustomAttributes(uint32 offset, std::vector<llvm::GenericValue>& args, VMMethod* meth) {
@@ -1240,10 +1234,10 @@
         VMThread::get()->vm->error("implement me"); 
         break;
       case 2: 
-        cons = getMethodFromToken(index + (CONSTANT_MethodDef << 24));
+        cons = getMethodFromToken(index + (CONSTANT_MethodDef << 24), NULL, NULL);
         break;
       case 3:
-        cons = getMethodFromToken(index + (CONSTANT_MemberRef << 24));
+        cons = getMethodFromToken(index + (CONSTANT_MemberRef << 24), NULL, NULL);
         break;
     }
 
@@ -1266,7 +1260,7 @@
   return res;
 }
 
-void Assembly::getProperties(VMCommonClass* cl) {
+void Assembly::getProperties(VMCommonClass* cl, VMGenericClass* genClass, VMGenericMethod *genMethod) {
   uint32 index = cl->token & 0xffff;
   Table* mapTable = CLIHeader->tables[CONSTANT_PropertyMap];
   uint32 mapSize = mapTable->rowsNumber;
@@ -1296,13 +1290,13 @@
     uint32 nbProperties = endProperty - propertyList;
 
     for (uint32 j = 0; j < nbProperties; ++j) {
-      cl->properties.push_back(readProperty(j + propertyList, cl));
+      cl->properties.push_back(readProperty(j + propertyList, cl, genClass, genMethod));
     }
 
   } 
 }
 
-Property* Assembly::readProperty(uint32 index, VMCommonClass* cl) {
+Property* Assembly::readProperty(uint32 index, VMCommonClass* cl, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 stringOffset = CLIHeader->stringStream->realOffset;
   uint32 blobOffset = CLIHeader->blobStream->realOffset;
   
@@ -1320,11 +1314,12 @@
   prop->flags = flags;
   prop->type = cl;
   uint32 offset = blobOffset + type;
-  prop->virt = extractMethodSignature(offset, cl, prop->parameters);
+  prop->virt = extractMethodSignature(offset, cl, prop->parameters, genClass, genMethod);
   return prop;
 }
 
-VMMethod* Assembly::readMethodDef(uint32 index, VMCommonClass* cl) {
+VMMethod* Assembly::readMethodDef(uint32 index, VMCommonClass* cl,
+       std::vector<VMCommonClass*>* genMethodInstantiation, VMGenericClass* genClass) {
   uint32 token = index + (CONSTANT_MethodDef << 24);
   uint32 stringOffset = CLIHeader->stringStream->realOffset;
   uint32 blobOffset = CLIHeader->blobStream->realOffset;
@@ -1349,14 +1344,12 @@
 
   VMMethod* meth = 
     constructMethod((VMClass*)cl, readString(cl->vm, (name + stringOffset)),
-                    token, isGenericMethod(offset));
+                    token, isGenericMethod(offset), genMethodInstantiation, genClass);
   
   offset = blobOffset + signature;
   
-  VMGenericMethod* tmp = VMThread::get()->currGenericMethod;
-  VMThread::get()->currGenericMethod = dynamic_cast<VMGenericMethod*>(meth);
-  meth->virt = extractMethodSignature(offset, cl, meth->parameters);
-  VMThread::get()->currGenericMethod = tmp;
+  meth->virt = extractMethodSignature(offset, cl, meth->parameters, genClass, 
+      dynamic_cast<VMGenericMethod*> (meth));
   
   meth->flags = flags;
   meth->implFlags = implFlags;
@@ -1384,7 +1377,7 @@
   return meth;
 }
 
-VMField* Assembly::readField(uint32 index, VMCommonClass* cl) {
+VMField* Assembly::readField(uint32 index, VMCommonClass* cl, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 token = index + (CONSTANT_Field << 24);
   uint32 stringOffset = CLIHeader->stringStream->realOffset;
   uint32 blobOffset = CLIHeader->blobStream->realOffset;
@@ -1399,9 +1392,9 @@
   uint32 signature  = fieldArray[CONSTANT_FIELD_SIGNATURE];
   
   uint32 offset = blobOffset + signature;
-  VMField* field = 
-    constructField((VMClass*)cl, readString(cl->vm, (name + stringOffset)),
-                   extractFieldSignature(offset), token);
+  VMField* field = constructField((VMClass*) cl, readString(cl->vm, (name
+      + stringOffset)), extractFieldSignature(offset, genClass, genMethod),
+      token, genClass, genMethod);
   field->flags = flags;
   
   return field;
@@ -1447,13 +1440,13 @@
     }
   }
 
-  if (resolve) cl->resolveType(unify, clinit);
+  if (resolve) cl->resolveType(unify, clinit, NULL);
 
   return cl;
 }
 
 void Assembly::readSignature(uint32 localVarSig, 
-                             std::vector<VMCommonClass*>& locals) {
+                             std::vector<VMCommonClass*>& locals, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 table = localVarSig >> 24;
   uint32 index = localVarSig & 0xffff;
   if (table != CONSTANT_StandaloneSig) {
@@ -1467,10 +1460,10 @@
   uint32 blobEntry = blobOffset + array[CONSTANT_STANDALONE_SIG_SIGNATURE];
   
 
-  localVarSignature(blobEntry, locals);
+  localVarSignature(blobEntry, locals, genClass, genMethod);
 }
 
-VMField* Assembly::getFieldFromToken(uint32 token, bool stat) {
+VMField* Assembly::getFieldFromToken(uint32 token, bool stat, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMField* field = lookupFieldFromToken(token);
   if (!field) {
     uint32 table = token >> 24;
@@ -1481,7 +1474,7 @@
         switch (newTable) {
           case CONSTANT_TypeDef : {
             loadType((N3*)(VMThread::get()->vm), typeToken, true, true, false,
-                     true);
+                     true, genClass, genMethod);
             field = lookupFieldFromToken(token);
             if (!field) {
               VMThread::get()->vm->error("implement me");
@@ -1496,7 +1489,7 @@
       }
 
       case CONSTANT_MemberRef : {
-        field = readMemberRefAsField(token, stat);
+        field = readMemberRefAsField(token, stat, genClass, genMethod);
         break;
       }
 
@@ -1505,7 +1498,7 @@
       }
     }
   }
-  field->classDef->resolveType(stat, false);
+  field->classDef->resolveType(stat, false, genMethod);
   return field;
 }
 
@@ -1557,7 +1550,7 @@
   return size;
 }
 
-VMField* Assembly::readMemberRefAsField(uint32 token, bool stat) {
+VMField* Assembly::readMemberRefAsField(uint32 token, bool stat, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 index = token & 0xffff;
   Table* memberTable = CLIHeader->tables[CONSTANT_MemberRef];
   uint32* memberArray = (uint32*)alloca(sizeof(uint32) * memberTable->rowSize);
@@ -1581,14 +1574,14 @@
     case 0 : {
       uint32 typeToken = index + (CONSTANT_TypeDef << 24);
       type = loadType(((N3*)VMThread::get()->vm), typeToken,
-                                     true, false, false, true);
+                                     true, false, false, true, genClass, genMethod);
 	  break;
     }
 
     case 1 : {
       uint32 typeToken = index + (CONSTANT_TypeRef << 24);
       type = loadType(((N3*)VMThread::get()->vm), typeToken,
-                                     true, false, false, true);
+                                     true, false, false, true, genClass, genMethod);
       break;
     }
 
@@ -1597,7 +1590,7 @@
     case 4: {
       uint32 typeToken = index + (CONSTANT_TypeSpec << 24);
       type = loadType(((N3*)VMThread::get()->vm), typeToken,
-                                       true, false, false, true);
+                                       true, false, false, true, genClass, genMethod);
       break;
     }
     default:
@@ -1607,24 +1600,15 @@
 
   uint32 offset = blobOffset + memberArray[CONSTANT_MEMBERREF_SIGNATURE];
 
-  VMGenericClass* genClass = dynamic_cast<VMGenericClass*>(type);
-  
-  if (genClass) {
-    // save previous generic class
-    VMGenericClass* old = VMThread::get()->currGenericClass;
-    
-    // set generic class this MemberRef is referring to
-	VMThread::get()->currGenericClass = genClass; 
-	
-	VMCommonClass* signature = extractFieldSignature(offset);
-	
-	// restore saved class
-	VMThread::get()->currGenericClass = old;
-	                                    
-	VMField* field = type->lookupField(name, signature, stat, true);
-	return field;
+  VMGenericClass* genericClass = dynamic_cast<VMGenericClass*> (type);
+
+  if (genericClass) {
+    VMCommonClass* signature = extractFieldSignature(offset, genericClass,
+        genMethod);
+    VMField* field = type->lookupField(name, signature, stat, true);
+    return field;
   } else {
-    VMCommonClass* signature = extractFieldSignature(offset);
+    VMCommonClass* signature = extractFieldSignature(offset, genClass, genMethod);
     VMField* field = type->lookupField(name, signature, stat, true);
     return field;
   }
@@ -1632,7 +1616,7 @@
 }
 
 
-VMMethod* Assembly::getMethodFromToken(uint32 token) {
+VMMethod* Assembly::getMethodFromToken(uint32 token, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMMethod* meth = lookupMethodFromToken(token);
   
   if (!meth) {
@@ -1644,7 +1628,7 @@
         switch (newTable) {
           case CONSTANT_TypeDef : {
             loadType((N3*)(VMThread::get()->vm), typeToken, true, true, false,
-                     true);
+                     true, genClass, genMethod);
             meth = lookupMethodFromToken(token);
             if (!meth) {
               VMThread::get()->vm->error("implement me");
@@ -1659,12 +1643,12 @@
       }
 
       case CONSTANT_MemberRef : {
-        meth = readMemberRefAsMethod(token, NULL);
+        meth = readMemberRefAsMethod(token, NULL, genClass, genMethod);
         break;
       }
       
       case CONSTANT_MethodSpec : {
-        meth = readMethodSpec(token); 
+        meth = readMethodSpec(token, genClass, genMethod); 
         break;
       }
 
@@ -1674,7 +1658,7 @@
     }
   }
   
-  meth->getSignature();
+  meth->getSignature(genMethod);
   
   return meth;
 }
@@ -1704,8 +1688,8 @@
 VMMethod *Assembly::instantiateGenericMethod(
     std::vector<VMCommonClass*> *genArgs, VMCommonClass *type,
     const UTF8 *& name, std::vector<VMCommonClass*> & args, uint32 token,
-    bool virt) {
-  VMMethod *meth;
+    bool virt, VMGenericClass* genClass) {
+  VMMethod *meth = NULL;
   
   if (genArgs != NULL) {
     VMClass* cl = dynamic_cast<VMClass*> (type);
@@ -1719,15 +1703,13 @@
     for (uint i = 0; i < cl->genericMethods.size(); ++i) {
       VMMethod* genMethod = cl->genericMethods.at(i);
 
-      if (!name->equals(genMethod->name) || !genMethod->signatureEqualsGeneric(
+      if ((name != genMethod->name) || !genMethod->signatureEqualsGeneric(
           args)) {
         continue;
       }
 
       // use found token to create instance of generic method
-      VMThread::get()->genMethodInstantiation = genArgs;
-      meth = readMethodDef(genMethod->token & 0xFFFFFF, type);
-      VMThread::get()->genMethodInstantiation = NULL;
+      meth = readMethodDef(genMethod->token & 0xFFFFFF, type, genArgs, genClass);
       meth->token = token;
     }
   } else {
@@ -1737,7 +1719,7 @@
   return meth;
 }
 
-VMMethod* Assembly::readMemberRefAsMethod(uint32 token, std::vector<VMCommonClass*>* genArgs) {
+VMMethod* Assembly::readMemberRefAsMethod(uint32 token, std::vector<VMCommonClass*>* genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 index = token & 0xffff;
   Table* memberTable = CLIHeader->tables[CONSTANT_MemberRef];
   uint32* memberArray = (uint32*)alloca(sizeof(uint32) * memberTable->rowSize);
@@ -1761,52 +1743,44 @@
   switch (table) {
     case 0 : {
       uint32 typeToken = index + (CONSTANT_TypeDef << 24);
-      VMCommonClass* type = loadType(((N3*)(VMThread::get()->vm)), typeToken, true, false, false, true);
-      bool virt = extractMethodSignature(offset, type, args);
-      VMMethod *meth = instantiateGenericMethod(genArgs, type, name, args, token, virt);
+      VMCommonClass* type = loadType(((N3*)(VMThread::get()->vm)), typeToken, true, false, false, true, genClass, genMethod);
+      bool virt = extractMethodSignature(offset, type, args, genClass, genMethod);
+      VMMethod *meth = instantiateGenericMethod(genArgs, type, name, args, token, virt, genClass);
       return meth;
     }
 
     case 1 : {
       uint32 typeToken = index + (CONSTANT_TypeRef << 24);
       VMCommonClass* type = loadType(((N3*)VMThread::get()->vm), typeToken,
-                                     true, false, false, true);
-      bool virt = extractMethodSignature(offset, type, args);
-      VMMethod *meth = instantiateGenericMethod(genArgs, type, name, args, token, virt);
+                                     true, false, false, true, genClass, genMethod);
+      bool virt = extractMethodSignature(offset, type, args, genClass, genMethod);
+      VMMethod *meth = instantiateGenericMethod(genArgs, type, name, args, token, virt, genClass);
       return meth;
     }
 
     case 2:
     case 3: VMThread::get()->vm->error("implement me %d", table); break;
     case 4: {
-      VMClass* type = (VMClass*) readTypeSpec(vm, index);
+      VMClass* type = (VMClass*) readTypeSpec(vm, index, genClass, genMethod);
         
       VMGenericClass* genClass = dynamic_cast<VMGenericClass*> (type);
   
       if (genClass) {
-        // temporarily store the current generic class, in case it's generic arguments
-        // are referenced in the current method
-        VMGenericClass* old = VMThread::get()->currGenericClass;
-        VMThread::get()->currGenericClass = genClass;
+        type->resolveType(false, false, genMethod);
         
-        type->resolveType(false, false);
-        
-        bool virt = extractMethodSignature(offset, type, args);
+        bool virt = extractMethodSignature(offset, type, args, genClass, genMethod);
         VMMethod* meth = instantiateGenericMethod(genArgs, type, name, args,
-            token, virt);
-        
-        // restore previous generic class
-        VMThread::get()->currGenericClass = old;
+            token, virt, genClass);
         
         return meth;
       } else {
-        type->resolveType(false, false);
+        type->resolveType(false, false, genMethod);
         
         VMMethod* meth = gc_new(VMMethod)() ;
-        bool virt = extractMethodSignature(offset, type, args);
+        bool virt = extractMethodSignature(offset, type, args, genClass, genMethod);
         bool structReturn = false;
         const llvm::FunctionType* signature = VMMethod::resolveSignature(args,
-            virt, structReturn);
+            virt, structReturn, genMethod);
         meth->_signature = signature;
         meth->classDef = type;
         meth->name = name;
@@ -1824,7 +1798,7 @@
   return 0;
 }
 
-VMMethod* Assembly::readMethodSpec(uint32 token) {
+VMMethod* Assembly::readMethodSpec(uint32 token, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 index = token & 0xffff;
   uint32 blobOffset = CLIHeader->blobStream->realOffset;
   
@@ -1839,7 +1813,7 @@
   uint32 offset = blobOffset + instantiation;
   
   std::vector<VMCommonClass*> genArgs;
-  methodSpecSignature(offset, genArgs);
+  methodSpecSignature(offset, genArgs, genClass, genMethod);
   
   uint32 table = method & 1;
   index = method >> 1;
@@ -1854,7 +1828,7 @@
     }
     case 1 : {
       methodToken = index + (CONSTANT_MemberRef << 24);
-      return readMemberRefAsMethod(methodToken, &genArgs);
+      return readMemberRefAsMethod(methodToken, &genArgs, genClass, genMethod);
     }
     default:
       VMThread::get()->vm->error("Invalid MethodSpec!");

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Assembly.h (original)
+++ vmkit/trunk/lib/N3/VMCore/Assembly.h Mon Aug 18 17:22:15 2008
@@ -49,6 +49,8 @@
 class VMField;
 class VMMethod;
 class VMObject;
+class VMGenericClass;
+class VMGenericMethod;
 
 class Section : public mvm::Object {
 public:
@@ -129,7 +131,7 @@
                              uint32 heapSizes);
 
 typedef VMCommonClass* (*signatureVector_t)(uint32 op, Assembly* ass,
-                                            uint32& offset);
+                                            uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod);
 
 class Assembly : public mvm::Object {
 public:
@@ -148,9 +150,9 @@
                                         std::vector<VMCommonClass*> genArgs,
                                         uint32 token);
   VMField*      constructField(VMClass* cl, const UTF8* name,
-                               VMCommonClass* signature, uint32 token);
+                               VMCommonClass* signature, uint32 token, VMGenericClass* genClass, VMGenericMethod* genMethod);
   VMMethod*     constructMethod(VMClass* cl, const UTF8* name,
-                                uint32 token, bool generic);
+                                uint32 token, bool generic, std::vector<VMCommonClass*>* genMethodInstantiation, VMGenericClass* genClass);
   VMCommonClass* lookupClassFromName(const UTF8* name, const UTF8* nameSpace);
   VMCommonClass* lookupClassFromToken(uint32 token);
   VMMethod* lookupMethodFromToken(uint32 token);
@@ -206,49 +208,50 @@
   uint32 uncompressSignature(uint32& offset);
   uint32 getTypeDefTokenFromMethod(uint32 token);
   VMCommonClass* loadType(N3* vm, uint32 token, bool resolveFunc, bool resolve,
-                          bool clinit, bool dothrow);
+                          bool clinit, bool dothrow, VMGenericClass* genClass, VMGenericMethod* genMethod);
   VMCommonClass* loadType(N3* vm, uint32 token, bool resolveFunc, bool resolve,
-                          bool clinit, bool dothrow, std::vector<VMCommonClass*> genArgs);
+                          bool clinit, bool dothrow, std::vector<VMCommonClass*> genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod);
   
   VMCommonClass* loadTypeFromName(const UTF8* name, const UTF8* nameSpace, 
                                   bool resolveFunc, bool resolve,
                                   bool clinit, bool dothrow);
-  void readClass(VMCommonClass* cl);
-  void getProperties(VMCommonClass* cl);
-  Property* readProperty(uint32 index, VMCommonClass* cl);
-  VMMethod* readMethodDef(uint32 index, VMCommonClass* cl);
-  VMMethod* readMethodSpec(uint32 token);
-  VMField* readField(uint32 index, VMCommonClass* cl);
+  void readClass(VMCommonClass* cl, VMGenericMethod* genMethod);
+  void getProperties(VMCommonClass* cl, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  Property* readProperty(uint32 index, VMCommonClass* cl, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  VMMethod* readMethodDef(uint32 index, VMCommonClass* cl,
+                          std::vector<VMCommonClass*>* genMethodInstantiation, VMGenericClass* genClass);
+  VMMethod* readMethodSpec(uint32 token, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  VMField* readField(uint32 index, VMCommonClass* cl, VMGenericClass* genClass, VMGenericMethod* genMethod);
   Param* readParam(uint32 index, VMMethod* meth);
   VMClass* readTypeDef(N3* vm, uint32 index);
   VMClass* readTypeDef(N3* vm, uint32 index, std::vector<VMCommonClass*> genArgs);
-  VMCommonClass* readTypeSpec(N3* vm, uint32 index);
+  VMCommonClass* readTypeSpec(N3* vm, uint32 index, VMGenericClass* genClass, VMGenericMethod* genMethod);
   Assembly* readAssemblyRef(N3* vm, uint32 index);
   VMCommonClass* readTypeRef(N3* vm, uint32 index);
-  void readSignature(uint32 offset, std::vector<VMCommonClass*>& locals);
+  void readSignature(uint32 offset, std::vector<VMCommonClass*>& locals, VMGenericClass* genClass, VMGenericMethod* genMethod);
   
   void getInterfacesFromTokenType(std::vector<uint32>& tokens, uint32 token);
   
   bool extractMethodSignature(uint32& offset, VMCommonClass* cl,
-                              std::vector<VMCommonClass*> &params);
+                              std::vector<VMCommonClass*> &params, VMGenericClass* genClass, VMGenericMethod* genMethod);
   bool isGenericMethod(uint32& offset);
   void localVarSignature(uint32& offset,
-                         std::vector<VMCommonClass*>& locals);
+                         std::vector<VMCommonClass*>& locals, VMGenericClass* genClass, VMGenericMethod* genMethod);
   void methodSpecSignature(uint32& offset,
-                           std::vector<VMCommonClass*>& genArgs);
-  VMCommonClass* extractFieldSignature(uint32& offset);
-  VMCommonClass* extractTypeInSignature(uint32& offset);
-  VMCommonClass* exploreType(uint32& offset); 
+                           std::vector<VMCommonClass*>& genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  VMCommonClass* extractFieldSignature(uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  VMCommonClass* extractTypeInSignature(uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  VMCommonClass* exploreType(uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod); 
   
   VMCommonClass* getClassFromName(N3* vm, const UTF8* name, const UTF8* nameSpace);
   
-  VMField* getFieldFromToken(uint32 token, bool stat); 
+  VMField* getFieldFromToken(uint32 token, bool stat, VMGenericClass* genClass, VMGenericMethod* genMethod); 
   uint32 getTypedefTokenFromField(uint32 token);
-  VMField* readMemberRefAsField(uint32 token, bool stat);
+  VMField* readMemberRefAsField(uint32 token, bool stat, VMGenericClass* genClass, VMGenericMethod* genMethod);
   
-  VMMethod* getMethodFromToken(uint32 token); 
+  VMMethod* getMethodFromToken(uint32 token, VMGenericClass* genClass, VMGenericMethod* genMethod); 
   uint32 getTypedefTokenFromMethod(uint32 token);
-  VMMethod* readMemberRefAsMethod(uint32 token, std::vector<VMCommonClass*>* genArgs);
+  VMMethod* readMemberRefAsMethod(uint32 token, std::vector<VMCommonClass*>* genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod);
 
   const UTF8* readUserString(uint32 token); 
   uint32 getExplicitLayout(uint32 token);
@@ -260,7 +263,7 @@
   void readCustomAttributes(uint32 offset, std::vector<llvm::GenericValue>& args, VMMethod* meth);
   ArrayObject* getCustomAttributes(uint32 token, VMCommonClass* cl);
 private:
-    VMMethod *instantiateGenericMethod(std::vector<VMCommonClass*> *genArgs, VMCommonClass *type, const UTF8 *& name, std::vector<VMCommonClass*> & args, uint32 token, bool virt);
+    VMMethod *instantiateGenericMethod(std::vector<VMCommonClass*> *genArgs, VMCommonClass *type, const UTF8 *& name, std::vector<VMCommonClass*> & args, uint32 token, bool virt, VMGenericClass* genClass);
 
 
 };

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Mon Aug 18 17:22:15 2008
@@ -453,34 +453,25 @@
 }
 
 Instruction* CLIJit::invokeInline(VMMethod* meth, 
-                                  std::vector<Value*>& args) {
+                                  std::vector<Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   
   CLIJit* jit = gc_new(CLIJit)();
   jit->compilingClass = meth->classDef; 
   jit->compilingMethod = meth;
   
-  // save previous current generic class to restore it later
-  VMGenericClass* old = VMThread::get()->currGenericClass;
-  // temporarily store the class being compiled in case it is a generic class
-  VMThread::get()->currGenericClass = dynamic_cast<VMGenericClass*>(jit->compilingClass);
-  
-  
   jit->unifiedUnreachable = unifiedUnreachable;
   jit->inlineMethods = inlineMethods;
   jit->inlineMethods[meth] = true;
   Instruction* ret = jit->inlineCompile(llvmFunction, currentBlock, 
-                                        currentExceptionBlock, args);
+                                        currentExceptionBlock, args, dynamic_cast<VMGenericClass*>(jit->compilingClass), genMethod);
   inlineMethods[meth] = false;
   
-  // restore saved class
-  VMThread::get()->currGenericClass = old;
-  
   return ret;
 }
 
 
-void CLIJit::invoke(uint32 value) {
-  VMMethod* meth = compilingClass->assembly->getMethodFromToken(value);
+void CLIJit::invoke(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMMethod* meth = compilingClass->assembly->getMethodFromToken(value, genClass, genMethod);
 
   if (meth->classDef->isArray) {
     uint8 func = 0;
@@ -530,7 +521,7 @@
   }
 
   std::vector<Value*> Args;
-  const llvm::FunctionType* type = meth->getSignature();
+  const llvm::FunctionType* type = meth->getSignature(genMethod);
   makeArgs(type, Args, meth->structReturn);
   
   if (meth->classDef->nameSpace == N3::system && 
@@ -599,9 +590,9 @@
   Value* res = 0;
   if (meth && meth->canBeInlined && meth != compilingMethod && 
       inlineMethods[meth] == 0) {
-    res = invokeInline(meth, Args);
+    res = invokeInline(meth, Args, genClass, genMethod);
   } else {
-    Function* func = meth->compiledPtr();
+    Function* func = meth->compiledPtr(genMethod);
     
     res = invoke(func, Args, "", currentBlock, meth->structReturn);
   }
@@ -610,11 +601,11 @@
   }
 }
 
-void CLIJit::invokeNew(uint32 value) {
+void CLIJit::invokeNew(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   Assembly* ass = compilingClass->assembly;
-  VMMethod* meth = ass->getMethodFromToken(value);
+  VMMethod* meth = ass->getMethodFromToken(value, genClass, genMethod);
   VMClass* type = meth->classDef;
-  const FunctionType* funcType = meth->getSignature();
+  const FunctionType* funcType = meth->getSignature(genMethod);
     
   Value* obj = 0;
   if (type->isPointer) {
@@ -661,9 +652,9 @@
   makeArgs(funcType, Args, meth->structReturn);
   if (meth && meth->canBeInlined && meth != compilingMethod && 
       inlineMethods[meth] == 0) {
-    invokeInline(meth, Args);
+    invokeInline(meth, Args, genClass, genMethod);
   } else {
-    Function* func = meth->compiledPtr();
+    Function* func = meth->compiledPtr(genMethod);
     
     invoke(func, Args, "", currentBlock, meth->structReturn);
   }
@@ -676,8 +667,8 @@
   }
 }
   
-llvm::Value* CLIJit::getVirtualField(uint32 value) {
-  VMField* field = compilingClass->assembly->getFieldFromToken(value, false);
+llvm::Value* CLIJit::getVirtualField(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMField* field = compilingClass->assembly->getFieldFromToken(value, false, genClass, genMethod);
   Value* obj = pop();
   if ((field->classDef->super == MSCorlib::pValue ||
       field->classDef->super == MSCorlib::pEnum) &&
@@ -699,10 +690,10 @@
   }
 }
 
-llvm::Value* CLIJit::getStaticField(uint32 value) {
-  VMField* field = compilingClass->assembly->getFieldFromToken(value, true);
+llvm::Value* CLIJit::getStaticField(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMField* field = compilingClass->assembly->getFieldFromToken(value, true, genClass, genMethod);
   VMCommonClass* cl = field->classDef;
-  cl->resolveType(true, false);
+  cl->resolveType(true, false, genMethod);
   Value* arg = new LoadInst(cl->llvmVar(), "", currentBlock);
   Value* call = invoke(initialiseClassLLVM, arg, "", currentBlock, false);
   Value* staticCl = new BitCastInst(call, cl->staticType, "", currentBlock);
@@ -717,8 +708,8 @@
 
 }
   
-void CLIJit::setVirtualField(uint32 value, bool isVolatile) {
-  VMField* field = compilingClass->assembly->getFieldFromToken(value, false);
+void CLIJit::setVirtualField(uint32 value, bool isVolatile, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMField* field = compilingClass->assembly->getFieldFromToken(value, false, genClass, genMethod);
   Value* val = pop();
   Value* obj = pop();
   const Type* valType = val->getType();
@@ -765,8 +756,8 @@
   }
 }
 
-void CLIJit::setStaticField(uint32 value, bool isVolatile) {
-  VMField* field = compilingClass->assembly->getFieldFromToken(value, true);
+void CLIJit::setStaticField(uint32 value, bool isVolatile, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMField* field = compilingClass->assembly->getFieldFromToken(value, true, genClass, genMethod);
   
   VMCommonClass* cl = field->classDef;
   Value* arg = new LoadInst(cl->llvmVar(), "", currentBlock);
@@ -936,11 +927,11 @@
   return 0;
 }
 
-Function* CLIJit::compileNative() {
+Function* CLIJit::compileNative(VMGenericMethod* genMethod) {
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "native compile %s\n",
               compilingMethod->printString());
     
-  const FunctionType *funcType = compilingMethod->getSignature();
+  const FunctionType *funcType = compilingMethod->getSignature(genMethod);
   
   Function* func = llvmFunction = compilingMethod->methPtr;
   currentBlock = createBasicBlock("start");
@@ -977,7 +968,7 @@
   return llvmFunction;
 }
 
-uint32 CLIJit::readExceptionTable(uint32 offset, bool fat) {
+uint32 CLIJit::readExceptionTable(uint32 offset, bool fat, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   Assembly* ass = compilingClass->assembly;
   ArrayUInt8* bytes = ass->bytes;
   uint32 nbe = 0;
@@ -1027,7 +1018,7 @@
       ex->test = createBasicBlock("testException");
       if (classToken) {
         ex->catchClass = ass->loadType((N3*)VMThread::get()->vm, classToken,
-                                       true, false, false, true);
+                                       true, false, false, true, genClass, genMethod);
       } else {
         ex->catchClass = MSCorlib::pException;
       }
@@ -1158,7 +1149,7 @@
 }
 #endif
 
-Function* CLIJit::compileFatOrTiny() {
+Function* CLIJit::compileFatOrTiny(VMGenericClass* genClass, VMGenericMethod* genMethod) {
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "tiny or fat compile %s\n",
               compilingMethod->printString());
   uint32 offset = compilingMethod->offset;
@@ -1187,7 +1178,7 @@
   bool synchro = isSynchro(compilingMethod->flags);
   */
 
-  const FunctionType *funcType = compilingMethod->getSignature();
+  const FunctionType *funcType = compilingMethod->getSignature(genMethod);
   
   Function* func = llvmFunction = compilingMethod->methPtr;
   currentBlock = createBasicBlock("start");
@@ -1212,7 +1203,7 @@
 
       uint8 flags = READ_U1(bytes, excpOffset);
       nbe = readExceptionTable(excpOffset, 
-                         flags & CONSTANT_CorILMethod_Sect_FatFormat);
+                         flags & CONSTANT_CorILMethod_Sect_FatFormat, genClass, genMethod);
     }
   }
 
@@ -1228,12 +1219,12 @@
   
   if (localVarSig) {
     std::vector<VMCommonClass*> temp;
-    compilingClass->assembly->readSignature(localVarSig, temp);
+    compilingClass->assembly->readSignature(localVarSig, temp, genClass, genMethod);
 
     for (std::vector<VMCommonClass*>::iterator i = temp.begin(), 
             e = temp.end(); i!= e; ++i) {
       VMCommonClass* cl = *i;
-      cl->resolveType(false, false);
+      cl->resolveType(false, false, genMethod);
       AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock);
       if (cl->naturalType->isSingleValueType()) {
         new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false,
@@ -1268,7 +1259,7 @@
     endNode = PHINode::Create(lastType, "", endBlock);
   }
 
-  compileOpcodes(&compilingClass->assembly->bytes->elements[offset], codeLen);
+  compileOpcodes(&compilingClass->assembly->bytes->elements[offset], codeLen, genClass, genMethod);
   
   currentBlock = endBlock;
   pred_iterator PI = pred_begin(endBlock);
@@ -1335,7 +1326,7 @@
 
 Instruction* CLIJit::inlineCompile(Function* parentFunction, BasicBlock*& curBB,
                                    BasicBlock* endExBlock,
-                                   std::vector<Value*>& args) {
+                                   std::vector<Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   
   PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "tiny or fat inline compile %s\n",
               compilingMethod->printString());
@@ -1364,7 +1355,7 @@
   bool synchro = isSynchro(compilingMethod->flags);
   */
 
-  const FunctionType *funcType = compilingMethod->getSignature();
+  const FunctionType *funcType = compilingMethod->getSignature(genMethod);
   
   llvmFunction = parentFunction;
   currentBlock = curBB;
@@ -1389,7 +1380,7 @@
 
       uint8 flags = READ_U1(bytes, excpOffset);
       readExceptionTable(excpOffset, 
-                         flags & CONSTANT_CorILMethod_Sect_FatFormat);
+                         flags & CONSTANT_CorILMethod_Sect_FatFormat, genClass, genMethod);
     }
   }
 
@@ -1405,12 +1396,12 @@
 
   if (localVarSig) {
     std::vector<VMCommonClass*> temp;
-    compilingClass->assembly->readSignature(localVarSig, temp);
+    compilingClass->assembly->readSignature(localVarSig, temp, genClass, genMethod);
 
     for (std::vector<VMCommonClass*>::iterator i = temp.begin(), 
             e = temp.end(); i!= e; ++i) {
       VMCommonClass* cl = *i;
-      cl->resolveType(false, false);
+      cl->resolveType(false, false, genMethod);
       AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock);
       if (cl->naturalType->isSingleValueType()) {
         new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false,
@@ -1445,7 +1436,7 @@
     endNode = PHINode::Create(lastType, "", endBlock);
   }
 
-  compileOpcodes(&compilingClass->assembly->bytes->elements[offset], codeLen);
+  compileOpcodes(&compilingClass->assembly->bytes->elements[offset], codeLen, genClass, genMethod);
   
   curBB = endBlock;
   
@@ -1462,41 +1453,26 @@
   jit->compilingClass = cl; 
   jit->compilingMethod = meth;
 
-  // save previous generic and method class
-  VMGenericClass* old = VMThread::get()->currGenericClass;
-  VMGenericMethod* oldMethod = VMThread::get()->currGenericMethod;
-  
-  // temporarily store the class of the method to be compiled
-  // in case it is a generic class 
-  VMThread::get()->currGenericClass = dynamic_cast<VMGenericClass*>(cl);
-  
-  VMThread::get()->currGenericMethod = dynamic_cast<VMGenericMethod*>(meth);
-  
   Function* func;
-  meth->getSignature();
+  meth->getSignature(dynamic_cast<VMGenericMethod*>(meth));
   
   if (isInternal(meth->implFlags)) {
-    func = jit->compileNative();
+    func = jit->compileNative(dynamic_cast<VMGenericMethod*>(meth));
   } else if (meth->offset == 0) {
     func = jit->compileIntern();
   } else {
-    func = jit->compileFatOrTiny();
+    func = jit->compileFatOrTiny(dynamic_cast<VMGenericClass*>(cl), dynamic_cast<VMGenericMethod*>(meth));
   }
   
-  // restore saved class
-  VMThread::get()->currGenericClass = old;
-  
-  VMThread::get()->currGenericMethod = oldMethod;
-  
   return func;
 }
 
-llvm::Function *VMMethod::compiledPtr() {
+llvm::Function *VMMethod::compiledPtr(VMGenericMethod* genMethod) {
   if (methPtr != 0) return methPtr;
   else {
     classDef->aquire();
     if (methPtr == 0) {
-      methPtr = Function::Create(getSignature(), GlobalValue::GhostLinkage,
+      methPtr = Function::Create(getSignature(genMethod), GlobalValue::GhostLinkage,
                                    printString(), classDef->vm->module);
       classDef->vm->functions->hash(methPtr, this);
     }
@@ -1522,7 +1498,7 @@
 }
 
 extern "C" VMObject* initialiseClass(VMClass* cl) {
-  cl->clinitClass();
+  cl->clinitClass(NULL);
   return cl->staticInstance;
 }
 

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Mon Aug 18 17:22:15 2008
@@ -36,6 +36,8 @@
 class VMCommonClass;
 class VMMethod;
 class VMObject;
+class VMGenericClass;
+class VMGenericMethod;
 
 class Exception : public mvm::Object {
 public:
@@ -85,7 +87,7 @@
   static VirtualTable* makeArrayVT(VMClassArray* cl);
   
   static void printExecution(char*, n3::VMMethod*);
-  void compileOpcodes(uint8*, uint32);
+  void compileOpcodes(uint8*, uint32, VMGenericClass* genClass, VMGenericMethod* genMethod);
   void exploreOpcodes(uint8*, uint32);
   
   llvm::Function* llvmFunction;
@@ -121,18 +123,18 @@
   llvm::BasicBlock* unifiedUnreachable;
   std::vector<Exception*> exceptions;
   std::vector<Exception*> finallyHandlers;
-  uint32 readExceptionTable(uint32 offset, bool fat);
+  uint32 readExceptionTable(uint32 offset, bool fat, VMGenericClass* genClass, VMGenericMethod* genMethod);
   std::vector<llvm::BasicBlock*> leaves; 
   llvm::Value* supplLocal;
 
   // calls
-  void invoke(uint32 value);
-  void invokeInterfaceOrVirtual(uint32 value);
-  void invokeNew(uint32 value);
-  llvm::Value* getVirtualField(uint32 value);
-  llvm::Value* getStaticField(uint32 value);
-  void setVirtualField(uint32 value, bool isVolatile);
-  void setStaticField(uint32 value, bool isVolatile);
+  void invoke(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  void invokeInterfaceOrVirtual(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  void invokeNew(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  llvm::Value* getVirtualField(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  llvm::Value* getStaticField(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  void setVirtualField(uint32 value, bool isVolatile, VMGenericClass* genClass, VMGenericMethod* genMethod);
+  void setStaticField(uint32 value, bool isVolatile, VMGenericClass* genClass, VMGenericMethod* genMethod);
 
   void JITVerifyNull(llvm::Value* obj);
   
@@ -174,8 +176,8 @@
   static void initialiseAppDomain(N3* vm);
   static void initialiseBootstrapVM(N3* vm);
 
-  llvm::Function* compileNative();
-  llvm::Function* compileFatOrTiny();
+  llvm::Function* compileNative(VMGenericMethod* genMethod);
+  llvm::Function* compileFatOrTiny(VMGenericClass* genClass, VMGenericMethod* genMethod);
   llvm::Function* compileIntern();
 
   llvm::Function* createDelegate();
@@ -211,12 +213,12 @@
   llvm::Instruction* inlineCompile(llvm::Function* parentFunction, 
                                    llvm::BasicBlock*& curBB,
                                    llvm::BasicBlock* endExBlock,
-                                   std::vector<llvm::Value*>& args);
+                                   std::vector<llvm::Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod);
 
   std::map<VMMethod*, bool> inlineMethods;
 
   llvm::Instruction* invokeInline(VMMethod* meth, 
-                                  std::vector<llvm::Value*>& args);
+                                  std::vector<llvm::Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod);
 
 };
 

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Mon Aug 18 17:22:15 2008
@@ -29,14 +29,14 @@
 
 VMObject* VMClass::operator()() {
   if (status < ready) 
-    resolveType(true, true);
+    resolveType(true, true, NULL);
   return doNew();
 }
 
 void VMField::operator()(VMObject* obj, float val) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) obj = classDef->staticInstance;
@@ -54,7 +54,7 @@
 void VMField::operator()(VMObject* obj, double val) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) obj = classDef->staticInstance;
@@ -72,7 +72,7 @@
 void VMField::operator()(VMObject* obj, sint64 val) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) obj = classDef->staticInstance;
@@ -90,7 +90,7 @@
 void VMField::operator()(VMObject* obj, sint32 val) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) obj = classDef->staticInstance;
@@ -108,7 +108,7 @@
 void VMField::operator()(VMObject* obj, VMObject* val) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) obj = classDef->staticInstance;
@@ -125,7 +125,7 @@
 void VMField::operator()(VMObject* obj, bool val) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) obj = classDef->staticInstance;
@@ -143,7 +143,7 @@
 GenericValue VMField::operator()(VMObject* obj) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
   bool stat = isStatic(flags);
   if (stat) {
@@ -193,9 +193,9 @@
 GenericValue VMMethod::operator()(va_list ap) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
-  Function* func = compiledPtr();
+  Function* func = compiledPtr(NULL);
   
   std::vector<GenericValue> args;
   for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end();
@@ -237,9 +237,9 @@
 GenericValue VMMethod::operator()(VMObject* obj, va_list ap) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
-  Function* func = compiledPtr();
+  Function* func = compiledPtr(NULL);
   
   std::vector<GenericValue> args;
   GenericValue object(obj);
@@ -301,9 +301,9 @@
 GenericValue VMMethod::operator()(std::vector<GenericValue>& args) {
   
   if (classDef->status < ready) 
-    classDef->resolveType(true, true);
+    classDef->resolveType(true, true, NULL);
   
-  Function* func = compiledPtr();
+  Function* func = compiledPtr(NULL);
   return mvm::jit::executionEngine->runFunction(func, args);
 }
 

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLISignature.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLISignature.cpp Mon Aug 18 17:22:15 2008
@@ -22,133 +22,162 @@
 // ECMA 335: page 150 23.1.16 Element types used in signatures 
 
 
-static VMCommonClass* METHOD_ElementTypeEnd(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeEnd(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypeVoid(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeVoid(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pVoid;
 }
 
-static VMCommonClass* METHOD_ElementTypeBoolean(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeBoolean(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pBoolean;
 }
 
-static VMCommonClass* METHOD_ElementTypeChar(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeChar(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pChar;
 }
 
-static VMCommonClass* METHOD_ElementTypeI1(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeI1(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pSInt8;
 }
 
-static VMCommonClass* METHOD_ElementTypeU1(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeU1(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pUInt8;
 }
 
-static VMCommonClass* METHOD_ElementTypeI2(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeI2(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pSInt16;
 }
 
-static VMCommonClass* METHOD_ElementTypeU2(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeU2(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pUInt16;
 }
 
-static VMCommonClass* METHOD_ElementTypeI4(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeI4(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pSInt32;
 }
 
-static VMCommonClass* METHOD_ElementTypeU4(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeU4(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pUInt32;
 }
 
-static VMCommonClass* METHOD_ElementTypeI8(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeI8(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pSInt64;
 }
 
-static VMCommonClass* METHOD_ElementTypeU8(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeU8(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pUInt64;
 }
 
-static VMCommonClass* METHOD_ElementTypeR4(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeR4(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pFloat;
 }
 
-static VMCommonClass* METHOD_ElementTypeR8(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeR8(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pDouble;
 }
 
-static VMCommonClass* METHOD_ElementTypeString(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeString(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pString;
 }
 
-static VMCommonClass* METHOD_ElementTypePtr(uint32 op, Assembly* ass, uint32& offset) {
-  VMCommonClass* contains = ass->exploreType(offset);
+static VMCommonClass* METHOD_ElementTypePtr(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMCommonClass* contains = ass->exploreType(offset, genClass, genMethod);
   return ass->constructPointer(contains, 1);
 }
 
-static VMCommonClass* METHOD_ElementTypeByRef(uint32 op, Assembly* ass, uint32& offset) {
-  VMCommonClass* contains = ass->exploreType(offset);
+static VMCommonClass* METHOD_ElementTypeByRef(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMCommonClass* contains = ass->exploreType(offset, genClass, genMethod);
   return ass->constructPointer(contains, 1);
 }
 
 static VMCommonClass* METHOD_ElementTypeValueType(uint32 op, Assembly* ass,
-                                                     uint32& offset) {
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 value = ass->uncompressSignature(offset);
   uint32 table = value & 3;
   uint32 index = value >> 2;
   uint32 token = 0;
 
-
   switch (table) {
-    case 0: table = CONSTANT_TypeDef; break;
-    case 1: table = CONSTANT_TypeRef; break;
-    case 2: table = CONSTANT_TypeSpec; break;
-    default:
-      VMThread::get()->vm->error("unknown TypeDefOrRefEncoded %d", index);
-      break;
+  case 0:
+    table = CONSTANT_TypeDef;
+    break;
+  case 1:
+    table = CONSTANT_TypeRef;
+    break;
+  case 2:
+    table = CONSTANT_TypeSpec;
+    break;
+  default:
+    VMThread::get()->vm->error("unknown TypeDefOrRefEncoded %d", index);
+    break;
   }
 
   token = (table << 24) + index;
-  VMCommonClass* cl = ass->loadType((N3*)(VMThread::get()->vm), token, false,
-                                    false, false, true);
+  VMCommonClass* cl = ass->loadType((N3*) (VMThread::get()->vm), token, false,
+      false, false, true, genClass, genMethod);
   return cl;
 }
 
-static VMCommonClass* METHOD_ElementTypeClass(uint32 op, 
-                                              Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeClass(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 value = ass->uncompressSignature(offset);
   uint32 table = value & 3;
   uint32 index = value >> 2;
   uint32 token = 0;
 
-
   switch (table) {
-    case 0: table = CONSTANT_TypeDef; break;
-    case 1: table = CONSTANT_TypeRef; break;
-    case 2: table = CONSTANT_TypeSpec; break;
-    default:
-      VMThread::get()->vm->error("unknown TypeDefOrRefEncoded %d", index);
-      break;
+  case 0:
+    table = CONSTANT_TypeDef;
+    break;
+  case 1:
+    table = CONSTANT_TypeRef;
+    break;
+  case 2:
+    table = CONSTANT_TypeSpec;
+    break;
+  default:
+    VMThread::get()->vm->error("unknown TypeDefOrRefEncoded %d", index);
+    break;
   }
 
   token = (table << 24) + index;
-  VMCommonClass* cl = ass->loadType((N3*)(VMThread::get()->vm), token, false, 
-                                    false, false, true);
+  VMCommonClass* cl = ass->loadType((N3*) (VMThread::get()->vm), token, false,
+      false, false, true, genClass, genMethod);
   return cl;
 }
 
-static VMCommonClass* METHOD_ElementTypeVar(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeVar(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 number = ass->uncompressSignature(offset);
-  
-  assert(VMThread::get()->currGenericClass != NULL && "Current Generic Class not set!");
-  
-  return VMThread::get()->currGenericClass->genericParams[number];
+
+  assert(genClass != NULL && "Current Generic Class not set!");
+
+  return genClass->genericParams[number];
 }
 
-static VMCommonClass* METHOD_ElementTypeArray(uint32 op, Assembly* ass, uint32& offset) {
-  VMCommonClass* cl = ass->exploreType(offset);
+static VMCommonClass* METHOD_ElementTypeArray(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMCommonClass* cl = ass->exploreType(offset, genClass, genMethod);
   uint32 rank = ass->uncompressSignature(offset);
   uint32 numSizes = ass->uncompressSignature(offset);
 
@@ -162,17 +191,19 @@
   }
 
   uint32 numObounds = ass->uncompressSignature(offset);
-  if (numObounds != 0) VMThread::get()->vm->error("implement me");
+  if (numObounds != 0)
+    VMThread::get()->vm->error("implement me");
 
   for (uint32 i = 0; i < numObounds; ++i) {
     ass->uncompressSignature(offset);
   }
-  
+
   VMClassArray* array = ass->constructArray(cl, rank);
   return array;
 }
 
-static VMCommonClass* METHOD_ElementTypeGenericInst(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeGenericInst(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   // offset points to (CLASS | VALUETYPE) TypeDefOrRefEncoded
 
   // skip generic type definition
@@ -180,25 +211,25 @@
 
   // save starting offset for later use
   uint32 genericTypeOffset = offset;
-  
+
   ass->uncompressSignature(offset); // TypeDefOrRefEncoded
 
   //VMCommonClass* cl = ass->exploreType(offset);
-  
+
   uint32 argCount = ass->uncompressSignature(offset);
-  
+
   std::vector<VMCommonClass*> args;
-  
+
   // Get generic arguments.
   for (uint32 i = 0; i < argCount; ++i) {
-	  args.push_back(ass->exploreType(offset));
+    args.push_back(ass->exploreType(offset, genClass, genMethod));
   }
 
   // save offset
   uint32 endOffset = offset;
   // restore starting offset
   offset = genericTypeOffset;
-  
+
   // TypeDefOrRefEncoded
   uint32 value = ass->uncompressSignature(offset);
   uint32 table = value & 3;
@@ -206,57 +237,72 @@
   uint32 token = 0;
 
   switch (table) {
-    case 0: table = CONSTANT_TypeDef; break;
-    case 1: table = CONSTANT_TypeRef; break;
-    case 2: table = CONSTANT_TypeSpec; break;
-    default:
-      VMThread::get()->vm->error("unknown TypeDefOrRefEncoded %d", index);
-      break;
+  case 0:
+    table = CONSTANT_TypeDef;
+    break;
+  case 1:
+    table = CONSTANT_TypeRef;
+    break;
+  case 2:
+    table = CONSTANT_TypeSpec;
+    break;
+  default:
+    VMThread::get()->vm->error("unknown TypeDefOrRefEncoded %d", index);
+    break;
   }
 
   token = (table << 24) + index;
-  VMCommonClass* cl = ass->loadType((N3*)(VMThread::get()->vm), token, false, 
-                                    false, false, true, args);
+  VMCommonClass* cl = ass->loadType((N3*) (VMThread::get()->vm), token, false,
+      false, false, true, args, genClass, genMethod);
   // restore endOffset
   offset = endOffset;
-  
+
   return cl;
 }
 
-static VMCommonClass* METHOD_ElementTypeTypedByRef(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeTypedByRef(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::typedReference;
 }
 
-static VMCommonClass* METHOD_ElementTypeI(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeI(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pIntPtr;
 }
 
-static VMCommonClass* METHOD_ElementTypeU(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeU(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pUIntPtr;
 }
 
-static VMCommonClass* METHOD_ElementTypeFnptr(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeFnptr(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypeObject(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeObject(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return MSCorlib::pObject;
 }
 
-static VMCommonClass* METHOD_ElementTypeSzarray(uint32 op, Assembly* ass, uint32& offset) {
-  VMCommonClass* contains = ass->exploreType(offset);
+static VMCommonClass* METHOD_ElementTypeSzarray(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
+  VMCommonClass* contains = ass->exploreType(offset, genClass, genMethod);
   VMClassArray* res = ass->constructArray(contains, 1);
   return res;
 }
 
-static VMCommonClass* METHOD_ElementTypeMvar(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeMvar(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod *currGenericMethod) {
   uint32 number = ass->uncompressSignature(offset);
-  
-  if (VMThread::get()->currGenericMethod == NULL) {
-    // return dummy VMClass, use the token field
-    // to store the generic argument number
-    VMClass* cl = gc_new(VMClass)();
+
+  if (currGenericMethod == NULL) {
+    // when reading in signatures which contain references to generic arguments
+    // of generic methods we need create a placeholder for each of them,
+    // this is done by creating a dummy VMClass which has the assembly field
+    // set to NULL, the token field is used to store the generic argument number
+    VMClass* cl = gc_new(VMClass)() ;
     cl->token = number;
     cl->assembly = NULL;
     cl->nameSpace = UTF8::asciizConstruct(VMThread::get()->vm, "");
@@ -265,159 +311,165 @@
     cl->name = UTF8::asciizConstruct(VMThread::get()->vm, tmp);
     return cl;
   } else {
-    return VMThread::get()->currGenericMethod->genericParams[number];
+    return currGenericMethod->genericParams[number];
   }
 }
 
-static VMCommonClass* METHOD_ElementTypeCmodReqd(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeCmodReqd(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypeCmodOpt(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeCmodOpt(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypeInternal(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeInternal(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypeModifier(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeModifier(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypeSentinel(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypeSentinel(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("implement me");
   return 0;
 }
 
-static VMCommonClass* METHOD_ElementTypePinned(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* METHOD_ElementTypePinned(uint32 op, Assembly* ass,
+    uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   return 0;
 }
 
-static VMCommonClass* unimplemented(uint32 op, Assembly* ass, uint32& offset) {
+static VMCommonClass* unimplemented(uint32 op, Assembly* ass, uint32& offset,
+    VMGenericClass* genClass, VMGenericMethod* genMethod) {
   VMThread::get()->vm->error("unknown signature");
   return 0;
 }
 
-signatureVector_t Assembly::signatureVector[0x46] = {
-  METHOD_ElementTypeEnd,           // 0x00
-  METHOD_ElementTypeVoid,          // 0x01
-  METHOD_ElementTypeBoolean,       // 0x02
-  METHOD_ElementTypeChar,          // 0x03
-  METHOD_ElementTypeI1,            // 0x04
-  METHOD_ElementTypeU1,            // 0x05
-  METHOD_ElementTypeI2,            // 0x06
-  METHOD_ElementTypeU2,            // 0x07
-  METHOD_ElementTypeI4,            // 0x08
-  METHOD_ElementTypeU4,            // 0x09
-  METHOD_ElementTypeI8,            // 0x0A
-  METHOD_ElementTypeU8,            // 0x0B
-  METHOD_ElementTypeR4,            // 0x0C
-  METHOD_ElementTypeR8,            // 0x0D
-  METHOD_ElementTypeString,        // 0x0E
-  METHOD_ElementTypePtr,           // 0x1F
-  METHOD_ElementTypeByRef,         // 0x10
-  METHOD_ElementTypeValueType,     // 0x11
-  METHOD_ElementTypeClass,         // 0x12
-  METHOD_ElementTypeVar,           // 0x13
-  METHOD_ElementTypeArray,         // 0x14
-  METHOD_ElementTypeGenericInst,   // 0x15
-  METHOD_ElementTypeTypedByRef,    // 0x16
-  unimplemented,                   // 0x17
-  METHOD_ElementTypeI,             // 0x18
-  METHOD_ElementTypeU,             // 0x19
-  unimplemented,                   // 0x1A
-  METHOD_ElementTypeFnptr,         // 0x1B
-  METHOD_ElementTypeObject,        // 0x1C
-  METHOD_ElementTypeSzarray,       // 0x1D
-  METHOD_ElementTypeMvar,          // 0x1E
-  METHOD_ElementTypeCmodReqd,      // 0x1F
-  METHOD_ElementTypeCmodOpt,       // 0x20
-  METHOD_ElementTypeInternal,      // 0x21
-  METHOD_ElementTypeModifier,      // 0x22
-  unimplemented,                   // 0x23
-  unimplemented,                   // 0x24
-  unimplemented,                   // 0x25
-  unimplemented,                   // 0x26
-  unimplemented,                   // 0x27
-  unimplemented,                   // 0x28
-  unimplemented,                   // 0x29
-  unimplemented,                   // 0x2A
-  unimplemented,                   // 0x2B
-  unimplemented,                   // 0x2C
-  unimplemented,                   // 0x2D
-  unimplemented,                   // 0x2E
-  unimplemented,                   // 0x2F
-  unimplemented,                   // 0x30
-  unimplemented,                   // 0x31
-  unimplemented,                   // 0x32
-  unimplemented,                   // 0x33
-  unimplemented,                   // 0x34
-  unimplemented,                   // 0x35
-  unimplemented,                   // 0x36
-  unimplemented,                   // 0x37
-  unimplemented,                   // 0x38
-  unimplemented,                   // 0x39
-  unimplemented,                   // 0x3A
-  unimplemented,                   // 0x3B
-  unimplemented,                   // 0x3C
-  unimplemented,                   // 0x3D
-  unimplemented,                   // 0x3E
-  unimplemented,                   // 0x3F
-  unimplemented,                   // 0x40
-  METHOD_ElementTypeSentinel,      // 0x41
-  unimplemented,                   // 0x42
-  unimplemented,                   // 0x43
-  unimplemented,                   // 0x44
-  METHOD_ElementTypePinned         // 0x45
-};
+signatureVector_t Assembly::signatureVector[0x46] = { METHOD_ElementTypeEnd, // 0x00
+    METHOD_ElementTypeVoid, // 0x01
+    METHOD_ElementTypeBoolean, // 0x02
+    METHOD_ElementTypeChar, // 0x03
+    METHOD_ElementTypeI1, // 0x04
+    METHOD_ElementTypeU1, // 0x05
+    METHOD_ElementTypeI2, // 0x06
+    METHOD_ElementTypeU2, // 0x07
+    METHOD_ElementTypeI4, // 0x08
+    METHOD_ElementTypeU4, // 0x09
+    METHOD_ElementTypeI8, // 0x0A
+    METHOD_ElementTypeU8, // 0x0B
+    METHOD_ElementTypeR4, // 0x0C
+    METHOD_ElementTypeR8, // 0x0D
+    METHOD_ElementTypeString, // 0x0E
+    METHOD_ElementTypePtr, // 0x1F
+    METHOD_ElementTypeByRef, // 0x10
+    METHOD_ElementTypeValueType, // 0x11
+    METHOD_ElementTypeClass, // 0x12
+    METHOD_ElementTypeVar, // 0x13
+    METHOD_ElementTypeArray, // 0x14
+    METHOD_ElementTypeGenericInst, // 0x15
+    METHOD_ElementTypeTypedByRef, // 0x16
+    unimplemented, // 0x17
+    METHOD_ElementTypeI, // 0x18
+    METHOD_ElementTypeU, // 0x19
+    unimplemented, // 0x1A
+    METHOD_ElementTypeFnptr, // 0x1B
+    METHOD_ElementTypeObject, // 0x1C
+    METHOD_ElementTypeSzarray, // 0x1D
+    METHOD_ElementTypeMvar, // 0x1E
+    METHOD_ElementTypeCmodReqd, // 0x1F
+    METHOD_ElementTypeCmodOpt, // 0x20
+    METHOD_ElementTypeInternal, // 0x21
+    METHOD_ElementTypeModifier, // 0x22
+    unimplemented, // 0x23
+    unimplemented, // 0x24
+    unimplemented, // 0x25
+    unimplemented, // 0x26
+    unimplemented, // 0x27
+    unimplemented, // 0x28
+    unimplemented, // 0x29
+    unimplemented, // 0x2A
+    unimplemented, // 0x2B
+    unimplemented, // 0x2C
+    unimplemented, // 0x2D
+    unimplemented, // 0x2E
+    unimplemented, // 0x2F
+    unimplemented, // 0x30
+    unimplemented, // 0x31
+    unimplemented, // 0x32
+    unimplemented, // 0x33
+    unimplemented, // 0x34
+    unimplemented, // 0x35
+    unimplemented, // 0x36
+    unimplemented, // 0x37
+    unimplemented, // 0x38
+    unimplemented, // 0x39
+    unimplemented, // 0x3A
+    unimplemented, // 0x3B
+    unimplemented, // 0x3C
+    unimplemented, // 0x3D
+    unimplemented, // 0x3E
+    unimplemented, // 0x3F
+    unimplemented, // 0x40
+    METHOD_ElementTypeSentinel, // 0x41
+    unimplemented, // 0x42
+    unimplemented, // 0x43
+    unimplemented, // 0x44
+    METHOD_ElementTypePinned // 0x45
+    };
 
 bool Assembly::extractMethodSignature(uint32& offset, VMCommonClass* cl,
-                                      std::vector<VMCommonClass*>& types) {
+    std::vector<VMCommonClass*>& types, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   //uint32 count      = 
   uncompressSignature(offset);
-  uint32 call       = uncompressSignature(offset);
-  
+  uint32 call = uncompressSignature(offset);
+
   if (call & CONSTANT_Generic) {
     //uint32 genArgCount =
     uncompressSignature(offset);
   }
-  
+
   uint32 paramCount = uncompressSignature(offset);
 
   uint32 hasThis = call & CONSTANT_HasThis ? 1 : 0;
   uint32 realCount = paramCount + hasThis;
 
-  VMCommonClass* ret = exploreType(offset);
+  VMCommonClass* ret = exploreType(offset, genClass, genMethod);
   types.push_back(ret);
-  
+
   if (hasThis) {
     types.push_back(cl);
   }
-  
+
   for (uint32 i = hasThis; i < realCount; ++i) {
-    VMCommonClass* cur = exploreType(offset);
+    VMCommonClass* cur = exploreType(offset, genClass, genMethod);
     types.push_back(cur);
   }
-  
+
   return hasThis != 0;
 }
 
 // checks whether the MethodDefSig at offset contains generic parameters
 bool Assembly::isGenericMethod(uint32& offset) {
   uncompressSignature(offset); // count
-  
+
   uint32 callingConvention = READ_U1(bytes, offset);
-  
+
   return callingConvention & CONSTANT_Generic ? true : false;
 }
 
 void Assembly::methodSpecSignature(uint32& offset,
-                                   std::vector<VMCommonClass*>& genArgs) {
+    std::vector<VMCommonClass*>& genArgs, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uncompressSignature(offset); // count
   uint32 genericSig = uncompressSignature(offset);
 
@@ -426,56 +478,58 @@
   }
 
   uint32 genArgCount = uncompressSignature(offset);
-  
+
   for (uint32 i = 0; i < genArgCount; i++) {
-    genArgs.push_back(exploreType(offset));
+    genArgs.push_back(exploreType(offset, genClass, genMethod));
   }
 }
 
 void Assembly::localVarSignature(uint32& offset,
-                                 std::vector<VMCommonClass*>& locals) {
+    std::vector<VMCommonClass*>& locals, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   //uint32 count      = 
   uncompressSignature(offset);
-  uint32 localSig   = uncompressSignature(offset);
-  uint32 nbLocals   = uncompressSignature(offset);
+  uint32 localSig = uncompressSignature(offset);
+  uint32 nbLocals = uncompressSignature(offset);
 
   if (localSig != 0x7) {
     VMThread::get()->vm->error("unknown local sig %x", localSig);
   }
-  
+
   for (uint32 i = 0; i < nbLocals; ++i) {
-    VMCommonClass* cl = exploreType(offset);
-    if (!cl) --i; // PINNED
-    else locals.push_back(cl);
+    VMCommonClass* cl = exploreType(offset, genClass, genMethod);
+    if (!cl)
+      --i; // PINNED
+    else
+      locals.push_back(cl);
   }
 }
 
-VMCommonClass* Assembly::extractFieldSignature(uint32& offset) {
+VMCommonClass* Assembly::extractFieldSignature(uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   //uint32 count      = 
   uncompressSignature(offset);
-  uint32 fieldSig   = uncompressSignature(offset);
-  
+  uint32 fieldSig = uncompressSignature(offset);
+
   if (fieldSig != 0x6) {
     VMThread::get()->vm->error("unknown field sig %x", fieldSig);
   }
-  
+
   // TODO implement support for custom modifiers
   //      see ECMA 335 23.2.4, 23.2.7 
 
-  return exploreType(offset);
+  return exploreType(offset, genClass, genMethod);
 
 }
 
-VMCommonClass* Assembly::extractTypeInSignature(uint32& offset) {
+VMCommonClass* Assembly::extractTypeInSignature(uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   //uint32 count      = 
   uncompressSignature(offset);
-  return exploreType(offset); 
+  return exploreType(offset, genClass, genMethod);
 }
 
-VMCommonClass* Assembly::exploreType(uint32& offset) {
+VMCommonClass* Assembly::exploreType(uint32& offset, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 op = READ_U1(bytes, offset);
   assert(op < 0x46 && "unknown signature type");
-  return (signatureVector[op])(op, this, offset);
+  return (signatureVector[op]) (op, this, offset, genClass, genMethod);
 }
 
 uint32 Assembly::uncompressSignature(uint32& offset) {

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.cpp Mon Aug 18 17:22:15 2008
@@ -233,7 +233,7 @@
   const UTF8* name = asciizConstructUTF8(_name);
   Assembly* assembly = loadAssembly(name, 0);
   if (assembly == 0) {
-    error("Can not found assembly %s", _name);
+    error("Can not find assembly %s", _name);
   } else {
     uint32 entryPoint = assembly->entryPoint;
     uint32 table = entryPoint >> 24;
@@ -241,7 +241,7 @@
       error("Entry point does not point to a method");
     } else {
       uint32 typeToken = assembly->getTypeDefTokenFromMethod(entryPoint);
-      assembly->loadType(this, typeToken, true, true, true ,true);
+      assembly->loadType(this, typeToken, true, true, true ,true, NULL, NULL);
       VMMethod* mainMeth = assembly->lookupMethodFromToken(entryPoint);
       (*mainMeth)(args);
     }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Mon Aug 18 17:22:15 2008
@@ -44,7 +44,7 @@
         code->setMetaInfo(meth);
       }
       meth->classDef->release();
-      meth->classDef->resolveStatic(true);
+      meth->classDef->resolveStatic(true, NULL);
     }
     return false;
   }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/NativeUtil.cpp Mon Aug 18 17:22:15 2008
@@ -67,7 +67,7 @@
     buf = (char*)alloca(6 + strlen(name) + strlen(nameSpace) +
                         strlen(methName) + 10);
     sprintf(buf, "%s_%s_%s_%d", nameSpace, name, methName, 
-                meth->getSignature()->getNumParams());
+                meth->getSignature(NULL)->getNumParams());
     cliToInternal(buf);
     res = dlsym(0, buf);
     if (!res) {

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Mon Aug 18 17:22:15 2008
@@ -200,7 +200,7 @@
   }
 }
 
-void CLIJit::compileOpcodes(uint8* bytecodes, uint32 codeLength) {
+void CLIJit::compileOpcodes(uint8* bytecodes, uint32 codeLength, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   uint32 leaveIndex = 0;
   bool isVolatile = false;
   for(uint32 i = 0; i < codeLength; ++i) {
@@ -364,7 +364,7 @@
       
       case CALL: {
         uint32 value = readU4(bytecodes, i);
-        invoke(value);
+        invoke(value, genClass, genMethod);
         break;
       }
 
@@ -1067,7 +1067,7 @@
       }
 
       case RET : {
-        if (compilingMethod->getSignature()->getReturnType() != Type::VoidTy) {
+        if (compilingMethod->getSignature(genMethod)->getReturnType() != Type::VoidTy) {
           Value* val = pop();
           if (val->getType() == PointerType::getUnqual(endNode->getType())) {
             // In case it's a struct
@@ -1278,7 +1278,7 @@
         Assembly* assembly = compilingClass->assembly;
         N3* vm = (N3*)(VMThread::get()->vm);
         VMCommonClass* type = assembly->loadType(vm, token, true, false, false,
-                                                 true);
+                                                 true, genClass, genMethod);
         assert(type);
         
         if (!type->isPrimitive) {
@@ -1322,7 +1322,7 @@
 
       case CALLVIRT : {
         uint32 value = readU4(bytecodes, i);
-        invokeInterfaceOrVirtual(value);
+        invokeInterfaceOrVirtual(value, genClass, genMethod);
         break; 
       }
 
@@ -1331,7 +1331,7 @@
         N3* vm = (N3*)(VMThread::get()->vm);
         uint32 token = readU4(bytecodes, i);
         VMCommonClass* dcl = assembly->loadType(vm, token, true, false,
-                                               false, true);
+                                               false, true, genClass, genMethod);
         Value* obj = new BitCastInst(pop(), VMObject::llvmType, "", currentBlock);
 
         Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj, 
@@ -1380,7 +1380,7 @@
         N3* vm = (N3*)(VMThread::get()->vm);
         uint32 token = readU4(bytecodes, i);
         VMCommonClass* dcl = assembly->loadType(vm, token, true, false,
-                                               false, true);
+                                               false, true, genClass, genMethod);
         Value* obj = pop();
 
         Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj, 
@@ -1520,9 +1520,9 @@
         N3* vm = (N3*)(VMThread::get()->vm);
         uint32 token = readU4(bytecodes, i);
         VMCommonClass* cl = assembly->loadType(vm, token, true, false,
-                                               false, true);
+                                               false, true, genClass, genMethod);
         VMClassArray* array = assembly->constructArray(cl, 1);
-        array->resolveType(false, false);
+        array->resolveType(false, false, genMethod);
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, array->naturalType);
@@ -1532,7 +1532,7 @@
 
       case LDFLD : {
         uint32 value = readU4(bytecodes, i);
-        Value* val = getVirtualField(value);
+        Value* val = getVirtualField(value, genClass, genMethod);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -1540,7 +1540,7 @@
       
       case LDFLDA : {
         uint32 value = readU4(bytecodes, i);
-        push(getVirtualField(value));
+        push(getVirtualField(value, genClass, genMethod));
         break;
       }
 
@@ -1554,7 +1554,7 @@
         N3* vm = (N3*)(VMThread::get()->vm);
         uint32 token = readU4(bytecodes, i);
         VMCommonClass* cl = assembly->loadType(vm, token, true, false,
-                                               false, true);
+                                               false, true, genClass, genMethod);
         if (!(cl->super == MSCorlib::pValue || cl->super == MSCorlib::pEnum)) {
           push(new LoadInst(pop(), "", isVolatile, currentBlock));
           isVolatile = false;
@@ -1564,7 +1564,7 @@
 
       case LDSFLD : {
         uint32 value = readU4(bytecodes, i);
-        Value* val = getStaticField(value);
+        Value* val = getStaticField(value, genClass, genMethod);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -1572,7 +1572,7 @@
       
       case LDSFLDA : {
         uint32 value = readU4(bytecodes, i);
-        push(getStaticField(value));
+        push(getStaticField(value, genClass, genMethod));
         break;
       }
 
@@ -1600,7 +1600,7 @@
         switch (table) {
           case CONSTANT_Field : {
             uint32 typeToken = assembly->getTypedefTokenFromField(token);
-            assembly->loadType(vm, typeToken, true, true, false, true);
+            assembly->loadType(vm, typeToken, true, true, false, true, genClass, genMethod);
             VMField* field = assembly->lookupFieldFromToken(token);
             if (!field) {
               VMThread::get()->vm->error("implement me");
@@ -1612,7 +1612,7 @@
           
           case CONSTANT_MethodDef : {
             uint32 typeToken = assembly->getTypedefTokenFromMethod(token);
-            assembly->loadType(vm, typeToken, true, true, false, true);
+            assembly->loadType(vm, typeToken, true, true, false, true, genClass, genMethod);
             VMMethod* meth = assembly->lookupMethodFromToken(token);
             if (!meth) {
               VMThread::get()->vm->error("implement me");
@@ -1625,7 +1625,7 @@
           case CONSTANT_TypeDef :
           case CONSTANT_TypeRef : {
             VMCommonClass* cl = assembly->loadType(vm, token, true, false,
-                                                   false, true);
+                                                   false, true, genClass, genMethod);
             Value* arg = new LoadInst(cl->llvmVar(), "", currentBlock);
             push(arg);
             break;
@@ -1647,10 +1647,10 @@
         Assembly* ass = compilingClass->assembly;
         VMCommonClass* baseType = ass->loadType((N3*)(VMThread::get()->vm),
                                                 value, true, false, false, 
-                                                true);
+                                                true, genClass, genMethod);
 
         VMClassArray* type = ass->constructArray(baseType, 1);
-        type->resolveType(false, false);
+        type->resolveType(false, false, genMethod);
         Value* var = new LoadInst(type->llvmVar(), "", currentBlock);
         std::vector<Value*> args;
         args.push_back(var);
@@ -1663,7 +1663,7 @@
 
       case NEWOBJ : {
         uint32 value = readU4(bytecodes, i);
-        invokeNew(value);
+        invokeNew(value, genClass, genMethod);
         break;
       }
       
@@ -1754,7 +1754,7 @@
       
       case STFLD : {
         uint32 index = readU4(bytecodes, i);
-        setVirtualField(index, isVolatile);
+        setVirtualField(index, isVolatile, genClass, genMethod);
         isVolatile = false;
         break;
       }
@@ -1767,7 +1767,7 @@
 
       case STSFLD : {
         uint32 index = readU4(bytecodes, i);
-        setStaticField(index, isVolatile);
+        setStaticField(index, isVolatile, genClass, genMethod);
         isVolatile = false;
         break;
       }
@@ -1791,7 +1791,7 @@
         Assembly* assembly = compilingClass->assembly;
         N3* vm = (N3*)(VMThread::get()->vm);
         VMCommonClass* type = assembly->loadType(vm, token, true, false, false,
-                                                 true);
+                                                 true, genClass, genMethod);
         assert(type);
 
         Value* val = new AllocaInst(type->naturalType, "", currentBlock);
@@ -1893,7 +1893,7 @@
             uint32 table = token >> 24;
             if (table == CONSTANT_MethodDef) {
               uint32 typeToken = assembly->getTypedefTokenFromMethod(token);
-              assembly->loadType(vm, typeToken, true, false,  false, true);
+              assembly->loadType(vm, typeToken, true, false,  false, true, genClass, genMethod);
               VMMethod* meth = assembly->lookupMethodFromToken(token);
               if (!meth) VMThread::get()->vm->error("implement me");
               Value* arg = new LoadInst(meth->llvmVar(), "", currentBlock);
@@ -1955,7 +1955,7 @@
             Assembly* assembly = compilingClass->assembly;
             N3* vm = (N3*)(VMThread::get()->vm);
             VMCommonClass* type = assembly->loadType(vm, token, true, false, false,
-                                                     true);
+                                                     true, genClass, genMethod);
             if (type->super == MSCorlib::pValue) {
               uint64 size = mvm::jit::getTypeSize(type->naturalType);
         

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMArray.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMArray.cpp Mon Aug 18 17:22:15 2008
@@ -217,21 +217,3 @@
   buf->setAt(size, 0);
   return buf->cString();
 }
-
-bool UTF8::equals(const UTF8 *string) const
-{
-  if (size != string->size) {
-    return false;
-  }
-  
-  for (sint32 i = 0; i < size; ++i) {
-    if (at(i) != string->at(i)) {
-      return false;
-    }
-  }
-  
-  return true;
-}
-
-
-

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMArray.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMArray.h Mon Aug 18 17:22:15 2008
@@ -104,8 +104,6 @@
   static const UTF8* readerConstruct(VirtualMachine *vm, uint16* buf, uint32 n);
 
   const UTF8* extract(VirtualMachine *vm, uint32 start, uint32 len) const;
-  
-  bool equals(const UTF8* string) 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=54951&r1=54950&r2=54951&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Mon Aug 18 17:22:15 2008
@@ -66,10 +66,10 @@
   return enveloppe;
 }
 
-void CLIJit::invokeInterfaceOrVirtual(uint32 value) {
+void CLIJit::invokeInterfaceOrVirtual(uint32 value, VMGenericClass* genClass, VMGenericMethod* genMethod) {
   
-  VMMethod* origMeth = compilingClass->assembly->getMethodFromToken(value);
-  const llvm::FunctionType* funcType = origMeth->getSignature();
+  VMMethod* origMeth = compilingClass->assembly->getMethodFromToken(value, genClass, genMethod);
+  const llvm::FunctionType* funcType = origMeth->getSignature(genMethod);
   
   std::vector<Value*> args;
   makeArgs(funcType, args, origMeth->structReturn);
@@ -202,7 +202,7 @@
       rcache = cache;
     }
     
-    Function* func = dmeth->compiledPtr();
+    Function* func = dmeth->compiledPtr(NULL);
     rcache->methPtr = mvm::jit::executionEngine->getPointerToGlobal(func);
     rcache->lastCible = (VMClass*)ocl;
     rcache->box = (dmeth->classDef->super == MSCorlib::pValue);

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Mon Aug 18 17:22:15 2008
@@ -196,12 +196,12 @@
 }
 
 
-void VMCommonClass::loadParents() {
+void VMCommonClass::loadParents(VMGenericClass* genClass, VMGenericMethod* genMethod) {
   if ((0xffff & superToken) == 0) {
     depth = 0;
     display.push_back(this);
   } else {
-    super = assembly->loadType((N3*)vm, superToken, true, false, false, true);
+    super = assembly->loadType((N3*)vm, superToken, true, false, false, true, genClass, genMethod);
     depth = super->depth + 1;
     for (uint32 i = 0; i < super->display.size(); ++i) {
       display.push_back(super->display[i]);
@@ -212,14 +212,14 @@
   for (std::vector<uint32>::iterator i = interfacesToken.begin(), 
        e = interfacesToken.end(); i!= e; ++i) {
     interfaces.push_back((VMClass*)assembly->loadType((N3*)vm, (*i), true, 
-                                                      false, false, true));
+                                                      false, false, true, genClass, genMethod));
   }
 
 }
 
 typedef void (*clinit_t)(void);
 
-void VMCommonClass::clinitClass() {
+void VMCommonClass::clinitClass(VMGenericMethod* genMethod) {
   VMCommonClass* cl = this; 
   if (cl->status < ready) {
     cl->aquire();
@@ -230,10 +230,10 @@
       cl->status = clinitParent;
       cl->release();
       if (cl->super) {
-        cl->super->resolveStatic(true);
+        cl->super->resolveStatic(true, genMethod);
       }
       for (uint32 i = 0; i < cl->interfaces.size(); i++) {
-        cl->interfaces[i]->resolveStatic(true);
+        cl->interfaces[i]->resolveStatic(true, genMethod);
       }
       
       cl->status = inClinit;
@@ -249,7 +249,7 @@
                   cl->printString());
       
       if (meth) {
-        llvm::Function* pred = meth->compiledPtr();
+        llvm::Function* pred = meth->compiledPtr(genMethod);
         clinit_t res = (clinit_t)
           (intptr_t)mvm::jit::executionEngine->getPointerToGlobal(pred);
         res();
@@ -269,7 +269,7 @@
   }
 }
 
-void VMClass::resolveStaticFields() {
+void VMClass::resolveStaticFields(VMGenericMethod* genMethod) {
   
   VMClass* cl = this;
 
@@ -283,7 +283,7 @@
   }
   for (std::vector<VMField*>::iterator i = cl->staticFields.begin(),
             e = cl->staticFields.end(); i!= e; ++i) {
-    (*i)->signature->resolveType(false, false);
+    (*i)->signature->resolveType(false, false, genMethod);
     fields.push_back((*i)->signature->naturalType);
   }
 
@@ -302,16 +302,16 @@
   }
 }
 
-void VMClass::unifyTypes() {
+void VMClass::unifyTypes(VMGenericClass* genClass, VMGenericMethod* genMethod) {
   PATypeHolder PA = naturalType;
   for (std::vector<VMField*>::iterator i = virtualFields.begin(), 
        e = virtualFields.end(); i!= e; ++i) {
-    (*i)->signature->resolveVirtual();
+    (*i)->signature->resolveVirtual(genClass, genMethod);
   }
   naturalType = PA.get();
 }
 
-void VMClass::resolveVirtualFields() {
+void VMClass::resolveVirtualFields(VMGenericClass* genClass, VMGenericMethod* genMethod) {
   const llvm::Type* ResultTy = 0;
   if (hasExplicitLayout(flags)) {
     explicitLayoutSize = assembly->getExplicitLayout(token);
@@ -362,7 +362,7 @@
     naturalType = ResultTy;
   }
   
-  unifyTypes();
+  unifyTypes(genClass, genMethod);
   
   if (super == MSCorlib::pValue) {
     std::vector<const llvm::Type*> Elts;
@@ -398,9 +398,9 @@
   naturalType = pType;
 }
 
-void VMCommonClass::resolveVirtual() {
+void VMCommonClass::resolveVirtual(VMGenericClass* genClass, VMGenericMethod *genMethod) {
   VMCommonClass* cl = this;
-  //printf("*** Resolving: %s\n", cl->printString());
+  
   if (cl->status < virtual_resolved) {
     cl->aquire();
     int status = cl->status;
@@ -413,23 +413,23 @@
       if (cl->isArray) {
         VMClassArray* arrayCl = (VMClassArray*)cl;
         VMCommonClass* baseClass =  arrayCl->baseClass;
-        baseClass->resolveType(false, false);
+        baseClass->resolveType(false, false, genMethod);
         arrayCl->makeType();
         cl->status = virtual_resolved;
       } else if (cl->isPointer) {
         VMClassPointer* pointerCl = (VMClassPointer*)cl;
         VMCommonClass* baseClass =  pointerCl->baseClass;
-        baseClass->resolveType(false, false);
+        baseClass->resolveType(false, false, genMethod);
         pointerCl->makeType();
         cl->status = virtual_resolved;
       } else {
         cl->release();
-        cl->loadParents();
+        cl->loadParents(genClass, genMethod);
         cl->aquire();
         cl->status = prepared;
-        assembly->readClass(cl);
+        assembly->readClass(cl, genMethod);
         cl->status = readed;
-        ((VMClass*)cl)->resolveVirtualFields();
+        ((VMClass*)cl)->resolveVirtualFields(genClass, genMethod);
         cl->status = virtual_resolved;
       }
       cl->release();
@@ -473,20 +473,12 @@
       }
 }
 
-void VMCommonClass::resolveType(bool stat, bool clinit) {
-  // save previous current generic class to restore it later
-  VMGenericClass* old = VMThread::get()->currGenericClass;
-  // temporarily store the class being compiled in case it is a generic class
-  VMThread::get()->currGenericClass = dynamic_cast<VMGenericClass*>(this);
-  
-  resolveVirtual();
-  if (stat) resolveStatic(clinit);
-  
-  // restore saved class
-  VMThread::get()->currGenericClass = old;
+void VMCommonClass::resolveType(bool stat, bool clinit, VMGenericMethod* genMethod) {
+  resolveVirtual(dynamic_cast<VMGenericClass*>(this), genMethod);
+  if (stat) resolveStatic(clinit, genMethod);
 }
 
-void VMCommonClass::resolveStatic(bool clinit) {
+void VMCommonClass::resolveStatic(bool clinit, VMGenericMethod* genMethod) {
   VMCommonClass* cl = this;
   if (cl->status < static_resolved) {
     cl->aquire();
@@ -500,15 +492,15 @@
       if (cl->isArray) {
         VMClassArray* arrayCl = (VMClassArray*)cl;
         VMCommonClass* baseClass =  arrayCl->baseClass;
-        baseClass->resolveStatic(false);
+        baseClass->resolveStatic(false, genMethod);
         cl->status = static_resolved;
       } else if (cl->isPointer) {
         VMClassPointer* pointerCl = (VMClassPointer*)cl;
         VMCommonClass* baseClass =  pointerCl->baseClass;
-        baseClass->resolveStatic(false);
+        baseClass->resolveStatic(false, genMethod);
         cl->status = static_resolved;
       } else {
-        ((VMClass*)cl)->resolveStaticFields();
+        ((VMClass*)cl)->resolveStaticFields(genMethod);
         cl->status = static_resolved;
       }
       cl->release();
@@ -521,7 +513,7 @@
       cl->release();
     }
   }
-  if (clinit) cl->clinitClass();
+  if (clinit) cl->clinitClass(genMethod);
 }
 
 
@@ -628,7 +620,7 @@
 }
 
 VMObject* VMClass::doNew() {
-  if (status < inClinit) resolveType(true, true);
+  if (status < inClinit) resolveType(true, true, NULL);
   uint64 size = mvm::jit::getTypeSize(virtualType->getContainedType(0));
   VMObject* res = (VMObject*)
     gc::operator new(size, virtualInstance->getVirtualTable());
@@ -637,7 +629,7 @@
 }
 
 VMObject* VMClassArray::doNew(uint32 nb) {
-  if (status < inClinit) resolveType(true, true);
+  if (status < inClinit) resolveType(true, true, NULL);
   uint64 size = mvm::jit::getTypeSize(baseClass->naturalType);
   VMArray* res = (VMArray*)
     gc::operator new(size * nb + sizeof(VMObject) + sizeof(sint32), arrayVT);
@@ -694,13 +686,13 @@
 
 const llvm::FunctionType* VMMethod::resolveSignature(
                   std::vector<VMCommonClass*> & parameters, bool isVirt,
-                  bool& structRet) {
+                  bool& structRet, VMGenericMethod* genMethod) {
     const llvm::Type* ret;
     std::vector<const llvm::Type*> args;
     std::vector<VMCommonClass*>::iterator i = parameters.begin(),
                                           e = parameters.end();
     if ((*i)->naturalType->isAbstract()) {
-      (*i)->resolveType(false, false);
+      (*i)->resolveType(false, false, genMethod);
     }
     ret = (*i)->naturalType;
     ++i;
@@ -709,7 +701,7 @@
       VMCommonClass* cur = (*i);
       ++i;
       if (cur->naturalType->isAbstract()) {
-        cur->resolveType(false, false);
+        cur->resolveType(false, false, genMethod);
       }
       if (cur->super != MSCorlib::pValue && cur->super != MSCorlib::pEnum) {
         args.push_back(cur->naturalType);
@@ -721,7 +713,7 @@
     for ( ; i!= e; ++i) {
       VMCommonClass* cur = (*i);
       if (cur->naturalType->isAbstract()) {
-        cur->resolveType(false, false);
+        cur->resolveType(false, false, genMethod);
       }
       if (cur->naturalType->isSingleValueType()) {
         args.push_back(cur->naturalType);
@@ -740,17 +732,17 @@
     return llvm::FunctionType::get(ret, args, false);
 }
 
-const llvm::FunctionType* VMMethod::getSignature() {
+const llvm::FunctionType* VMMethod::getSignature(VMGenericMethod* genMethod) {
   if (!_signature) {
-    _signature = resolveSignature(parameters, !isStatic(flags), structReturn);
+    _signature = resolveSignature(parameters, !isStatic(flags), structReturn, genMethod);
   }
   return _signature;
 }
 
-const llvm::FunctionType* Property::getSignature() {
+const llvm::FunctionType* Property::getSignature(VMGenericMethod* genMethod) {
   if (!_signature) {
     bool structReturn = false;
-    _signature = VMMethod::resolveSignature(parameters, virt, structReturn);
+    _signature = VMMethod::resolveSignature(parameters, virt, structReturn, genMethod);
   }
   return _signature;
 }
@@ -839,10 +831,15 @@
 		std::vector<VMCommonClass*>::iterator i = parameters.begin(), a =
 				args.begin(), e = args.end();
 
+		// dummy classes for generic arguments have a NULL assembly field
+		// check whether both i and a point to a dummy class
 		if (((*i)->assembly == NULL && (*a)->assembly != NULL) ||
 		    ((*i)->assembly != NULL && (*a)->assembly == NULL))
 		  return false;
 		
+		// dummy classes for generic arguments contain the 
+		// argument number in the token field
+		// signature is only equal if the argument number matches
 		if ((*i)->assembly == NULL && (*a)->assembly == NULL) {
 		  if ((*i)->token != (*a)->token) {
 		    return false;
@@ -860,10 +857,15 @@
 		}
 
 		for (; a != e; ++i, ++a) {
+	    // dummy classes for generic arguments have a NULL assembly field
+	    // check whether both i and a point to a dummy class
 	    if (((*i)->assembly == NULL && (*a)->assembly != NULL) ||
 	        ((*i)->assembly != NULL && (*a)->assembly == NULL))
 	      return false;
 	    
+	    // dummy classes for generic arguments contain the 
+	    // argument number in the token field
+	    // signature is only equal if the argument number matches
 	    if ((*i)->assembly == NULL && (*a)->assembly == NULL) {
 	      if ((*i)->token != (*a)->token) {
 	        return false;

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.h Mon Aug 18 17:22:15 2008
@@ -35,6 +35,8 @@
 class VMField;
 class VMMethod;
 class VMObject;
+class VMGenericClass;
+class VMGenericMethod;
 
 typedef enum VMClassState {
   hashed = 0, loaded, prepared, readed, virtual_resolved, static_resolved, clinitParent, inClinit, ready
@@ -98,12 +100,12 @@
   bool isAssignableFrom(VMCommonClass* cl);
   
   void assignType();
-  void clinitClass();
-  void resolveStatic(bool clinit);
-  void resolveVirtual();
+  void clinitClass(VMGenericMethod* genMethod);
+  void resolveStatic(bool clinit, VMGenericMethod* genMethod);
+  void resolveVirtual(VMGenericClass* genClass, VMGenericMethod* genMethod);
   void resolveVT();
-  void resolveType(bool stat, bool clinit);
-  void loadParents();
+  void resolveType(bool stat, bool clinit, VMGenericMethod* genMethod);
+  void loadParents(VMGenericClass* genClass, VMGenericMethod* genMethod);
   
   VMMethod* lookupMethodDontThrow(const UTF8* name, 
                                   std::vector<VMCommonClass*>& args,
@@ -133,9 +135,9 @@
   virtual void TRACER;
   
   void resolveFields();
-  void resolveStaticFields();
-  void resolveVirtualFields();
-  void unifyTypes();
+  void resolveStaticFields(VMGenericMethod* genMethod);
+  void resolveVirtualFields(VMGenericClass* genClass, VMGenericMethod* genMethod);
+  void unifyTypes(VMGenericClass* genClass, VMGenericMethod* genMethod);
   
   VMObject* staticInstance;
   VMObject* virtualInstance;
@@ -150,6 +152,8 @@
   uint32 explicitLayoutSize;
 };
 
+// FIXME try to get rid of this class
+//       add flag to VMClass instead
 class VMGenericClass : public VMClass {
 public:
   static VirtualTable* VT;
@@ -210,7 +214,7 @@
   std::vector<Enveloppe*, gc_allocator<Enveloppe*> > caches;
   std::vector<VMCommonClass*> parameters;
   VMClass* classDef;
-  llvm::Function* compiledPtr();
+  llvm::Function* compiledPtr(VMGenericMethod* genMethod);
   llvm::Function* methPtr;
   const UTF8* name;
   const llvm::FunctionType* _signature;
@@ -226,15 +230,17 @@
   llvm::GenericValue operator()(std::vector<llvm::GenericValue>& args);
   llvm::GenericValue run(...);
   
-  const llvm::FunctionType* getSignature();
+  const llvm::FunctionType* getSignature(VMGenericMethod* genMethod);
   static const llvm::FunctionType* resolveSignature(
-      std::vector<VMCommonClass*>& params, bool isVirt, bool &structRet);
+      std::vector<VMCommonClass*>& params, bool isVirt, bool &structRet, VMGenericMethod* genMethod);
   bool signatureEquals(std::vector<VMCommonClass*>& args);
   bool signatureEqualsGeneric(std::vector<VMCommonClass*>& args);
   llvm::GlobalVariable* llvmVar();
   llvm::GlobalVariable* _llvmVar;
 };
 
+// FIXME try to get rid of this class
+//       add flag to VMMethod instead
 class VMGenericMethod : public VMMethod {
 public:
   static VirtualTable* VT;
@@ -298,7 +304,7 @@
   std::vector<VMCommonClass*> parameters;
   VMCommonClass* type;
   const llvm::FunctionType* _signature;
-  const llvm::FunctionType* getSignature();
+  const llvm::FunctionType* getSignature(VMGenericMethod* genMethod);
   bool virt;
   const UTF8* name;
   VMObject* delegatee;

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.cpp Mon Aug 18 17:22:15 2008
@@ -60,9 +60,6 @@
   key->pendingException = 0;
   key->perFunctionPasses = new llvm::FunctionPassManager(vm->TheModuleProvider);
   key->perFunctionPasses->add(new llvm::TargetData(vm->module));
-  key->currGenericClass = NULL;
-  key->currGenericMethod = NULL;
-  key->genMethodInstantiation = NULL;
   AddStandardCompilePasses(key->perFunctionPasses);
   return key;
 }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.h Mon Aug 18 17:22:15 2008
@@ -41,14 +41,6 @@
   unsigned int interruptFlag;
   unsigned int state;
   
-  // helper which points to the current generic class
-  VMGenericClass* currGenericClass;
-  // helper which contains the instantiation of the
-  // current generic method
-  std::vector<VMCommonClass*>* genMethodInstantiation;
-  // helper which points to the current generic method
-  VMGenericMethod* currGenericMethod;
-
   static const unsigned int StateRunning;
   static const unsigned int StateWaiting;
   static const unsigned int StateInterrupted;





More information about the vmkit-commits mailing list