[vmkit-commits] [vmkit] r59244 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMRuntime.cpp VMCore/JavaJIT.cpp VMCore/JavaJIT.h VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h VMCore/LowerConstantCalls.cpp VMCore/NativeUtil.cpp VMCore/NativeUtil.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Nov 13 07:27:28 PST 2008


Author: geoffray
Date: Thu Nov 13 09:27:25 2008
New Revision: 59244

URL: http://llvm.org/viewvc/llvm-project?rev=59244&view=rev
Log:
Code cleanup, no functionality changes.


Modified:
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
    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/LowerConstantCalls.cpp
    vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp
    vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.h

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Thu Nov 13 09:27:25 2008
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <dlfcn.h>
-#include <string.h>
 
 #include "MvmGC.h"
 
@@ -25,6 +23,7 @@
 #include "LockedMap.h"
 #include "NativeUtil.h"
 
+#include <cstring>
 
 using namespace jnjvm;
 
@@ -78,10 +77,10 @@
 
   char* buf = str->strToAsciiz();
   
-  void* res = dlopen(buf, RTLD_LAZY | RTLD_LOCAL);
+  void* res = loader->loadLib(buf);
+  
   if (res != 0) {
-    loader->nativeLibs.push_back(res);
-    onLoad_t onLoad = (onLoad_t)(intptr_t)dlsym(res, "JNI_OnLoad");
+    onLoad_t onLoad = (onLoad_t)loader->loadInLib("JNI_OnLoad", res);
     if (onLoad) onLoad(&vm->javavmEnv, 0);
     return 1;
   } else {
@@ -96,11 +95,7 @@
 jclass clazz,
 #endif
 ) {
-#ifdef MULTIPLE_GC
-    mvm::Thread::get()->GC->collect();
-#else
   Collector::collect();
-#endif
 }
 
 JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(
@@ -151,11 +146,7 @@
 jclass clazz,
 #endif
 ) {
-#ifdef MULTIPLE_GC
-  return (jlong)JavaThread::get()->GC->getFreeMemory();
-#else
   return (jlong)Collector::getFreeMemory();
-#endif
 }
 
 JNIEXPORT jlong Java_java_lang_VMRuntime_totalMemory(
@@ -164,11 +155,7 @@
 jclass clazz,
 #endif
 ) {
-#ifdef MULTIPLE_GC
-  return (jlong)mvm::Thread::get()->GC->getTotalMemory();
-#else
   return (jlong)Collector::getTotalMemory();
-#endif
 }
 
 JNIEXPORT jlong Java_java_lang_VMRuntime_maxMemory(
@@ -177,11 +164,7 @@
 jclass clazz,
 #endif
 ) {
-#ifdef MULTIPLE_GC
-  return (jlong)mvm::Thread::get()->GC->getMaxMemory();
-#else
   return (jlong)Collector::getMaxMemory();
-#endif
 }
 
 JNIEXPORT jint Java_java_lang_VMRuntime_availableProcessors(){

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Thu Nov 13 09:27:25 2008
@@ -168,7 +168,7 @@
 #endif
 }
 
-llvm::Function* JavaJIT::nativeCompile(void* natPtr) {
+llvm::Function* JavaJIT::nativeCompile(intptr_t natPtr) {
   
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "native compile %s\n",
               compilingMethod->printString());
@@ -193,7 +193,7 @@
   Function* func = llvmFunction;
   if (jnjvm) {
     if (!module->isStaticCompiling())
-      module->executionEngine->addGlobalMapping(func, natPtr);
+      module->executionEngine->addGlobalMapping(func, (void*)natPtr);
     return llvmFunction;
   }
   
@@ -290,7 +290,7 @@
     nativeArgs.push_back(i);
   }
   
-  Value* nativeFunc = module->getNativeFunction(compilingMethod, natPtr);
+  Value* nativeFunc = module->getNativeFunction(compilingMethod, (void*)natPtr);
   nativeFunc = new LoadInst(nativeFunc, "", currentBlock);
 
   Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(),

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Thu Nov 13 09:27:25 2008
@@ -83,7 +83,7 @@
   
   
   llvm::Function* javaCompile();
