[vmkit-commits] [vmkit] r58087 - in /vmkit/trunk: include/mvm/ lib/JnJVM/Classpath/ lib/JnJVM/VMCore/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Fri Oct 24 02:44:42 PDT 2008


Author: geoffray
Date: Fri Oct 24 04:44:42 2008
New Revision: 58087

URL: http://llvm.org/viewvc/llvm-project?rev=58087&view=rev
Log:
Removal of vectors and maps in Class, CommonClass, JavaField and JavaMethod
classes. This gives us better control over memory allocations.


Modified:
    vmkit/trunk/include/mvm/Allocator.h
    vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
    vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
    vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp

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

==============================================================================
--- vmkit/trunk/include/mvm/Allocator.h (original)
+++ vmkit/trunk/include/mvm/Allocator.h Fri Oct 24 04:44:42 2008
@@ -232,6 +232,10 @@
   void operator delete(void* ptr) {
     free(ptr);
   }
+
+  void* operator new [](size_t sz, BumpPtrAllocator& allocator) {
+    return allocator.Allocate(sz);
+  }
 };
 
 } // end namespace mvm

Modified: vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/Classpath.cpp Fri Oct 24 04:44:42 2008
@@ -32,9 +32,8 @@
   verifyNull(Cl);
   Jnjvm* vm = JavaThread::get()->isolate;
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, Cl, true);
-  UserClass* methodCl = 0;
   if (cl->lookupMethodDontThrow(Jnjvm::clinitName, Jnjvm::clinitType, true,
-                                false, methodCl))
+                                false, 0))
     return true;
   
   return false;

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp Fri Oct 24 04:44:42 2008
@@ -295,14 +295,11 @@
 jclass Cl) {
   Jnjvm* vm = JavaThread::get()->isolate;
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, Cl, false);
-  std::vector<UserClass*> * interfaces = cl->getInterfaces();
   ArrayObject* ret = 
-    (ArrayObject*)vm->upcalls->classArrayClass->doNew(interfaces->size(), vm);
-  sint32 index = 0;
-  for (std::vector<UserClass*>::iterator i = interfaces->begin(),
-       e = interfaces->end(); i != e; ++i, ++index) {
-    UserClass* klass = *i; 
-    ret->elements[index] = klass->getClassDelegatee(vm);
+    (ArrayObject*)vm->upcalls->classArrayClass->doNew(cl->nbInterfaces, vm);
+  for (uint16 i = 0; i < cl->nbInterfaces; ++i) {
+    UserClass* klass = cl->interfaces[i];
+    ret->elements[i] = klass->getClassDelegatee(vm);
   }
   return (jobject)ret;
 }
@@ -337,13 +334,11 @@
   UserClass* cl = NativeUtil::resolvedImplClass(vm, Cl, false)->asClass();
   if (cl) {
     cl->resolveInnerOuterClasses();
-    std::vector<UserClass*>* innerClasses = cl->getInnerClasses();
     UserClassArray* array = vm->upcalls->constructorArrayClass;
-    ArrayObject* res = (ArrayObject*)array->doNew(innerClasses->size(), vm);
-    uint32 index = 0;
-    for (std::vector<UserClass*>::iterator i = innerClasses->begin(), 
-         e = innerClasses->end(); i!= e; i++) {
-      res->elements[index++] = (*i)->getClassDelegatee(vm); 
+    ArrayObject* res = (ArrayObject*)array->doNew(cl->nbInnerClasses, vm);
+    for (uint16 i = 0; i < cl->nbInnerClasses; ++i) {
+      UserClass* klass = cl->innerClasses[i];
+      res->elements[i] = klass->getClassDelegatee(vm); 
     }
     return (jobject)res;
   }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Fri Oct 24 04:44:42 2008
@@ -48,7 +48,7 @@
 #endif
 }
 
