[vmkit-commits] [vmkit] r109342 - in /vmkit/trunk/lib/J3/Compiler: JavaJIT.cpp JavaJIT.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Jul 24 08:38:55 PDT 2010


Author: geoffray
Date: Sat Jul 24 10:38:55 2010
New Revision: 109342

URL: http://llvm.org/viewvc/llvm-project?rev=109342&view=rev
Log:
don't synchronize on the argument direclty but on the local that saved the argument.


Modified:
    vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.h

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=109342&r1=109341&r2=109342&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Jul 24 10:38:55 2010
@@ -347,10 +347,6 @@
   Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), 2 * sizeof(void*));
   Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock);
   
-  // Synchronize before saying we're entering native
-  if (isSynchro(compilingMethod->access))
-    beginSynchronize();
-
   uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); 
   std::vector<Value*> nativeArgs;
   
@@ -400,6 +396,9 @@
 
       Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "",
                                          func->begin()->getTerminator());
+      if (i == func->arg_begin() && !stat) {
+        this->thisObject = temp;
+      }
       
       if (TheCompiler->useCooperativeGC()) {
         Value* GCArgs[2] = { 
@@ -473,6 +472,10 @@
     currentBlock = endBlock;
     nativeFunc = node;
   }
+
+  // Synchronize before saying we're entering native
+  if (isSynchro(compilingMethod->access))
+    beginSynchronize();
   
   Value* Args4[3] = { temp, oldCLIN, Frame };
 
@@ -727,7 +730,8 @@
 void JavaJIT::beginSynchronize() {
   Value* obj = 0;
   if (isVirtual(compilingMethod->access)) {
-    obj = llvmFunction->arg_begin();
+    assert(thisObject != NULL && "beginSynchronize without this");
+    obj = new LoadInst(thisObject, "", false, currentBlock);
   } else {
     obj = TheCompiler->getJavaClassPtr(compilingClass);
     obj = new LoadInst(obj, "", false, currentBlock);
@@ -738,7 +742,8 @@
 void JavaJIT::endSynchronize() {
   Value* obj = 0;
   if (isVirtual(compilingMethod->access)) {
-    obj = llvmFunction->arg_begin();
+    assert(thisObject != NULL && "endSynchronize without this");
+    obj = new LoadInst(thisObject, "", false, currentBlock);
   } else {
     obj = TheCompiler->getJavaClassPtr(compilingClass);
     obj = new LoadInst(obj, "", false, currentBlock);
@@ -908,6 +913,7 @@
     ++i;
     ++index;
     ++count;
+    thisObject = objectLocals[0];
   }
 
   
@@ -1086,6 +1092,7 @@
     ++i;
     ++index;
     ++count;
+    thisObject = objectLocals[0];
   }
 
   for (;count < max; ++i, ++index, ++count, ++type) {

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=109342&r1=109341&r2=109342&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sat Jul 24 10:38:55 2010
@@ -95,6 +95,7 @@
     currentCtpIndex = -1;
     currentBytecode = -1;
     callNumber = 0;
+    thisObject = NULL;
   }
 
   /// javaCompile - Compile the Java method.
@@ -403,6 +404,8 @@
   
 //===-------------------------- Synchronization  --------------------------===//
   
+  llvm::Value* thisObject;
+
   /// beginSynchronize - Emit synchronization code to acquire the instance
   /// or the class.
   void beginSynchronize();





More information about the vmkit-commits mailing list