-  llvm::Function* nativeCompile(void* natPtr = 0);
+  llvm::Function* nativeCompile(intptr_t natPtr = 0);
   llvm::Instruction* inlineCompile(llvm::BasicBlock*& curBB,
                                    llvm::BasicBlock* endExBlock,
                                    std::vector<llvm::Value*>& args);
@@ -260,7 +260,7 @@
   uint16 maxLocals;
   uint32 codeLen;
 
-#if defined(ISOLATE) || defined(MULTIPLE_GC)
+#if defined(SERVICE)
   llvm::Value* isolateLocal;
 #if defined(ISOLATE_SHARING)
   llvm::Value* ctpCache;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Thu Nov 13 09:27:25 2008
@@ -664,13 +664,13 @@
   return readerConstructUTF8(buf, n);
 }
 
-void* JnjvmClassLoader::loadLib(const char* buf, bool& jnjvm) {
-  void* res = dlsym(SELF_HANDLE, buf);
+intptr_t JnjvmClassLoader::loadInLib(const char* buf, bool& jnjvm) {
+  uintptr_t res = (uintptr_t)dlsym(SELF_HANDLE, buf);
   
   if (!res) {
     for (std::vector<void*>::iterator i = nativeLibs.begin(),
               e = nativeLibs.end(); i!= e; ++i) {
-      res = dlsym((*i), buf);
+      res = (uintptr_t)dlsym((*i), buf);
       if (res) break;
     }
   } else {
@@ -678,7 +678,17 @@
   }
   
   if (!res && this != bootstrapLoader)
-    res = bootstrapLoader->loadLib(buf, jnjvm);
+    res = bootstrapLoader->loadInLib(buf, jnjvm);
 
-  return res;
+  return (intptr_t)res;
+}
+
+void* JnjvmClassLoader::loadLib(const char* buf) {
+  void* handle = dlopen(buf, RTLD_LAZY | RTLD_LOCAL);
+  if (handle) nativeLibs.push_back(handle);
+  return handle;
+}
+
+intptr_t JnjvmClassLoader::loadInLib(const char* name, void* handle) {
+  return (intptr_t)dlsym(handle, name);
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h Thu Nov 13 09:27:25 2008
@@ -229,7 +229,9 @@
   ///
   std::vector<void*> nativeLibs;
 
-  void* loadLib(const char* buf, bool& jnjvm);
+  intptr_t loadInLib(const char* buf, bool& jnjvm);
+  intptr_t loadInLib(const char* buf, void* handle);
+  void* loadLib(const char* buf);
 };
 
 /// JnjvmBootstrapLoader - This class is for the bootstrap class loader, which

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Thu Nov 13 09:27:25 2008
@@ -344,26 +344,20 @@
   BasicBlock* block = BasicBlock::Create("", func);
   llvm::Value* realArg = new BitCastInst(arg, type, "", block);
 
-#ifdef MULTIPLE_GC
-  Value* GC = ++func->arg_begin();
   std::vector<Value*> Args;
   Args.push_back(arg);
+#ifdef MULTIPLE_GC
+  Value* GC = ++func->arg_begin();
   Args.push_back(GC);
+#endif
   if (stat || cl->super == 0) {
     CallInst::Create(JavaObjectTracerFunction, Args.begin(), Args.end(),
                      "", block);
   } else {
-    CallInst::Create(((Class*)cl->super)->virtualTracer, Args.begin(),
-                     Args.end(), "", block);
-  }
-#else  
-  if (stat || cl->super == 0) {
-    CallInst::Create(JavaObjectTracerFunction, arg, "", block);
-  } else {
     LLVMClassInfo* LCP = (LLVMClassInfo*)getClassInfo((Class*)(cl->super));
-    CallInst::Create(LCP->getVirtualTracer(), arg, "", block);
+    CallInst::Create(LCP->getVirtualTracer(), Args.begin(),
+                     Args.end(), "", block);
   }
-#endif
   
   for (uint32 i = 0; i < nbFields; ++i) {
     JavaField& cur = fields[i];
@@ -377,15 +371,13 @@
       Value* val = new LoadInst(ptr, "", block);
       Value* valCast = new BitCastInst(val, JnjvmModule::JavaObjectType, "",
                                        block);
-#ifdef MULTIPLE_GC
       std::vector<Value*> Args;
       Args.push_back(valCast);
+#ifdef MULTIPLE_GC
       Args.push_back(GC);
+#endif
       CallInst::Create(JnjvmModule::MarkAndTraceFunction, Args.begin(),
                        Args.end(), "", block);
-#else
-      CallInst::Create(JnjvmModule::MarkAndTraceFunction, valCast, "", block);
-#endif
     }
   }
 
