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

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun May 9 09:42:35 PDT 2010


Author: geoffray
Date: Sun May  9 11:42:35 2010
New Revision: 103382

URL: http://llvm.org/viewvc/llvm-project?rev=103382&view=rev
Log:
The array of methods can be pre-computed, get it instead of creating it again.


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=103382&r1=103381&r2=103382&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun May  9 11:42:35 2010
@@ -1120,12 +1120,19 @@
   if (cl->nbVirtualMethods + cl->nbStaticMethods) {
     methods = ConstantArray::get(ATy, TempElts);
     TempElts.clear();
-    std::string name(UTF8Buffer(cl->name).toCompileName()->cString());
-    name += "_VirtualMethods";
-    GlobalVariable* GV = new GlobalVariable(Mod, ATy, false,
-                                            GlobalValue::ExternalLinkage,
-                                            methods, name);
-    virtualMethods.insert(std::make_pair(cl, GV));
+
+    GlobalVariable* GV = NULL;
+    method_iterator SI = virtualMethods.find(cl);
+    if (SI != virtualMethods.end()) {
+      GV = dyn_cast<GlobalVariable>(SI->second);
+      GV->setInitializer(methods);
+    } else {
+      std::string name(UTF8Buffer(cl->name).toCompileName()->cString());
+      name += "_VirtualMethods";
+      GV = new GlobalVariable(Mod, ATy, false, GlobalValue::ExternalLinkage,
+                              methods, name);
+      virtualMethods.insert(std::make_pair(cl, GV));
+    }
     methods = ConstantExpr::getCast(Instruction::BitCast, GV,
                                     JavaIntrinsics.JavaMethodType);
   } else {





More information about the vmkit-commits mailing list