[vmkit-commits] [vmkit] r180551 - Fix Cooperative/Uncooperative code functions. Fixed local frame management.

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:24:03 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:22:33 2013
New Revision: 180551

URL: http://llvm.org/viewvc/llvm-project?rev=180551&view=rev
Log:
Fix Cooperative/Uncooperative code functions. Fixed local frame management.
(cherry picked from commit c8b95ea6a078b407aac99f6bef039605da98bb94)

Modified:
    vmkit/trunk/include/vmkit/Thread.h
    vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/j3/VMCore/Jni.cpp
    vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp

Modified: vmkit/trunk/include/vmkit/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/Thread.h?rev=180551&r1=180550&r2=180551&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/Thread.h (original)
+++ vmkit/trunk/include/vmkit/Thread.h Thu Apr 25 12:22:33 2013
@@ -117,7 +117,6 @@ public:
   Thread() {
     lastExceptionBuffer = 0;
     lastKnownFrame = 0;
-    inUncooperativeCode = false;
   }
 
   /// yield - Yield the processor to another thread.
@@ -214,7 +213,7 @@ public:
   void enterUncooperativeCode(uint16_t level = 0) __attribute__ ((noinline));
   void enterUncooperativeCode(word_t SP);
   void leaveUncooperativeCode();
-  bool isInUncooperativeCode()	{	return inUncooperativeCode;	};
+  bool isInUncooperativeCode()	{	return lastSP;	};
   word_t waitOnSP();
 
 
@@ -277,10 +276,6 @@ public:
   ///
   ExceptionBuffer* lastExceptionBuffer;
 
-  /// inUncooperativeCode - Status of the Thread toward Collection.
-  ///
-  bool inUncooperativeCode;
-
   void internalThrowException();
 
   void startKnownFrame(KnownFrame& F) __attribute__ ((noinline));

Modified: vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll?rev=180551&r1=180550&r2=180551&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll Thu Apr 25 12:22:33 2013
@@ -41,8 +41,7 @@
 ;;; field 9:  void*  routine
 ;;; field 10: void*  lastKnownFrame
 ;;; field 11: void*  lastExceptionBuffer
-;;; field 12: bool   inUncooperativeCode
-%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8*, i1 }
+%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8* }
 
 %JavaThread = type { %MutatorThread, i8*, %JavaObject* }
 

Modified: vmkit/trunk/lib/j3/VMCore/Jni.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/Jni.cpp?rev=180551&r1=180550&r2=180551&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/Jni.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/Jni.cpp Thu Apr 25 12:22:33 2013
@@ -316,6 +316,7 @@ jobject PopLocalFrame(JNIEnv* env, jobje
   assert(toRemove >= 0 && "Local frame has negative number of references to remove");
   th->JNIlocalFrames.pop_back();
   th->localJNIRefs->removeJNIReferences(th,toRemove);
+  *(th->currentAddedReferences) -= toRemove;
 
   if(result){
   	res = *(JavaObject**)result;

Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=180551&r1=180550&r2=180551&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Thu Apr 25 12:22:33 2013
@@ -192,8 +192,8 @@ void Thread::scanStack(word_t closure) {
 
 void Thread::enterUncooperativeCode(uint16_t level) {
   if (isVmkitThread()) {
-    if (!inRV && !inUncooperativeCode) {
-      assert(!lastSP && "SP already set when entering uncooperative code");
+  	if (!inRV) {
+  		assert(!lastSP && "SP already set when entering uncooperative code");
       // Get the caller.
       word_t temp = System::GetCallerAddress();
       // Make sure to at least get the caller of the caller.
@@ -204,27 +204,25 @@ void Thread::enterUncooperativeCode(uint
       __sync_bool_compare_and_swap(&lastSP, 0, temp);
       if (doYield) joinRVBeforeEnter();
       assert(lastSP && "No last SP when entering uncooperative code");
-      inUncooperativeCode=true;
     }
   }
 }
 
 void Thread::enterUncooperativeCode(word_t SP) {
   if (isVmkitThread()) {
-    if (!inRV && !inUncooperativeCode) {
+  	if (!inRV) {
       assert(!lastSP && "SP already set when entering uncooperative code");
       // The cas is not necessary, but it does a memory barrier.
       __sync_bool_compare_and_swap(&lastSP, 0, SP);
       if (doYield) joinRVBeforeEnter();
       assert(lastSP && "No last SP when entering uncooperative code");
-      inUncooperativeCode=true;
     }
   }
 }
 
 void Thread::leaveUncooperativeCode() {
   if (isVmkitThread()) {
-    if (!inRV && inUncooperativeCode) {
+  	if (!inRV) {
       assert(lastSP && "No last SP when leaving uncooperative code");
       word_t savedSP = lastSP;
       // The cas is not necessary, but it does a memory barrier.
@@ -232,7 +230,6 @@ void Thread::leaveUncooperativeCode() {
       // A rendezvous has just been initiated, join it.
       if (doYield) joinRVAfterLeave(savedSP);
       assert(!lastSP && "SP has a value after leaving uncooperative code");
-      inUncooperativeCode=false;
     }
   }
 }





More information about the vmkit-commits mailing list