@@ -1115,10 +1107,6 @@
   VirtualLookupFunction = module->getFunction("vtableLookup");
 #endif
 
-#ifdef MULTIPLE_GC
-  GetCollectorFunction = module->getFunction("getCollector");
-#endif
-  
   GetLockFunction = module->getFunction("getLock");
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Thu Nov 13 09:27:25 2008
@@ -315,9 +315,6 @@
   llvm::Function* GetVTFunction;
   llvm::Function* GetClassFunction;
   llvm::Function* JavaObjectAllocateFunction;
-#ifdef MULTIPLE_GC
-  llvm::Function* GetCollectorFunction;
-#endif
   llvm::Function* GetVTFromClassFunction;
   llvm::Function* GetObjectSizeFromClassFunction;
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Thu Nov 13 09:27:25 2008
@@ -502,21 +502,6 @@
           BranchInst::Create(NBB, trueCl);
           break;
         }
-#ifdef MULTIPLE_GC
-        else if (V == module->GetCollectorFunction) {
-          Changed = true;
-          Value* val = Call.getArgument(0); 
-          std::vector<Value*> indexes; 
-          indexes.push_back(mvm::MvmModule::constantOne);
-          val = new BitCastInst(val, mvm::MvmModule::ptrPtrType, "", CI);
-          Value* CollectorPtr = GetElementPtrInst::Create(val, indexes.begin(),
-                                                          indexes.end(), "",
-                                                          CI);
-          Value* Collector = new LoadInst(CollectorPtr, "", CI);
-          CI->replaceAllUsesWith(Collector);
-          CI->eraseFromParent();
-        }
-#endif
 
 #ifdef ISOLATE_SHARING
         else if (V == module->GetCtpClassFunction) {

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Thu Nov 13 09:27:25 2008
@@ -165,7 +165,7 @@
 
 }
 
-void* NativeUtil::nativeLookup(CommonClass* cl, JavaMethod* meth, bool& jnjvm) {
+intptr_t NativeUtil::nativeLookup(CommonClass* cl, JavaMethod* meth, bool& jnjvm) {
   const UTF8* jniConsClName = cl->name;
   const UTF8* jniConsName = meth->name;
   const UTF8* jniConsType = meth->type;
@@ -175,13 +175,13 @@
 
   char* buf = (char*)alloca(3 + JNI_NAME_PRE_LEN + mnlen + clen + (mtlen << 1));
   meth->jniConsFromMeth(buf);
-  void* res = cl->classLoader->loadLib(buf, jnjvm);
+  intptr_t res = cl->classLoader->loadInLib(buf, jnjvm);
   if (!res) {
     meth->jniConsFromMeth2(buf);
-    res = cl->classLoader->loadLib(buf, jnjvm);
+    res = cl->classLoader->loadInLib(buf, jnjvm);
     if (!res) {
       meth->jniConsFromMeth3(buf);
-      res = cl->classLoader->loadLib(buf, jnjvm);
+      res = cl->classLoader->loadInLib(buf, jnjvm);
     }
   }
   return res;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.h Thu Nov 13 09:27:25 2008
@@ -28,7 +28,7 @@
 public:
 
   static Jnjvm* myVM(JNIEnv* env);
-  static void* nativeLookup(CommonClass* cl, JavaMethod* meth, bool& jnjvm);
+  static intptr_t nativeLookup(CommonClass* cl, JavaMethod* meth, bool& jnjvm);
   static UserCommonClass* resolvedImplClass(Jnjvm* vm, jclass clazz, bool doClinit);
   static void decapsulePrimitive(Jnjvm *vm, void**&buf, JavaObject* obj,
                                  const Typedef* signature);





More information about the vmkit-commits mailing list