[vmkit-commits] [vmkit] r141489 - in /vmkit/trunk: include/mvm/JIT.h lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/Mvm/Compiler/JIT.cpp mmtk/magic/LowerMagic.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Oct 8 04:37:18 PDT 2011


Author: geoffray
Date: Sat Oct  8 06:37:18 2011
New Revision: 141489

URL: http://llvm.org/viewvc/llvm-project?rev=141489&view=rev
Log:
Use new LLVM atomic instructions.


Modified:
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/mmtk/magic/LowerMagic.cpp

Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=141489&r1=141488&r2=141489&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Sat Oct  8 06:37:18 2011
@@ -101,11 +101,6 @@
   llvm::Function* llvm_memcpy_i32;
   llvm::Function* llvm_memset_i32;
   llvm::Function* llvm_frameaddress;
-  llvm::Function* llvm_atomic_lcs_i8;
-  llvm::Function* llvm_atomic_lcs_i16;
-  llvm::Function* llvm_atomic_lcs_i32;
-  llvm::Function* llvm_atomic_lcs_i64;
-  llvm::Function* llvm_atomic_lcs_ptr;
   llvm::Function* llvm_gc_gcroot;
 
   llvm::Function* conditionalSafePoint;

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=141489&r1=141488&r2=141489&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Oct  8 06:37:18 2011
@@ -629,14 +629,10 @@
   Value* newValMask = BinaryOperator::CreateOr(threadId, lock, "",
                                                currentBlock);
 
-  std::vector<Value*> atomicArgs;
-  atomicArgs.push_back(lockPtr);
-  atomicArgs.push_back(lock);
-  atomicArgs.push_back(newValMask);
-
   // Do the atomic compare and swap.
-  Value* atomic = CallInst::Create(intrinsics->llvm_atomic_lcs_ptr,
-                                   atomicArgs, "", currentBlock);
+  Value* atomic = new AtomicCmpXchgInst(
+      lockPtr, lock, newValMask, SequentiallyConsistent, CrossThread,
+      currentBlock);
   
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic,
                             lock, "");
@@ -682,8 +678,9 @@
   atomicArgs.push_back(lockedMask);
 
   // Do the atomic compare and swap.
-  Value* atomic = CallInst::Create(intrinsics->llvm_atomic_lcs_ptr,
-                                   atomicArgs, "", currentBlock);
+  Value* atomic = new AtomicCmpXchgInst(
+      lockPtr, oldValMask, lockedMask, SequentiallyConsistent, CrossThread,
+      currentBlock);
   
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic,
                             oldValMask, "");

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=141489&r1=141488&r2=141489&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Oct  8 06:37:18 2011
@@ -388,7 +388,7 @@
     // Do a compare and swap, so that we do not overwrtie what a stub might
     // have just updated.
     uintptr_t val = (uintptr_t)
-      __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub);
+      __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, (void*)stub);
     // If there is something in the the constant pool that is not NULL nor
     // the stub, then it's the method.
     if (val != 0 && val != stub) {

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=141489&r1=141488&r2=141489&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Oct  8 06:37:18 2011
@@ -355,14 +355,6 @@
   llvm_frameaddress = module->getFunction("llvm.frameaddress");
   llvm_gc_gcroot = module->getFunction("llvm.gcroot");
 
-  llvm_atomic_lcs_i8 = module->getFunction("llvm.atomic.cmp.swap.i8.p0i8");
-  llvm_atomic_lcs_i16 = module->getFunction("llvm.atomic.cmp.swap.i16.p0i16");
-  llvm_atomic_lcs_i32 = module->getFunction("llvm.atomic.cmp.swap.i32.p0i32");
-  llvm_atomic_lcs_i64 = module->getFunction("llvm.atomic.cmp.swap.i64.p0i64");
-
-  llvm_atomic_lcs_ptr = pointerSizeType == Type::getInt32Ty(Context) ? llvm_atomic_lcs_i32 :
-                                                           llvm_atomic_lcs_i64;
-
   unconditionalSafePoint = module->getFunction("unconditionalSafePoint");
   conditionalSafePoint = module->getFunction("conditionalSafePoint");
   AllocateFunction = module->getFunction("gcmalloc");

Modified: vmkit/trunk/mmtk/magic/LowerMagic.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerMagic.cpp?rev=141489&r1=141488&r2=141489&view=diff
==============================================================================
--- vmkit/trunk/mmtk/magic/LowerMagic.cpp (original)
+++ vmkit/trunk/mmtk/magic/LowerMagic.cpp Sat Oct  8 06:37:18 2011
@@ -201,9 +201,6 @@
 static const char* WordRshlMethod;
 //static const char* WordRshaMethod;
 
-static Function* CASPtr;
-static Function* CASInt;
-
 static const char* AddressArrayClass = "JnJVM_org_vmmagic_unboxed_AddressArray_";
 static const char* ExtentArrayClass = "JnJVM_org_vmmagic_unboxed_ExtentArray_";
 static const char* ObjectReferenceArrayClass = "JnJVM_org_vmmagic_unboxed_ObjectReferenceArray_";
@@ -408,15 +405,6 @@
   }
 
 
-  if (!CASPtr || CASPtr->getParent() != globalModule) {
-    if (pointerSizeType == Type::getInt32Ty(Context)) {
-      CASPtr = globalModule->getFunction("llvm.atomic.cmp.swap.i32.p0i32");
-    } else {
-      CASPtr = globalModule->getFunction("llvm.atomic.cmp.swap.i64.p0i64");
-    }
-    CASInt = globalModule->getFunction("llvm.atomic.cmp.swap.i32.p0i32");
-  }
-
   for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) { 
     BasicBlock *Cur = BI; 
     for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) {
@@ -589,8 +577,8 @@
               Old = new PtrToIntInst(Old, pointerSizeType, "", CI);
               Val = new PtrToIntInst(Val, pointerSizeType, "", CI);
               
-              Value* Args[3] = { Ptr, Old, Val };
-              Value* res = CallInst::Create(CASPtr, Args, "", CI);
+              Value* res = new AtomicCmpXchgInst(
+                  Ptr, Old, Val, SequentiallyConsistent, CrossThread, CI);
               res = new ICmpInst(CI, ICmpInst::ICMP_EQ, res, Old, "");
               res = new ZExtInst(res, FCur->getReturnType(), "", CI);
 
@@ -606,8 +594,8 @@
               Old = new PtrToIntInst(Old, pointerSizeType, "", CI);
               Val = new PtrToIntInst(Val, pointerSizeType, "", CI);
               
-              Value* Args[3] = { Ptr, Old, Val };
-              Value* res = CallInst::Create(CASPtr, Args, "", CI);
+              Value* res = new AtomicCmpXchgInst(
+                  Ptr, Old, Val, SequentiallyConsistent, CrossThread, CI);
               res = new ICmpInst(CI, ICmpInst::ICMP_EQ, res, Old, "");
               res = new ZExtInst(res, FCur->getReturnType(), "", CI);
 





More information about the vmkit-commits mailing list