[vmkit-commits] [vmkit] r137026 - /vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Aug 6 15:03:56 PDT 2011


Author: geoffray
Date: Sat Aug  6 17:03:55 2011
New Revision: 137026

URL: http://llvm.org/viewvc/llvm-project?rev=137026&view=rev
Log:
Put UTF8s and class references in the precompiled resolved constant pools.


Modified:
    vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp

Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=137026&r1=137025&r2=137026&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Aug  6 17:03:55 2011
@@ -183,7 +183,15 @@
     ArrayType* ATy = ArrayType::get(JavaIntrinsics.ptrType, ctp->ctpSize);
     std::vector<Constant*> Vals;
     for (uint32 i = 0; i < ctp->ctpSize; ++i) {
-      Vals.push_back(Constant::getNullValue(JavaIntrinsics.ptrType));
+      if (ctp->typeAt(i) == JavaConstantPool::ConstantUTF8) {
+        Vals.push_back(ConstantExpr::getBitCast(getUTF8(ctp->UTF8At(i)), JavaIntrinsics.ptrType));
+      } else if (ctp->typeAt(i) == JavaConstantPool::ConstantClass
+                  && (ctp->isClassLoaded(i) != NULL)) {
+        Vals.push_back(ConstantExpr::getBitCast(
+            getNativeClass(ctp->isClassLoaded(i)), JavaIntrinsics.ptrType));
+      } else {
+        Vals.push_back(Constant::getNullValue(JavaIntrinsics.ptrType));
+      }
     }
 
     Constant* Array = ConstantArray::get(ATy, Vals);
@@ -2372,6 +2380,15 @@
     meth->code = Func;
   }
 
+  // Make sure classes and arrays already referenced in constant pools
+  // are loaded.
+  for (ClassMap::iterator i = loader->getClasses()->map.begin(),
+       e = loader->getClasses()->map.end(); i!= e; ++i) {
+    if (i->second->isClass()) {
+      getResolvedConstantPool(i->second->asClass()->ctpInfo);
+    }
+  }
+
   // Add all class initializers.
   for (ClassMap::iterator i = loader->getClasses()->map.begin(),
        e = loader->getClasses()->map.end(); i!= e; ++i) {





More information about the vmkit-commits mailing list