-Enveloppe::Enveloppe(UserConstantPool* ctp, uint32 i) {
+void Enveloppe::initialise(UserConstantPool* ctp, uint32 i) {
   mvm::BumpPtrAllocator& allocator = ctp->classDef->classLoader->allocator;
   firstCache = new(allocator) CacheNode(this);
   ctpInfo = ctp;

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h Fri Oct 24 04:44:42 2008
@@ -88,7 +88,13 @@
   /// Enveloppe - Allocates the linked list with the given constant pool info
   /// at the given index, so as the resolution process knows which interface
   /// method the invokeinterface bytecode references.
-  Enveloppe(UserConstantPool* info, uint32 index);
+  Enveloppe(UserConstantPool* info, uint32 index) {
+    initialise(info, index);
+  }
+
+  Enveloppe() {}
+
+  void initialise(UserConstantPool* info, uint32 index);
 
 };
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Fri Oct 24 04:44:42 2008
@@ -41,7 +41,7 @@
 const UTF8* Attribut::sourceFileAttribut = 0;
 
 CommonClass* ClassArray::SuperArray;
-std::vector<Class*> ClassArray::InterfacesArray;
+Class** ClassArray::InterfacesArray;
 
 Attribut::Attribut(const UTF8* name, uint32 length,
                    uint32 offset) {
@@ -53,9 +53,8 @@
 }
 
 Attribut* Class::lookupAttribut(const UTF8* key ) {
-  for (std::vector<Attribut*>::iterator i = attributs.begin(), 
-       e = attributs.end(); i!= e; ++i) {
-    Attribut* cur = *i;
+  for (uint32 i = 0; i < nbAttributs; ++i) {
+    Attribut* cur = &(attributs[i]);
     if (cur->name->equals(key)) return cur;
   }
 
@@ -63,9 +62,8 @@
 }
 
 Attribut* JavaField::lookupAttribut(const UTF8* key ) {
-  for (std::vector<Attribut*>::iterator i = attributs.begin(), 
-       e = attributs.end(); i!= e;++i) {
-    Attribut* cur = *i;
+  for (uint32 i = 0; i < nbAttributs; ++i) {
+    Attribut* cur = &(attributs[i]);
     if (cur->name->equals(key)) return cur;
   }
 
@@ -73,22 +71,14 @@
 }
 
 Attribut* JavaMethod::lookupAttribut(const UTF8* key ) {
-  for (std::vector<Attribut*>::iterator i = attributs.begin(), 
-       e = attributs.end(); i!= e; ++i) {
-    Attribut* cur = *i;
+  for (uint32 i = 0; i < nbAttributs; ++i) {
+    Attribut* cur = &(attributs[i]);
     if (cur->name->equals(key)) return cur;
   }
 
   return 0;
 }
 
-bool CommonClass::FieldCmp::operator<(const CommonClass::FieldCmp &cmp) const {
-  if (name->lessThan(cmp.name)) return true;
-  else if (cmp.name->lessThan(name)) return false;
-  else return type->lessThan(cmp.type);
-}
-
-
 CommonClass::~CommonClass() {
   classLoader->allocator.Deallocate(display);
 }
@@ -96,48 +86,49 @@
 CommonClass::CommonClass() {
   display = 0;
   virtualVT = 0;
+  nbVirtualFields = 0;
+  nbStaticFields = 0;
+  nbVirtualMethods = 0;
+  nbStaticMethods = 0;
+  nbInterfaces = 0;
 }
 
-Class::Class() {
+Class::Class() : CommonClass() {
   ctpInfo = 0;
   staticVT = 0;
   JInfo = 0;
   outerClass = 0;
   innerOuterResolved = false;
+  nbInnerClasses = 0;
 }
 
 Class::~Class() {
-  for (std::vector<Attribut*>::iterator i = attributs.begin(), 
-       e = attributs.end(); i!= e; ++i) {
-    Attribut* cur = *i;
+  for (uint32 i = 0; i < nbAttributs; ++i) {
+    Attribut* cur = &(attributs[i]);
     cur->~Attribut();
     classLoader->allocator.Deallocate(cur);
   }
   
-  for (field_iterator i = staticFields.begin(), 
-       e = staticFields.end(); i!= e; ++i) {
-    JavaField* cur = i->second;
+  for (uint32 i = 0; i < nbStaticFields; ++i) {
+    JavaField* cur = &(staticFields[i]);
     cur->~JavaField();
     classLoader->allocator.Deallocate(cur);
   }
   
-  for (field_iterator i = virtualFields.begin(), 
-       e = virtualFields.end(); i!= e; ++i) {
-    JavaField* cur = i->second;
+  for (uint32 i = 0; i < nbVirtualFields; ++i) {
+    JavaField* cur = &(virtualFields[i]);
     cur->~JavaField();
     classLoader->allocator.Deallocate(cur);
   }
   
-  for (method_iterator i = virtualMethods.begin(), 
-       e = virtualMethods.end(); i!= e; ++i) {
-    JavaMethod* cur = i->second;
+  for (uint32 i = 0; i < nbVirtualMethods; ++i) {
+    JavaMethod* cur = &(virtualMethods[i]);
     cur->~JavaMethod();
     classLoader->allocator.Deallocate(cur);
   }
   
-  for (method_iterator i = staticMethods.begin(), 
-       e = staticMethods.end(); i!= e; ++i) {
-    JavaMethod* cur = i->second;
+  for (uint32 i = 0; i < nbStaticMethods; ++i) {
+    JavaMethod* cur = &(staticMethods[i]);
     cur->~JavaMethod();
     classLoader->allocator.Deallocate(cur);
   }
@@ -156,9 +147,8 @@
 }
 
 JavaField::~JavaField() {
-  for (std::vector<Attribut*>::iterator i = attributs.begin(), 
-       e = attributs.end(); i!= e; ++i) {
-    Attribut* cur = *i;
+  for (uint32 i = 0; i < nbAttributs; ++i) {
+    Attribut* cur = &(attributs[i]);
     cur->~Attribut();
     classDef->classLoader->allocator.Deallocate(cur);
   }
@@ -166,16 +156,14 @@
 
 JavaMethod::~JavaMethod() {
   
-  for (std::vector<Attribut*>::iterator i = attributs.begin(), 
-       e = attributs.end(); i!= e; ++i) {
-    Attribut* cur = *i;
+  for (uint32 i = 0; i < nbAttributs; ++i) {
+    Attribut* cur = &(attributs[i]);
     cur->~Attribut();
     classDef->classLoader->allocator.Deallocate(cur);
   }
-
-  for (std::vector<Enveloppe*>::iterator i = caches.begin(), 
-       e = caches.end(); i!= e; ++i) {
-    Enveloppe* cur = *i;
+  
+  for (uint32 i = 0; i < nbEnveloppes; ++i) {
+    Enveloppe* cur = &(enveloppes[i]);
     cur->~Enveloppe();
     classDef->classLoader->allocator.Deallocate(cur);
   }
@@ -271,11 +259,21 @@
 CommonClass::CommonClass(JnjvmClassLoader* loader, const UTF8* n,
                          bool isArray) {
   name = n;
-  this->virtualVT = 0;
-  this->status = loaded;
-  this->classLoader = loader;
-  this->array = isArray;
-  this->primitive = false;
+  virtualVT = 0;
+  status = loaded;
+  classLoader = loader;
+  array = isArray;
+  primitive = false;
+  nbVirtualMethods = 0;
+  nbStaticMethods = 0;
+  nbStaticFields = 0;
+  nbVirtualFields = 0;
+  nbInterfaces = 0;
+  interfaces = 0;
+  virtualMethods = 0;
+  staticMethods = 0;
+  virtualFields = 0;
+  staticFields = 0;
 #if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
   this->delegatee = 0;
 #endif
@@ -302,6 +300,7 @@
   outerClass = 0;
   innerOuterResolved = false;
   display = 0;
+  nbInnerClasses = 0;
 #if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
   _staticInstance = 0;
 #endif
@@ -313,6 +312,7 @@
   _baseClass = base;
   super = ClassArray::SuperArray;
   interfaces = ClassArray::InterfacesArray;
+  nbInterfaces = 2;
   depth = 1;
   display = (CommonClass**)loader->allocator.Allocate(2 * sizeof(CommonClass*));
   display[0] = ClassArray::SuperArray;
@@ -413,18 +413,26 @@
                                                const UTF8* type,
                                                bool isStatic,
                                                bool recurse,
-                                               Class*& methodCl) {
+                                               Class** methodCl) {
   
-  CommonClass::FieldCmp CC(name, type);
-  CommonClass::method_map* map = isStatic ? getStaticMethods() :
-                                            getVirtualMethods();
-  CommonClass::method_iterator End = map->end();
-  CommonClass::method_iterator I = map->find(CC);
-  if (I != End) {
-    methodCl = (Class*)this;
-    return I->second;
+  JavaMethod* methods = 0;
+  uint32 nb = 0;
+  if (isStatic) {
+    methods = getStaticMethods();
+    nb = nbStaticMethods;
+  } else {
+    methods = getVirtualMethods();
+    nb = nbVirtualMethods;
   }
   
+  for (uint32 i = 0; i < nb; ++i) {
+    JavaMethod& res = methods[i];
+    if (res.name->equals(name) && res.type->equals(type)) {
+      if (methodCl) *methodCl = (Class*)this;
+      return &res;
+    }
+  }
+
   JavaMethod *cur = 0;
   
   if (recurse) {
@@ -432,11 +440,10 @@
                                                   recurse, methodCl);
     if (cur) return cur;
     if (isStatic) {
-      std::vector<Class*>* interfaces = getInterfaces();
-      for (std::vector<Class*>::iterator i = interfaces->begin(),
-           e = interfaces->end(); i!= e; i++) {
-        cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse,
-                                          methodCl);
+      for (uint16 i = 0; i < nbInterfaces; ++i) {
+        Class* I = interfaces[i];
+        cur = I->lookupMethodDontThrow(name, type, isStatic, recurse,
+                                       methodCl);
         if (cur) return cur;
       }
     }
@@ -447,7 +454,7 @@
 
 JavaMethod* CommonClass::lookupMethod(const UTF8* name, const UTF8* type,
                                       bool isStatic, bool recurse,
-                                      Class*& methodCl) {
+                                      Class** methodCl) {
   JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse,
                                           methodCl);
   if (!res) {
@@ -459,18 +466,25 @@
 JavaField*
 CommonClass::lookupFieldDontThrow(const UTF8* name, const UTF8* type,
                                   bool isStatic, bool recurse,
-                                  CommonClass*& definingClass) {
-
-  CommonClass::FieldCmp CC(name, type);
-  CommonClass::field_map* map = isStatic ? getStaticFields() :
-                                           getVirtualFields();
-  CommonClass::field_iterator End = map->end();
-  CommonClass::field_iterator I = map->find(CC);
-  if (I != End) {
-    definingClass = this;
-    return I->second;
+                                  CommonClass** definingClass) {
+  JavaField* fields = 0;
+  uint32 nb = 0;
+  if (isStatic) {
+    fields = getStaticFields();
+    nb = nbStaticFields;
+  } else {
+    fields = getVirtualFields();
+    nb = nbVirtualFields;
   }
   
+  for (uint32 i = 0; i < nb; ++i) {
+    JavaField& res = fields[i];
+    if (res.name->equals(name) && res.type->equals(type)) {
+      if (definingClass) *definingClass = this;
+      return &res;
+    }
+  }
+
   JavaField *cur = 0;
 
   if (recurse) {
@@ -478,11 +492,10 @@
                                                  recurse, definingClass);
     if (cur) return cur;
     if (isStatic) {
-      std::vector<Class*>* interfaces = getInterfaces();
-      for (std::vector<Class*>::iterator i = interfaces->begin(),
-           e = interfaces->end(); i!= e; i++) {
-        cur = (*i)->lookupFieldDontThrow(name, type, isStatic, recurse,
-                                         definingClass);
+      for (uint16 i = 0; i < nbInterfaces; ++i) {
+        Class* I = interfaces[i];
+        cur = I->lookupFieldDontThrow(name, type, isStatic, recurse,
+                                      definingClass);
         if (cur) return cur;
       }
     }
@@ -493,7 +506,7 @@
 
 JavaField* CommonClass::lookupField(const UTF8* name, const UTF8* type,
                                     bool isStatic, bool recurse,
-                                    CommonClass*& definingClass) {
+                                    CommonClass** definingClass) {
   
   JavaField* res = lookupFieldDontThrow(name, type, isStatic, recurse,
                                         definingClass);
@@ -522,7 +535,7 @@
     if (getSuper()->inheritName(Tname)) return true;
   }
   
-  for (uint32 i = 0; i < interfaces.size(); ++i) {
+  for (uint32 i = 0; i < nbInterfaces; ++i) {
     if (interfaces[i]->inheritName(Tname)) return true;
   }
   return false;
@@ -555,10 +568,10 @@
 bool UserCommonClass::implements(UserCommonClass* cl) {
   if (this == cl) return true;
   else {
-    for (std::vector<UserClass*>::iterator i = interfaces.begin(),
-         e = interfaces.end(); i!= e; i++) {
-      if (*i == cl) return true;
-      else if ((*i)->implements(cl)) return true;
+    for (uint16 i = 0; i < nbInterfaces; ++i) {
+      Class* I = interfaces[i];
+      if (I == cl) return true;
+      else if (I->implements(cl)) return true;
     }
     if (super) {
       return super->implements(cl);
@@ -636,68 +649,56 @@
   } 
 }
 
-JavaMethod* CommonClass::constructMethod(const UTF8* name,
+JavaMethod* CommonClass::constructMethod(JavaMethod& method,
+                                         const UTF8* name,
                                          const UTF8* type, uint32 access) {
-  method_map& map = isStatic(access) ? staticMethods : virtualMethods;
-  FieldCmp CC(name, type);
-  method_iterator End = map.end();
-  method_iterator I = map.find(CC);
-  if (I == End) {
-    JavaMethod* method = new(classLoader->allocator) JavaMethod();
-    method->name = name;
-    method->type = type;
-    method->classDef = (Class*)this;
-    method->_signature = 0;
-    method->code = 0;
-    method->access = access;
-    method->canBeInlined = false;
-    method->offset = 0;
-    method->JInfo = 0;
-    map.insert(std::make_pair(CC, method));
-    return method;
-  } else {
-    return I->second;
-  }
+  method.name = name;
+  method.type = type;
+  method.classDef = (Class*)this;
+  method._signature = 0;
+  method.code = 0;
+  method.access = access;
+  method.canBeInlined = false;
+  method.offset = 0;
+  method.JInfo = 0;
+  return &method;
 }
 
-JavaField* CommonClass::constructField(const UTF8* name,
+JavaField* CommonClass::constructField(JavaField& field,
+                                       const UTF8* name,
                                        const UTF8* type, uint32 access) {
-  field_map& map = isStatic(access) ? staticFields : virtualFields;
-  FieldCmp CC(name, type);
-  field_iterator End = map.end();
-  field_iterator I = map.find(CC);
-  if (I == End) {
-    JavaField* field = new(classLoader->allocator) JavaField();
-    field->name = name;
-    field->type = type;
-    field->classDef = (Class*)this;
-    field->_signature = 0;
-    field->ptrOffset = 0;
-    field->access = access;
-    field->JInfo = 0;
-    map.insert(std::make_pair(CC, field));
-    return field;
-  } else {
-    return I->second;
-  }
+  field.name = name;
+  field.type = type;
+  field.classDef = (Class*)this;
+  field._signature = 0;
+  field.ptrOffset = 0;
+  field.access = access;
+  field.JInfo = 0;
+  return &field;
 }
 
 void Class::readParents(Reader& reader) {
-  unsigned short int superEntry = reader.readU2();
-  const UTF8* super = superEntry ? 
+  uint16 superEntry = reader.readU2();
+  const UTF8* superUTF8 = superEntry ? 
         ctpInfo->resolveClassName(superEntry) : 0;
 
-  unsigned short int nbI = reader.readU2();
-  superUTF8 = super;
+  uint16 nbI = reader.readU2();
+  // Use the super field to store the UTF8. since the field is never
+  // used before actually loading the super, this is harmless.
+  super = (Class*)superUTF8;
+
+  // Use the regular interface array to store the UTF8s. Since this array
+  // is never used before actually loading the interfaces, this is harmless.
+  interfaces = (Class**)
+    classLoader->allocator.Allocate(nbI * sizeof(Class*));
+  nbInterfaces = nbI;
   for (int i = 0; i < nbI; i++)
-    interfacesUTF8.push_back(ctpInfo->resolveClassName(reader.readU2()));
+    interfaces[i] = (Class*)ctpInfo->resolveClassName(reader.readU2());
 
 }
 
 void UserClass::loadParents() {
-  std::vector<const UTF8*>* interfacesUTF8 = getInterfacesUTF8();
-  unsigned nbI = interfacesUTF8->size();
-  const UTF8* superUTF8 = getSuperUTF8();
+  const UTF8* superUTF8 = (const UTF8*)super;
   if (superUTF8 == 0) {
     depth = 0;
     display = (CommonClass**)
@@ -713,48 +714,70 @@
     display[depth] = this;
   }
 
-  for (unsigned i = 0; i < nbI; i++)
-    interfaces.push_back((UserClass*)classLoader->loadName((*interfacesUTF8)[i],
-                                                           true, true));
+  for (unsigned i = 0; i < nbInterfaces; i++)
+    interfaces[i] = 
+      ((UserClass*)classLoader->loadName((const UTF8*)interfaces[i],
+                                         true, true));
 }
 
-void Class::readAttributs(Reader& reader, std::vector<Attribut*>& attr) {
-  unsigned short int nba = reader.readU2();
+Attribut* Class::readAttributs(Reader& reader, uint16& size) {
+  uint16 nba = reader.readU2();
   
+  Attribut* attributs = new(classLoader->allocator) Attribut[nba];
+
   for (int i = 0; i < nba; i++) {
     const UTF8* attName = ctpInfo->UTF8At(reader.readU2());
     uint32 attLen = reader.readU4();
-    Attribut* att = new(classLoader->allocator) Attribut(attName, attLen,
-                                                         reader.cursor);
-    attr.push_back(att);
+    Attribut& att = attributs[i];
+    att.start = reader.cursor;
+    att.nbb = attLen;
+    att.name = attName;
     reader.seek(attLen, Reader::SeekCur);
   }
+
+  size = nba;
+  return attributs;
 }
 
 void Class::readFields(Reader& reader) {
   uint16 nbFields = reader.readU2();
-  uint32 sindex = 0;
-  uint32 vindex = 0;
+  virtualFields = new (classLoader->allocator) JavaField[nbFields];
+  staticFields = virtualFields + nbFields;
   for (int i = 0; i < nbFields; i++) {
     uint16 access = reader.readU2();
     const UTF8* name = ctpInfo->UTF8At(reader.readU2());
     const UTF8* type = ctpInfo->UTF8At(reader.readU2());
-    JavaField* field = constructField(name, type, access);
-    isStatic(access) ?
-      field->num = sindex++ :
-      field->num = vindex++;
-    readAttributs(reader, field->attributs);
+    JavaField* field = 0;
+    if (isStatic(access)) {
+      --staticFields;
+      field = constructField(staticFields[0], name, type, access);
+      ++nbStaticFields;
+    } else {
+      field = constructField(virtualFields[nbVirtualFields], name, type, access);
+      ++nbVirtualFields;
+    }
+    field->attributs = readAttributs(reader, field->nbAttributs);
   }
 }
 
 void Class::readMethods(Reader& reader) {
   uint16 nbMethods = reader.readU2();
+  virtualMethods = new(classLoader->allocator) JavaMethod[nbMethods];
+  staticMethods = virtualMethods + nbMethods;
   for (int i = 0; i < nbMethods; i++) {
     uint16 access = reader.readU2();
     const UTF8* name = ctpInfo->UTF8At(reader.readU2());
     const UTF8* type = ctpInfo->UTF8At(reader.readU2());
-    JavaMethod* meth = constructMethod(name, type, access);
-    readAttributs(reader, meth->attributs);
+    JavaMethod* meth = 0;
+    if (isStatic(access)) {
+      --staticMethods;
+      meth = constructMethod(staticMethods[0], name, type, access);
+      ++nbStaticMethods;
+    } else {
+      meth = constructMethod(virtualMethods[nbVirtualMethods], name, type, access);
+      ++nbVirtualMethods;
+    }
+    meth->attributs = readAttributs(reader, meth->nbAttributs);
   }
 }
 
@@ -769,8 +792,8 @@
   if (magic != Jnjvm::Magic) {
     JavaThread::get()->isolate->classFormatError("bad magic number %p", magic);
   }
-  minor = reader.readU2();
-  major = reader.readU2();
+  /* uint16 minor = */ reader.readU2();
+  /* uint16 major = */ reader.readU2();
   uint32 ctpSize = reader.readU2();
   ctpInfo = new(classLoader->allocator, ctpSize) JavaConstantPool(this, reader,
                                                                   ctpSize);
@@ -790,7 +813,7 @@
   readParents(reader);
   readFields(reader);
   readMethods(reader);
-  readAttributs(reader, attributs);
+  attributs = readAttributs(reader, nbAttributs);
 }
 
 #ifndef ISOLATE_SHARING
@@ -839,7 +862,7 @@
     Attribut* attribut = lookupAttribut(Attribut::innerClassesAttribut);
     if (attribut != 0) {
       Reader reader(attribut, getBytes());
-
+      uint16 temp = 0;
       uint16 nbi = reader.readU2();
       for (uint16 i = 0; i < nbi; ++i) {
         uint16 inner = reader.readU2();
@@ -853,8 +876,12 @@
         if (clInner == this) {
           outerClass = clOuter;
         } else if (clOuter == this) {
+          if (!temp) {
+            innerClasses = (Class**)
+              classLoader->allocator.Allocate(nbi * sizeof(Class*));
+          }
           clInner->setInnerAccess(accessFlags);
-          innerClasses.push_back(clInner);
+          innerClasses[nbInnerClasses++] = clInner;
         }
       }
     }
@@ -864,9 +891,8 @@
 
 void CommonClass::getDeclaredConstructors(std::vector<JavaMethod*>& res,
                                           bool publicOnly) {
-  for (CommonClass::method_iterator i = virtualMethods.begin(),
-       e = virtualMethods.end(); i != e; ++i) {
-    JavaMethod* meth = i->second;
+  for (uint32 i = 0; i < nbVirtualMethods; ++i) {
+    JavaMethod* meth = &virtualMethods[i];
     bool pub = isPublic(meth->access);
     if (meth->name->equals(Jnjvm::initName) && (!publicOnly || pub)) {
       res.push_back(meth);
@@ -876,18 +902,16 @@
 
 void CommonClass::getDeclaredMethods(std::vector<JavaMethod*>& res,
                                      bool publicOnly) {
-  for (CommonClass::method_iterator i = virtualMethods.begin(),
-       e = virtualMethods.end(); i != e; ++i) {
-    JavaMethod* meth = i->second;
+  for (uint32 i = 0; i < nbVirtualMethods; ++i) {
+    JavaMethod* meth = &virtualMethods[i];
     bool pub = isPublic(meth->access);
     if (!(meth->name->equals(Jnjvm::initName)) && (!publicOnly || pub)) {
       res.push_back(meth);
     }
   }
   
-  for (CommonClass::method_iterator i = staticMethods.begin(),
-       e = staticMethods.end(); i != e; ++i) {
-    JavaMethod* meth = i->second;
+  for (uint32 i = 0; i < nbStaticMethods; ++i) {
+    JavaMethod* meth = &staticMethods[i];
     bool pub = isPublic(meth->access);
     if (!(meth->name->equals(Jnjvm::clinitName)) && (!publicOnly || pub)) {
       res.push_back(meth);
@@ -897,17 +921,15 @@
 
 void CommonClass::getDeclaredFields(std::vector<JavaField*>& res,
                                     bool publicOnly) {
-  for (CommonClass::field_iterator i = virtualFields.begin(),
-       e = virtualFields.end(); i != e; ++i) {
-    JavaField* field = i->second;
+  for (uint32 i = 0; i < nbVirtualFields; ++i) {
+    JavaField* field = &virtualFields[i];
     if (!publicOnly || isPublic(field->access)) {
       res.push_back(field);
     }
   }
   
-  for (CommonClass::field_iterator i = staticFields.begin(),
-       e = staticFields.end(); i != e; ++i) {
-    JavaField* field = i->second;
+  for (uint32 i = 0; i < nbStaticFields; ++i) {
+    JavaField* field = &staticFields[i];
     if (!publicOnly || isPublic(field->access)) {
       res.push_back(field);
     }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Fri Oct 24 04:44:42 2008
@@ -10,7 +10,6 @@
 #ifndef JNJVM_JAVA_CLASS_H
 #define JNJVM_JAVA_CLASS_H
 
-#include <map>
 #include <vector>
 
 #include "types.h"
@@ -82,6 +81,7 @@
   /// Attribut - Create an attribut at the given length and offset.
   ///
   Attribut(const UTF8* name, uint32 length, uint32 offset);
+  Attribut() {}
   
   /// codeAttribut - The "Code" JVM attribut. This is a method attribut for
   /// finding the bytecode of a method in the .class file.
@@ -126,26 +126,6 @@
 #ifdef ISOLATE_SHARING
 friend class UserCommonClass;
 #endif
-private:
-
-
-/// FieldCmp - Internal class for field and method lookup in a class.
-///
-class FieldCmp {
-public:
-  
-  /// name - The name of the field/method
-  ///
-  const UTF8* name;
-
-  /// type - The type of the field/method.
-  ///
-  const UTF8* type;
-
-  FieldCmp(const UTF8* n, const UTF8* t) : name(n), type(t) {}
-  
-  bool operator<(const FieldCmp &cmp) const;
-};
 
 public:
   
@@ -169,13 +149,12 @@
   ///
   VirtualTable* virtualVT;
   
-  /// display - The class hierarchy of supers for this class. Array classes
-  /// do not need it.
+  /// display - The class hierarchy of supers for this class.
   ///
   CommonClass** display;
   
   /// depth - The depth of this class in its class hierarchy. 
-  /// display[depth] contains the class. Array classes do not need it.
+  /// display[depth] contains the class.
   ///
   uint32 depth;
 
@@ -255,12 +234,14 @@
   
   /// interfaces - The interfaces this class implements.
   ///
-  std::vector<Class*> interfaces;
+  Class** interfaces;
   
-  std::vector<Class*> * getInterfaces() {
-    return &interfaces;
+  Class** getInterfaces() {
+    return interfaces;
   }
   
+  uint16 nbInterfaces;
+  
   /// name - The name of the class.
   ///
   const UTF8* name;
@@ -277,22 +258,6 @@
     return super;
   }
 
-  /// superUTF8 - The name of the parent of this class.
-  ///
-  const UTF8* superUTF8;
-
-  const UTF8* getSuperUTF8() {
-    return superUTF8;
-  }
-
-  /// interfacesUTF8 - The names of the interfaces this class implements.
-  ///
-  std::vector<const UTF8*> interfacesUTF8;
-  
-  std::vector<const UTF8*>* getInterfacesUTF8() {
-    return &interfacesUTF8;
-  }
-
   /// lockVar - When multiple threads want to load/resolve/initialize a class,
   /// they must be synchronized so that these steps are only performed once
   /// for a given class.
@@ -312,49 +277,40 @@
   JavaObject* delegatee;
 #endif
   
-
-  typedef std::map<const FieldCmp, JavaField*, std::less<FieldCmp> >::iterator
-    field_iterator;
-  
-  typedef std::map<const FieldCmp, JavaField*, std::less<FieldCmp> > 
-    field_map;
-  
   /// virtualFields - List of all the virtual fields defined in this class.
   /// This does not contain non-redefined super fields.
-  field_map virtualFields;
-  
+  JavaField* virtualFields;
+  uint16 nbVirtualFields;
+
   /// staticFields - List of all the static fields defined in this class.
   ///
-  field_map staticFields;
-  
-  typedef std::map<const FieldCmp, JavaMethod*, std::less<FieldCmp> >::iterator
-    method_iterator;
-  
-  typedef std::map<const FieldCmp, JavaMethod*, std::less<FieldCmp> > 
-    method_map;
+  JavaField* staticFields;
+  uint16 nbStaticFields;
   
   /// virtualMethods - List of all the virtual methods defined by this class.
   /// This does not contain non-redefined super methods.
-  method_map virtualMethods;
+  JavaMethod* virtualMethods;
+  uint16 nbVirtualMethods;
   
   /// staticMethods - List of all the static methods defined by this class.
   ///
-  method_map staticMethods;
+  JavaMethod* staticMethods;
+  uint16 nbStaticMethods;
   
-  field_map* getStaticFields() { return &staticFields; }
-  field_map* getVirtualFields() { return &virtualFields; }
-  method_map* getStaticMethods() { return &staticMethods; }
-  method_map* getVirtualMethods() { return &virtualMethods; }
+  JavaField* getStaticFields()    { return staticFields; }
+  JavaField* getVirtualFields()   { return virtualFields; }
+  JavaMethod* getStaticMethods()  { return staticMethods; }
+  JavaMethod* getVirtualMethods() { return virtualMethods; }
 
-  /// constructMethod - Add a new method in this class method map.
+  /// constructMethod - Create a new method.
   ///
-  JavaMethod* constructMethod(const UTF8* name, const UTF8* type,
-                              uint32 access);
+  JavaMethod* constructMethod(JavaMethod& method, const UTF8* name,
+                              const UTF8* type, uint32 access);
   
-  /// constructField - Add a new field in this class field map.
+  /// constructField - Create a new field.
   ///
-  JavaField* constructField(const UTF8* name, const UTF8* type,
-                            uint32 access);
+  JavaField* constructField(JavaField& field, const UTF8* name,
+                            const UTF8* type, uint32 access);
 
   /// printClassName - Adds a string representation of this class in the
   /// given buffer.
@@ -396,24 +352,24 @@
   /// Do not throw if the method is not found.
   ///
   JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type,
-                                    bool isStatic, bool recurse, Class*& cl);
+                                    bool isStatic, bool recurse, Class** cl);
   
   /// lookupMethod - Lookup a method and throw an exception if not found.
   ///
   JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic,
-                           bool recurse, Class*& cl);
+                           bool recurse, Class** cl);
   
   /// lookupFieldDontThrow - Lookup a field in the field map of this class. Do
   /// not throw if the field is not found.
   ///
   JavaField* lookupFieldDontThrow(const UTF8* name, const UTF8* type,
                                   bool isStatic, bool recurse,
-                                  CommonClass*& definingClass);
+                                  CommonClass** definingClass);
   
   /// lookupField - Lookup a field and throw an exception if not found.
   ///
   JavaField* lookupField(const UTF8* name, const UTF8* type, bool isStatic,
-                         bool recurse, CommonClass*& definingClass);
+                         bool recurse, CommonClass** definingClass);
 
   /// print - Print the class for debugging purposes.
   ///
@@ -509,7 +465,7 @@
   void getDeclaredConstructors(std::vector<JavaMethod*>& res, bool publicOnly);
   void getDeclaredMethods(std::vector<JavaMethod*>& res, bool publicOnly);
   void getDeclaredFields(std::vector<JavaField*>& res, bool publicOnly);
-  void setInterfaces(std::vector<Class*> I) {
+  void setInterfaces(Class** I) {
     interfaces = I;
   }
   void setSuper(CommonClass* S) {
@@ -529,10 +485,6 @@
 
   static UserClassPrimitive* byteIdToPrimitive(char id, Classpath* upcalls);
   
-  void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator) {
-    return allocator.Allocate(sz);
-  }
-
 };
 
 
@@ -542,18 +494,6 @@
 class Class : public CommonClass {
 public:
   
-  /// VT - The virtual table of this class.
-  ///
-  static VirtualTable* VT;
-
-  /// minor - The minor version of this class.
-  ///
-  unsigned int minor;
-
-  /// major - The major version of this class.
-  ///
-  unsigned int major;
-
   /// bytes - The .class file of this class.
   ///
   ArrayUInt8* bytes;
@@ -564,21 +504,31 @@
 
   /// attributs - JVM attributes of this class.
   ///
-  std::vector<Attribut*> attributs;
+  Attribut* attributs;
+  uint16 nbAttributs;
  
 #if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
   /// innerClasses - The inner classes of this class.
   ///
-  std::vector<Class*> innerClasses;
+  Class** innerClasses;
+  uint16 nbInnerClasses;
 
   /// outerClass - The outer class, if this class is an inner class.
   ///
   Class* outerClass;
+  
+  Class* getOuterClass() {
+    return outerClass;
+  }
+
+  Class** getInnerClasses() {
+    return innerClasses;
+  }
 #endif
 
   /// innerAccess - The access of this class, if this class is an inner class.
   ///
-  uint32 innerAccess;
+  uint16 innerAccess;
 
   void setInnerAccess(uint32 access) {
     innerAccess = access;
@@ -662,7 +612,7 @@
 
   /// readAttributs - Reads the attributs of the class.
   ///
-  void readAttributs(Reader& reader, std::vector<Attribut*> & attr);
+  Attribut* readAttributs(Reader& reader, uint16& size);
 
   /// readFields - Reads the fields of the class.
   ///
@@ -687,16 +637,6 @@
   
   void resolveInnerOuterClasses();
 
-#ifndef ISOLATE_SHARING
-  Class* getOuterClass() {
-    return outerClass;
-  }
-
-  std::vector<Class*>* getInnerClasses() {
-    return &innerClasses;
-  }
-#endif
-  
   mvm::JITInfo* JInfo;
   template<typename Ty> 
   Ty *getInfo() {
@@ -726,10 +666,6 @@
 
 public:
   
-  /// VT - The virtual table of array classes.
-  ///
-  static VirtualTable* VT;
-
   /// _baseClass - The base class of the array, or null if not resolved.
   ///
   CommonClass*  _baseClass;
@@ -776,7 +712,7 @@
   virtual void TRACER;
 
   static CommonClass* SuperArray;
-  static std::vector<Class*> InterfacesArray;
+  static Class** InterfacesArray;
 };
 
 /// JavaMethod - This class represents Java methods.
@@ -803,16 +739,18 @@
 
   /// access - Java access type of this method (e.g. private, public...).
   ///
-  unsigned int access;
+  uint16 access;
 
   /// attributs - List of Java attributs of this method.
   ///
-  std::vector<Attribut*> attributs;
+  Attribut* attributs;
+  uint16 nbAttributs;
 
   /// caches - List of caches in this method. For all invokeinterface bytecode
   /// there is a corresponding cache.
   ///
-  std::vector<Enveloppe*> caches;
+  Enveloppe* enveloppes;
+  uint16 nbEnveloppes;
   
   /// classDef - The Java class where the method is defined.
   ///
@@ -950,7 +888,7 @@
 
   /// access - The Java access type of this field (e.g. public, private).
   ///
-  unsigned int access;
+  uint16 access;
 
   /// name - The name of the field.
   ///
@@ -962,7 +900,8 @@
 
   /// attributs - List of Java attributs for this field.
   ///
-  std::vector<Attribut*> attributs;
+  Attribut* attributs;
+  uint16 nbAttributs;
 
   /// classDef - The class where the field is defined.
   ///
@@ -975,7 +914,7 @@
   
   /// num - The index of the field in the field list.
   ///
-  uint32 num;
+  uint16 num;
   
   /// getSignature - Get the signature of this field, resolving it if
   /// necessary.

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Fri Oct 24 04:44:42 2008
@@ -365,10 +365,9 @@
   const UTF8* utf8 = UTF8At(ctpDef[ntIndex] >> 16);
   cl = getMethodClassIfLoaded(entry >> 16);
   if (cl && cl->status >= classRead) {
-    Class* methodCl = 0;
     // lookup the method
     meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access),
-                                     false, methodCl);
+                                     false, 0);
   } 
 }
 
@@ -410,9 +409,8 @@
   CommonClass* cl = getMethodClassIfLoaded(entry >> 16);
   if (cl && cl->status >= classRead) {
     // lookup the method
-    Class* methodCl = 0;
     meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access),
-                                     false, methodCl);
+                                     false, 0);
     if (meth) { 
       // don't throw if no meth, the exception will be thrown just in time
       JnjvmModule* M = classDef->classLoader->TheModule;
@@ -473,9 +471,8 @@
   const UTF8* utf8 = UTF8At(ctpDef[ntIndex] >> 16);
   CommonClass* cl = getMethodClassIfLoaded(entry >> 16);
   if (cl && cl->status >= resolved) {
-    CommonClass* fieldCl = 0; 
     JavaField* field = cl->lookupFieldDontThrow(utf8, sign->keyName, stat, 
-                                                true, fieldCl);
+                                                true, 0);
     // don't throw if no field, the exception will be thrown just in time  
     if (field) {
       if (!stat) {

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Fri Oct 24 04:44:42 2008
@@ -47,8 +47,6 @@
   X fake; \
   X::VT = ((void**)(void*)(&fake))[0]; }
 
-  INIT(Class);
-  INIT(ClassArray);
   INIT(JavaThread);
   INIT(Jnjvm);
   INIT(JnjvmBootstrapLoader);
@@ -110,14 +108,17 @@
   JCL->upcalls->ArrayOfByte = 
     JCL->constructArray(JCL->asciizConstructUTF8("[B"), JCL->upcalls->OfByte);
 
+  JCL->InterfacesArray = 
+    (Class**)JCL->allocator.Allocate(2 * sizeof(UserClass*));
+
   // Now we can create the super and interfaces of arrays.
-  JCL->InterfacesArray.push_back(
+  JCL->InterfacesArray[0] = 
     JCL->loadName(JCL->asciizConstructUTF8("java/lang/Cloneable"), false,
-                  false));
+                  false);
   
-  JCL->InterfacesArray.push_back(
+  JCL->InterfacesArray[1] = 
     JCL->loadName(JCL->asciizConstructUTF8("java/io/Serializable"), false,
-                  false));
+                  false);
   
   JCL->SuperArray = 
     JCL->loadName(JCL->asciizConstructUTF8("java/lang/Object"), false,
@@ -126,8 +127,8 @@
 #ifdef ISOLATE_SHARING
   if (!ClassArray::SuperArray) {
     ClassArray::SuperArray = JCL->SuperArray->classDef;
-    ClassArray::InterfacesArray.push_back((Class*)JCL->InterfacesArray[0]->classDef);
-    ClassArray::InterfacesArray.push_back((Class*)JCL->InterfacesArray[1]->classDef);
+    ClassArray::InterfacesArray[0] = ((Class*)JCL->InterfacesArray[0]->classDef);
+    ClassArray::InterfacesArray[1] = ((Class*)JCL->InterfacesArray[1]->classDef);
   }
 #else
   ClassArray::SuperArray = JCL->SuperArray;

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Fri Oct 24 04:44:42 2008
@@ -790,8 +790,10 @@
   unsigned nbe = readExceptionTable(reader);
   
   exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
-  
-
+  compilingMethod->enveloppes = 
+    new (compilingClass->classLoader->allocator) Enveloppe[nbEnveloppes];
+  compilingMethod->nbEnveloppes = nbEnveloppes;
+  nbEnveloppes = 0;
  
   endBlock = createBasicBlock("end");
 
@@ -2021,12 +2023,10 @@
 
 #ifndef ISOLATE_SHARING
   // ok now the cache
-  mvm::BumpPtrAllocator& allocator = compilingClass->classLoader->allocator;
-  Enveloppe* enveloppe = 
-    new(allocator) Enveloppe(compilingClass->ctpInfo, index);
-  compilingMethod->caches.push_back(enveloppe);
+  Enveloppe& enveloppe = compilingMethod->enveloppes[nbEnveloppes++];
+  enveloppe.initialise(compilingClass->ctpInfo, index);
    
-  Value* llvmEnv = module->getEnveloppe(enveloppe, this);
+  Value* llvmEnv = module->getEnveloppe(&enveloppe, this);
 #else
   Value* llvmEnv = getConstantPoolAt(index,
                                      module->EnveloppeLookupFunction,

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Fri Oct 24 04:44:42 2008
@@ -64,6 +64,10 @@
 
 public:
   
+  JavaJIT() {
+    nbEnveloppes = 0;
+  }
+
   JnjvmModule* module;
 
   static void invokeOnceVoid(Jnjvm* vm, JnjvmClassLoader* loader,
@@ -266,6 +270,10 @@
   static JavaObject* getCallingClassLoader();
   static void printBacktrace();
   static JavaMethod* IPToJavaMethod(void* ip);
+  
+  /// nbEnveloppes - Number of enveloppes (ie invokeinterface) in this
+  /// method.
+  uint32 nbEnveloppes;
 };
 
 enum Opcode {

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Oct 24 04:44:42 2008
@@ -2450,6 +2450,7 @@
         break;
       
       case INVOKEINTERFACE :
+        ++nbEnveloppes;
         i += 4;
         break;
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Fri Oct 24 04:44:42 2008
@@ -34,10 +34,9 @@
   
   cl->initialiseClass(vm);
   bool stat = access == ACC_STATIC ? true : false;
-  UserClass* methodCl = 0;
   JavaMethod* method = cl->lookupMethod(loader->asciizConstructUTF8(func), 
                                         loader->asciizConstructUTF8(sign), stat,
-                                        true, methodCl);
+                                        true, 0);
   va_list ap;
   va_start(ap, access);
   if (stat) {
@@ -146,8 +145,7 @@
   } \
   \
   verifyNull(obj);\
-  UserClass* methodCl = 0; \
-  JavaMethod* meth = obj->classOf->lookupMethod(name, type, false, true, methodCl);\
+  JavaMethod* meth = obj->classOf->lookupMethod(name, type, false, true, 0);\
   \
   Signdef* sign = getSignature(); \
   void* func = meth->compiledPtr();\

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri Oct 24 04:44:42 2008
@@ -60,7 +60,7 @@
   if (!rcache) {
     UserClass* methodCl = 0;
     JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true,
-                                          methodCl);
+                                          &methodCl);
 #ifndef ISOLATE_SHARING
     assert(dmeth->classDef->isReady() &&
            "Class not ready in a virtual lookup.");
@@ -99,13 +99,12 @@
   }
   
   UserCommonClass* cl = 0;
-  UserCommonClass* fieldCl = 0;
   const UTF8* utf8 = 0;
   Typedef* sign = 0;
   
   ctpInfo->resolveField(index, cl, utf8, sign);
   
-  JavaField* field = cl->lookupField(utf8, sign->keyName, false, true, fieldCl);
+  JavaField* field = cl->lookupField(utf8, sign->keyName, false, true, 0);
   
   ctpInfo->ctpRes[index] = (void*)field->ptrOffset;
   
@@ -126,7 +125,7 @@
   
   ctpInfo->resolveField(index, cl, utf8, sign);
   
-  JavaField* field = cl->lookupField(utf8, sign->keyName, true, true, fieldCl);
+  JavaField* field = cl->lookupField(utf8, sign->keyName, true, true, &fieldCl);
   
   fieldCl->initialiseClass(JavaThread::get()->isolate);
   void* ptr = 
@@ -169,7 +168,7 @@
 
   shared->resolveMethod(index, baseCl, utf8, sign);
   UserClass* methodCl = 0;
-  refCl->lookupMethod(utf8, sign->keyName, true, true, methodCl);
+  refCl->lookupMethod(utf8, sign->keyName, true, true, &methodCl);
   ctpInfo->ctpRes[index] = methodCl->getConstantPool();
   shared->ctpRes[clIndex] = refCl->classDef;
   return (void*)methodCl->getConstantPool();
@@ -196,7 +195,7 @@
 
   shared->resolveMethod(index, baseCl, utf8, sign);
   UserClass* methodCl = 0;
-  refCl->lookupMethod(utf8, sign->keyName, false, true, methodCl);
+  refCl->lookupMethod(utf8, sign->keyName, false, true, &methodCl);
   shared->ctpRes[clIndex] = refCl->classDef;
   *res = methodCl->getConstantPool();
   return methodCl->getConstantPool();
@@ -213,9 +212,8 @@
   Signdef* sign = 0;
   
   caller->getConstantPool()->resolveMethod(index, cl, utf8, sign);
-  UserClass* methodCl = 0;
   JavaMethod* dmeth = cl->lookupMethodDontThrow(utf8, sign->keyName, false,
-                                                true, methodCl);
+                                                true, 0);
   if (!dmeth) {
     va_list ap;
     va_start(ap, index);
@@ -224,8 +222,7 @@
     assert(obj->classOf->isReady() && "Class not ready in a virtual lookup.");
     // Arg, the bytecode is buggy! Perform the lookup on the object class
     // and do not update offset.
-    dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true,
-                                       methodCl);
+    dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true, 0);
   } else {
     caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset;
   }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h Fri Oct 24 04:44:42 2008
@@ -15,19 +15,21 @@
 #include "JnjvmConfig.h"
 
 #define UPCALL_CLASS(vm, name)                                                 \
-  vm->loadName(vm->asciizConstructUTF8(name), false, false)                        
+  vm->loadName(vm->asciizConstructUTF8(name), true, false)                        
 
 #define UPCALL_PRIMITIVE_CLASS(loader, name, nb)                               \
   new(loader->allocator)                                                       \
           UserClassPrimitive(loader, loader->asciizConstructUTF8(name), nb)    \
 
 #define UPCALL_FIELD(vm, cl, name, type, acc)                                  \
-  UPCALL_CLASS(vm, cl)->constructField(vm->asciizConstructUTF8(name),          \
-                                       vm->asciizConstructUTF8(type), acc)
+  UPCALL_CLASS(vm, cl)->lookupFieldDontThrow(vm->asciizConstructUTF8(name),    \
+                                             vm->asciizConstructUTF8(type),    \
+                                             isStatic(acc), false, 0)
 
 #define UPCALL_METHOD(vm, cl, name, type, acc)                                 \
-  UPCALL_CLASS(vm, cl)->constructMethod(vm->asciizConstructUTF8(name),         \
-                                        vm->asciizConstructUTF8(type), acc)
+  UPCALL_CLASS(vm, cl)->lookupMethodDontThrow(vm->asciizConstructUTF8(name),   \
+                                              vm->asciizConstructUTF8(type),   \
+                                              isStatic(acc), false, 0)
 
 #define UPCALL_ARRAY_CLASS(loader, name, depth)                                \
   loader->constructArray(                                                      \
@@ -40,14 +42,14 @@
   name = UPCALL_CLASS(loader, "java/lang/reflect/"#name)                   
 
 #define UPCALL_METHOD_EXCEPTION(loader, name) \
-  Init##name = name->constructMethod(loader->asciizConstructUTF8("<init>"), \
-                                     loader->asciizConstructUTF8("(Ljava/lang/String;)V"), \
-                                     ACC_VIRTUAL);
+  Init##name = name->lookupMethodDontThrow(loader->asciizConstructUTF8("<init>"), \
+                                           loader->asciizConstructUTF8("(Ljava/lang/String;)V"), \
+                                           false, false, 0);
 
 #define UPCALL_METHOD_WITH_EXCEPTION(loader, name) \
-  ErrorWithExcp##name = name->constructMethod(loader->asciizConstructUTF8("<init>"), \
+  ErrorWithExcp##name = name->lookupMethodDontThrow(loader->asciizConstructUTF8("<init>"), \
                                      loader->asciizConstructUTF8("(Ljava/lang/Throwable;)V"), \
-                                     ACC_VIRTUAL);
+                                     false, false, 0);
 
 namespace jnjvm {
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp Fri Oct 24 04:44:42 2008
@@ -158,10 +158,9 @@
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, clazz, true);
   if (cl->isArray()) assert(0 && "implement me");
   JavaObject* res = ((UserClass*)cl)->doNew(vm);
-  UserClass* methodCl = 0;
   JavaMethod* init = cl->lookupMethod(Jnjvm::initName, 
               cl->classLoader->asciizConstructUTF8("(Ljava/lang/String;)V"),
-              false, true, methodCl);
+              false, true, 0);
   init->invokeIntSpecial(vm, (UserClass*)cl, res, vm->asciizToStr(msg));
   th->pendingException = res;
   th->returnFromNative();
@@ -329,8 +328,7 @@
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, clazz, true);
   const UTF8* name = vm->asciizToInternalUTF8(aname);
   const UTF8* type = vm->asciizToInternalUTF8(atype);
-  UserClass* methodCl = 0;
-  JavaMethod* meth = cl->lookupMethod(name, type, false, true, methodCl);
+  JavaMethod* meth = cl->lookupMethod(name, type, false, true, 0);
 
   return (jmethodID)meth;
 
@@ -872,10 +870,9 @@
   // TODO: find a better place to store the UTF8
   Jnjvm* vm = JavaThread::get()->isolate;
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, clazz, true);
-  UserCommonClass* realCl = 0;
   return (jfieldID) 
     cl->lookupField(cl->classLoader->asciizConstructUTF8(name),
-                    cl->classLoader->asciizConstructUTF8(sig), 0, 1, realCl);
+                    cl->classLoader->asciizConstructUTF8(sig), 0, 1, 0);
   
   END_EXCEPTION
   return 0;
@@ -1118,8 +1115,7 @@
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, clazz, true);
   const UTF8* name = vm->asciizToInternalUTF8(aname);
   const UTF8* type = vm->asciizToInternalUTF8(atype);
-  UserClass* methodCl = 0;
-  JavaMethod* meth = cl->lookupMethod(name, type, true, true, methodCl);
+  JavaMethod* meth = cl->lookupMethod(name, type, true, true, 0);
 
   return (jmethodID)meth;
 
@@ -1369,11 +1365,10 @@
   // TODO: find a better place to store the UTF8
   Jnjvm* vm = JavaThread::get()->isolate;
   UserCommonClass* cl = NativeUtil::resolvedImplClass(vm, clazz, true);
-  UserCommonClass* realCl = 0;
   return (jfieldID)
     cl->lookupField(cl->classLoader->asciizConstructUTF8(name),
                     cl->classLoader->asciizConstructUTF8(sig), true, true,
-                    realCl);
+                    0);
 
   END_EXCEPTION
   return 0;

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Fri Oct 24 04:44:42 2008
@@ -112,10 +112,9 @@
       cl->resolveStaticClass();
       
       status = inClinit;
-      UserClass* methodCl;
       JavaMethod* meth = lookupMethodDontThrow(Jnjvm::clinitName,
                                                Jnjvm::clinitType, true,
-                                               false, methodCl);
+                                               false, 0);
       
       PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0);
       PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ", 0);
@@ -125,10 +124,9 @@
         (JavaObject*)vm->gcAllocator.allocateManagedObject(cl->getStaticSize(),
                                                            cl->getStaticVT());
       val->initialise(cl);
-      CommonClass::field_map* map = cl->getStaticFields();
-      for (CommonClass::field_iterator i = map->begin(), e = map->end(); i!= e;
-           ++i) { 
-        i->second->initField(val, vm);
+      JavaField* fields = cl->getStaticFields();
+      for (uint32 i = 0; i < cl->nbStaticFields; ++i) {
+        fields[i].initField(val, vm);
       }
   
       cl->setStaticInstance(val);

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Oct 24 04:44:42 2008
@@ -32,7 +32,7 @@
 #ifndef ISOLATE_SHARING
 JnjvmBootstrapLoader* JnjvmClassLoader::bootstrapLoader = 0;
 UserClass* JnjvmBootstrapLoader::SuperArray = 0;
-std::vector<UserClass*> JnjvmBootstrapLoader::InterfacesArray;
+UserClass** JnjvmBootstrapLoader::InterfacesArray;
 #endif
 
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h Fri Oct 24 04:44:42 2008
@@ -289,7 +289,7 @@
   ///
   Classpath* upcalls;
 
-  ISOLATE_STATIC std::vector<UserClass*> InterfacesArray;
+  ISOLATE_STATIC UserClass** InterfacesArray;
   ISOLATE_STATIC UserClass* SuperArray;
 };
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Oct 24 04:44:42 2008
@@ -213,8 +213,8 @@
 
 #ifndef WITHOUT_VTABLE
 VirtualTable* JnjvmModule::allocateVT(Class* cl,
-                                      CommonClass::method_iterator meths) {
-  if (meths == cl->virtualMethods.end()) {
+                                      uint32 index) {
+  if (index == cl->nbVirtualMethods) {
     uint64 size = cl->virtualTableSize;
     mvm::BumpPtrAllocator& allocator = cl->classLoader->allocator;
     VirtualTable* VT = (VirtualTable*)allocator.Allocate(size * sizeof(void*));
@@ -230,14 +230,14 @@
     }
     return VT;
   } else {
-    JavaMethod* meth = meths->second;
+    JavaMethod& meth = cl->virtualMethods[index];
     VirtualTable* VT = 0;
-    if (meth->name->equals(Jnjvm::finalize)) {
-      VT = allocateVT(cl, ++meths);
+    if (meth.name->equals(Jnjvm::finalize)) {
+      VT = allocateVT(cl, ++index);
 #ifndef ISOLATE_SHARING
-      meth->offset = 0;
-      Function* func = cl->classLoader->TheModuleProvider->parseFunction(meth);
-      if (!cl->super) meth->canBeInlined = true;
+      meth.offset = 0;
+      Function* func = cl->classLoader->TheModuleProvider->parseFunction(&meth);
+      if (!cl->super) meth.canBeInlined = true;
       Function::iterator BB = func->begin();
       BasicBlock::iterator I = BB->begin();
       if (isa<ReturnInst>(I)) {
@@ -250,22 +250,21 @@
 #endif
     } else {
     
-      Class* methodCl = 0;
       JavaMethod* parent = cl->super? 
-        cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true,
-                                         methodCl) :
+        cl->super->lookupMethodDontThrow(meth.name, meth.type, false, true,
+                                         0) :
         0;
 
       uint64_t offset = 0;
       if (!parent) {
         offset = cl->virtualTableSize++;
-        meth->offset = offset;
+        meth.offset = offset;
       } else {
         offset = parent->offset;
-        meth->offset = parent->offset;
+        meth.offset = parent->offset;
       }
-      VT = allocateVT(cl, ++meths);
-      LLVMMethodInfo* LMI = getMethodInfo(meth);
+      VT = allocateVT(cl, ++index);
+      LLVMMethodInfo* LMI = getMethodInfo(&meth);
       Function* func = LMI->getMethod();
       ExecutionEngine* EE = mvm::MvmModule::executionEngine;
       ((void**)VT)[offset] = EE->getPointerToFunctionOrStub(func);
@@ -293,7 +292,7 @@
     } else {
       cl->virtualTableSize = VT_NB_FUNCS;
     }
-    res = allocateVT(cl, cl->virtualMethods.begin());
+    res = allocateVT(cl, 0);
   
     if (!(cl->super)) {
       uint32 size =  (cl->virtualTableSize - VT_NB_FUNCS) * sizeof(void*);
@@ -315,7 +314,15 @@
 #ifdef WITH_TRACER
   LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
   const Type* type = stat ? LCI->getStaticType() : LCI->getVirtualType();
-  CommonClass::field_map& fields = stat ? cl->staticFields : cl->virtualFields;
+  JavaField* fields = 0;
+  uint32 nbFields = 0;
+  if (stat) {
+    fields = cl->getStaticFields();
+    nbFields = cl->nbStaticFields;
+  } else {
+    fields = cl->getVirtualFields();
+    nbFields = cl->nbVirtualFields;
+  }
  
   Function* func = Function::Create(JnjvmModule::MarkAndTraceType,
                                     GlobalValue::ExternalLinkage,
@@ -348,10 +355,10 @@
   }
 #endif
   
-  for (CommonClass::field_iterator i = fields.begin(), e = fields.end();
-       i!= e; ++i) {
-    if (i->second->getSignature()->trace()) {
-      LLVMFieldInfo* LFI = getFieldInfo(i->second);
+  for (uint32 i = 0; i < nbFields; ++i) {
+    JavaField& cur = fields[i];
+    if (cur.getSignature()->trace()) {
+      LLVMFieldInfo* LFI = getFieldInfo(&cur);
       std::vector<Value*> args; //size = 2
       args.push_back(zero);
       args.push_back(LFI->getOffset());
@@ -392,8 +399,6 @@
 const Type* LLVMClassInfo::getVirtualType() {
   if (!virtualType) {
     std::vector<const llvm::Type*> fields;
-    JavaField** array = 
-      (JavaField**)alloca(sizeof(JavaField*) * classDef->virtualFields.size());
     
     if (classDef->super) {
       LLVMClassInfo* CLI = 
@@ -403,29 +408,24 @@
       fields.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
     }
     
-    for (CommonClass::field_iterator i = classDef->virtualFields.begin(),
-         e = classDef->virtualFields.end(); i!= e; ++i) {
-      JavaField* field = i->second;
-      array[field->num] = field;
-    }
-    
-    
-    for (uint32 index = 0; index < classDef->virtualFields.size(); ++index) {
-      Typedef* type = array[index]->getSignature();
+    for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) {
+      JavaField& field = classDef->virtualFields[i];
+      field.num = i;
+      Typedef* type = field.getSignature();
       LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type);
       fields.push_back(LAI.llvmType);
     }
     
+    
     StructType* structType = StructType::get(fields, false);
     virtualType = PointerType::getUnqual(structType);
     ExecutionEngine* engine = mvm::MvmModule::executionEngine;
     const TargetData* targetData = engine->getTargetData();
     const StructLayout* sl = targetData->getStructLayout(structType);
     
-    for (CommonClass::field_iterator i = classDef->virtualFields.begin(),
-         e = classDef->virtualFields.end(); i!= e; ++i) {
-      JavaField* field = i->second;
-      field->ptrOffset = sl->getElementOffset(field->num + 1);
+    for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) {
+      JavaField& field = classDef->virtualFields[i];
+      field.ptrOffset = sl->getElementOffset(i + 1);
     }
     
     JnjvmModule* Mod = classDef->classLoader->TheModule;
@@ -446,19 +446,12 @@
   if (!staticType) {
     Class* cl = (Class*)classDef;
     std::vector<const llvm::Type*> fields;
-    JavaField** array = (JavaField**)
-      alloca(sizeof(JavaField*) * (classDef->staticFields.size() + 1));
     fields.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
 
-    for (CommonClass::field_iterator i = classDef->staticFields.begin(),
-         e = classDef->staticFields.end(); i!= e; ++i) {
-      JavaField* field = i->second;
-      array[field->num] = field;
-    }
-
-    for (uint32 index = 0; index < classDef->staticFields.size(); ++index) {
-      JavaField* field = array[index];
-      Typedef* type = field->getSignature();
+    for (uint32 i = 0; i < classDef->nbStaticFields; ++i) {
+      JavaField& field = classDef->staticFields[i];
+      field.num = i;
+      Typedef* type = field.getSignature();
       LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type);
       fields.push_back(LAI.llvmType);
     }
@@ -469,10 +462,9 @@
     const TargetData* targetData = engine->getTargetData();
     const StructLayout* sl = targetData->getStructLayout(structType);
     
-    for (CommonClass::field_iterator i = classDef->staticFields.begin(),
-         e = classDef->staticFields.end(); i!= e; ++i) {
-      JavaField* field = i->second;
-      field->ptrOffset = sl->getElementOffset(field->num + 1);
+    for (uint32 i = 0; i < classDef->nbStaticFields; ++i) {
+      JavaField& field = classDef->staticFields[i];
+      field.ptrOffset = sl->getElementOffset(i + 1);
     }
     
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Fri Oct 24 04:44:42 2008
@@ -212,7 +212,7 @@
 
 
   VirtualTable* makeVT(Class* cl, bool stat);
-  VirtualTable* allocateVT(Class* cl, CommonClass::method_iterator meths);
+  VirtualTable* allocateVT(Class* cl, uint32 index);
 
 
 public:

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=58087&r1=58086&r2=58087&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Fri Oct 24 04:44:42 2008
@@ -37,9 +37,8 @@
   Signdef* sign = 0;
 
   ctpInfo->resolveMethod(index, cl, utf8, sign);
-  Class* methodCl = 0;
   JavaMethod* meth = cl->lookupMethod(utf8, sign->keyName, isStatic, true,
-                                      methodCl);
+                                      0);
 
 #ifndef ISOLATE_SHARING
   // A multi environment would have already initialized the class. Besides,

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Fri Oct 24 04:44:42 2008
@@ -32,8 +32,6 @@
 
   INIT(JavaArray);
   INIT(ArrayObject);
-  INIT(Class);
-  INIT(ClassArray);
   INIT(JavaObject);
   INIT(JavaThread);
   INIT(Jnjvm);
@@ -70,10 +68,11 @@
     (*i)->MARK_AND_TRACE; }}
 
 void CommonClass::TRACER {
-  if (super) super->classLoader->MARK_AND_TRACE;
-  for (std::vector<Class*, gc_allocator<Class*> >::iterator i = interfaces.begin(),
-       e = interfaces.end(); i!= e; ++i) {
-    (*i)->classLoader->MARK_AND_TRACE;
+  if (status >= prepared) {
+    if (super) super->classLoader->MARK_AND_TRACE;
+    for (uint32 i = 0; i < nbInterfaces; ++i) {
+      interfaces[i]->classLoader->MARK_AND_TRACE;
+    }
   }
   classLoader->MARK_AND_TRACE;
 #if !defined(ISOLATE)





More information about the vmkit-commits mailing list