[vmkit-commits] [vmkit] r139099 - in /vmkit/trunk/lib/J3: Classpath/JavaUpcalls.cpp Compiler/JavaJIT.cpp Compiler/JavaJIT.h VMCore/Jnjvm.cpp VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Sep 4 06:20:25 PDT 2011


Author: geoffray
Date: Sun Sep  4 08:20:25 2011
New Revision: 139099

URL: http://llvm.org/viewvc/llvm-project?rev=139099&view=rev
Log:
Intrinsify some VMFloat and BMDouble methods.


Modified:
    vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.h
    vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
    vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h

Modified: vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp?rev=139099&r1=139098&r2=139099&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp (original)
+++ vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp Sun Sep  4 08:20:25 2011
@@ -746,6 +746,9 @@
     UPCALL_METHOD(loader, "java/lang/Class", "isArray", "()Z", ACC_VIRTUAL);
   isArray->setNative();
 
+  // Make sure classes the JIT optimizes on are loaded.
+  UPCALL_CLASS(loader, "java/lang/VMFloat");
+  UPCALL_CLASS(loader, "java/lang/VMDouble");
 
   UPCALL_REFLECT_CLASS_EXCEPTION(loader, InvocationTargetException);
   UPCALL_CLASS_EXCEPTION(loader, ArrayStoreException);

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=139099&r1=139098&r2=139099&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sun Sep  4 08:20:25 2011
@@ -1451,7 +1451,29 @@
   }
   
   return 0;
+}
+
+
+Instruction* JavaJIT::lowerFloatOps(const UTF8* name, 
+                                    std::vector<Value*>& args) {
+  JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader;
+  if (name->equals(loader->floatToRawIntBits)) {
+    return new BitCastInst(args[0], Type::getInt32Ty(*llvmContext), "", currentBlock);
+  } else if (name->equals(loader->intBitsToFloat)) {
+    return new BitCastInst(args[0], Type::getFloatTy(*llvmContext), "", currentBlock);
+  }
+  return NULL;
+}
 
+Instruction* JavaJIT::lowerDoubleOps(const UTF8* name, 
+                                    std::vector<Value*>& args) {
+  JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader;
+  if (name->equals(loader->doubleToRawLongBits)) {
+    return new BitCastInst(args[0], Type::getInt64Ty(*llvmContext), "", currentBlock);
+  } else if (name->equals(loader->longBitsToDouble)) {
+    return new BitCastInst(args[0], Type::getDoubleTy(*llvmContext), "", currentBlock);
+  }
+  return NULL;
 }
 
 
@@ -1573,6 +1595,10 @@
 
   if (className->equals(loader->mathName)) {
     val = lowerMathOps(name, args);
+  } else if (className->equals(loader->VMFloatName)) {
+    val = lowerFloatOps(name, args);
+  } else if (className->equals(loader->VMDoubleName)) {
+    val = lowerDoubleOps(name, args);
   }
     
   if (val == NULL) {

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=139099&r1=139098&r2=139099&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sun Sep  4 08:20:25 2011
@@ -486,6 +486,10 @@
   /// lowerMathOps - Map Java Math operations to LLVM intrinsics.
   llvm::Instruction* lowerMathOps(const UTF8* name, 
                                   std::vector<llvm::Value*>& args);
+  llvm::Instruction* lowerFloatOps(const UTF8* name, 
+                                   std::vector<llvm::Value*>& args);
+  llvm::Instruction* lowerDoubleOps(const UTF8* name, 
+                                    std::vector<llvm::Value*>& args);
  
   /// lowerArraycopy - Create a fast path for System.arraycopy.
   void lowerArraycopy(std::vector<llvm::Value*>& args);

Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=139099&r1=139098&r2=139099&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Sun Sep  4 08:20:25 2011
@@ -1053,7 +1053,7 @@
   JavaObject* javaLoader = NULL;
   llvm_gcroot(obj, 0);
   llvm_gcroot(javaLoader, 0);
-  JnjvmClassLoader* loader = bootstrapLoader;
+  JnjvmBootstrapLoader* loader = bootstrapLoader;
   
   // First create system threads.
   finalizerThread = new FinalizerThread(this);
@@ -1159,8 +1159,7 @@
                                                    obj, &javaLoader);
   // load and initialise math since it is responsible for dlopen'ing 
   // libjavalang.so and we are optimizing some math operations
-  UserCommonClass* math = loader->loadName(
-      loader->asciizConstructUTF8("java/lang/Math"), true, true, NULL);
+  UserCommonClass* math = loader->loadName(loader->mathName, true, true, NULL);
   math->asClass()->initialiseClass(this);
 }
 

Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=139099&r1=139098&r2=139099&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Sun Sep  4 08:20:25 2011
@@ -164,6 +164,8 @@
   prelib = asciizConstructUTF8("lib");
   postlib = asciizConstructUTF8(mvm::System::GetDyLibExtension());
   mathName = asciizConstructUTF8("java/lang/Math");
+  VMFloatName = asciizConstructUTF8("java/lang/VMFloat");
+  VMDoubleName = asciizConstructUTF8("java/lang/VMDouble");
   stackWalkerName = asciizConstructUTF8("gnu/classpath/VMStackWalker");
   NoClassDefFoundError = asciizConstructUTF8("java/lang/NoClassDefFoundError");
 
@@ -194,6 +196,10 @@
   DEF_UTF8(sinh);
   DEF_UTF8(tanh);
   DEF_UTF8(finalize);
+  DEF_UTF8(floatToRawIntBits);
+  DEF_UTF8(doubleToRawLongBits);
+  DEF_UTF8(intBitsToFloat);
+  DEF_UTF8(longBitsToDouble);
 
 #undef DEF_UTF8 
 }

Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h?rev=139099&r1=139098&r2=139099&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h Sun Sep  4 08:20:25 2011
@@ -373,6 +373,8 @@
   const UTF8* prelib; 
   const UTF8* postlib; 
   const UTF8* mathName;
+  const UTF8* VMFloatName;
+  const UTF8* VMDoubleName;
   const UTF8* stackWalkerName;
   const UTF8* abs;
   const UTF8* sqrt;
@@ -398,6 +400,10 @@
   const UTF8* sinh;
   const UTF8* tanh;
   const UTF8* finalize;
+  const UTF8* floatToRawIntBits;
+  const UTF8* doubleToRawLongBits;
+  const UTF8* intBitsToFloat;
+  const UTF8* longBitsToDouble;
 
   /// primitiveMap - Map of primitive classes, hashed by id.
   std::map<const char, UserClassPrimitive*> primitiveMap;





More information about the vmkit-commits mailing list