[vmkit-commits] [vmkit] r180457 - In Scala, some classes have more than 2^16 Miranda methods

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:13:34 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:11:53 2013
New Revision: 180457

URL: http://llvm.org/viewvc/llvm-project?rev=180457&view=rev
Log:
In Scala, some classes have more than 2^16 Miranda methods
(cherry picked from commit eee27a2b4e91040e27eeb919d174870f307d7aa4)

Modified:
    vmkit/trunk/lib/j3/VMCore/JavaClass.cpp
    vmkit/trunk/lib/j3/VMCore/JavaClass.h

Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.cpp?rev=180457&r1=180456&r2=180457&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaClass.cpp Thu Apr 25 12:11:53 2013
@@ -355,7 +355,7 @@ JavaMethod* Class::lookupMethodDontThrow
     methods = getVirtualMethods();
     nb = nbVirtualMethods;
   }
-  
+
   for (uint32 i = 0; i < nb; ++i) {
     JavaMethod& res = methods[i];
     if (res.name->equals(name) && res.type->equals(type)) {
@@ -835,7 +835,8 @@ static void computeMirandaMethods(Class*
 }
 
 void Class::readMethods(Reader& reader) {
-  uint16 nbMethods = reader.readU2();
+
+  uint32 nbMethods = reader.readU2();
   vmkit::ThreadAllocator allocator;
   if (isAbstract(access)) {
     virtualMethods = (JavaMethod*)
@@ -845,9 +846,10 @@ void Class::readMethods(Reader& reader)
       new(classLoader->allocator, "Methods") JavaMethod[nbMethods];
   }
   staticMethods = virtualMethods + nbMethods;
-  for (int i = 0; i < nbMethods; i++) {
+  for (uint32 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 = 0;
     if (isStatic(access)) {
@@ -870,8 +872,13 @@ void Class::readMethods(Reader& reader)
     nbMethods += size;
     JavaMethod* realMethods =
       new(classLoader->allocator, "Methods") JavaMethod[nbMethods];
+
+    if (nbMethods < size) {
+        	printf("Error in class %s\n", UTF8Buffer(name).cString());
+    }
     memcpy(realMethods + size, virtualMethods,
            sizeof(JavaMethod) * (nbMethods - size));
+
     nbVirtualMethods += size;
     staticMethods = realMethods + nbVirtualMethods;
     if (size != 0) {

Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.h?rev=180457&r1=180456&r2=180457&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaClass.h Thu Apr 25 12:11:53 2013
@@ -462,7 +462,7 @@ public:
 
   /// nbVirtualMethods - The number of virtual methods.
   ///
-  uint16 nbVirtualMethods;
+  uint32 nbVirtualMethods;
   
   /// staticMethods - List of all the static methods defined by this class.
   ///





More information about the vmkit-commits mailing list