You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/12/27 17:24:16 UTC

svn commit: r607084 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti: jvmti_locals.cpp jvmti_stack.cpp

Author: gshimansky
Date: Thu Dec 27 08:24:16 2007
New Revision: 607084

URL: http://svn.apache.org/viewvc?rev=607084&view=rev
Log:
Fixed JVMTI regression after revision 606926. Thread suspend/resume functions jthread_suspend,
jthread_resume became non-recursive which broke some JVMTI functions. They were changed to
hythread_suspend, hythread_resume recursive versions.


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_locals.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_locals.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_locals.cpp?rev=607084&r1=607083&r2=607084&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_locals.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_locals.cpp Thu Dec 27 08:24:16 2007
@@ -122,7 +122,7 @@
     if (si_is_past_end(si))                                 \
     {                                                       \
         if (thread_suspended)                               \
-            jthread_resume(thread);                         \
+            hythread_resume((hythread_t)vm_thread);         \
         si_free(si);                                        \
         return JVMTI_ERROR_NO_MORE_FRAMES;                  \
     }                                                       \
@@ -130,7 +130,7 @@
     if (si_is_native(si))                                   \
     {                                                       \
         if (thread_suspended)                               \
-            jthread_resume(thread);                         \
+            hythread_resume((hythread_t)vm_thread);         \
         si_free(si);                                        \
         return JVMTI_ERROR_OPAQUE_FRAME;                    \
     }                                                       \
@@ -214,7 +214,8 @@
         vm_thread = jthread_get_vm_thread_ptr_safe(thread);
         if (vm_thread != p_TLS_vmthread)
         {
-            jthread_suspend(thread);
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
             thread_suspended = true;
         }
     }
@@ -285,7 +286,7 @@
     }
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return err;
 }
@@ -325,7 +326,8 @@
         vm_thread = jthread_get_vm_thread_ptr_safe(thread);
         if (vm_thread != p_TLS_vmthread)
         {
-            jthread_suspend(thread);
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
             thread_suspended = true;
         }
     }
@@ -366,7 +368,7 @@
     }
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return err;
 }
@@ -406,7 +408,8 @@
         vm_thread = jthread_get_vm_thread_ptr_safe(thread);
         if (vm_thread != p_TLS_vmthread)
         {
-            jthread_suspend(thread);
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
             thread_suspended = true;
         }
     }
@@ -434,7 +437,7 @@
     }
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return err;
 }
@@ -474,7 +477,8 @@
         vm_thread = jthread_get_vm_thread_ptr_safe(thread);
         if (vm_thread != p_TLS_vmthread)
         {
-            jthread_suspend(thread);
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
             thread_suspended = true;
         }
     }
@@ -502,7 +506,7 @@
     }
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return err;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp?rev=607084&r1=607083&r2=607084&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp Thu Dec 27 08:24:16 2007
@@ -303,13 +303,15 @@
             // to avoid suspension of each other due to race condition
             // get global thread lock as it's done in hythread_suspend_all().
             IDATA UNREF status = hythread_global_lock();
-            assert(0 == status);
+            assert(TM_ERROR_NONE == status);
+
+            status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
 
-            jthread_suspend(thread);
             thread_suspended = true;
 
             status = hythread_global_unlock();
-            assert(0 == status);
+            assert(TM_ERROR_NONE == status);
         }
     }
     else
@@ -322,7 +324,7 @@
         err = get_stack_trace_jit(vm_thread, start_depth, max_frame_count, frame_buffer, count_ptr);
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return err;
 } // jvmtiGetStackTrace
@@ -473,25 +475,17 @@
        return res;
 
     int i;
-    jthread currentThread = getCurrentThread();
+    vm_thread_t self = jthread_self_vm_thread();
     // stopping all threads
     for(i = 0; i < count; i++) {
         // FIXME: thread can be dead at this time
         // event handler for thread death should block thread death
         // until the function end.
         info[i].thread = threads[i];
-        res = jvmtiGetThreadState(env, threads[i], &info[i].state);
-
-        if (JVMTI_ERROR_NONE != res) {
-            _deallocate((unsigned char *) info);
-            return res;
-        }
-
-        // FIXME: suspended thread might be resumed in other jvmti thread?
-        if (info[i].state != JVMTI_THREAD_STATE_SUSPENDED) {
-            if (IsSameObject(p_TLS_vmthread->jni_env, currentThread, threads[i]))
-                continue;
-            jthread_suspend(threads[i]);
+        vm_thread_t vm_thread = jthread_get_vm_thread_ptr_safe(threads[i]);
+        if (self != vm_thread) {
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
         }
     }
 
@@ -513,8 +507,10 @@
 
     // unsuspend suspended threads.
     for(i = 0; i < count; i++) {
-        if (info[i].state != JVMTI_THREAD_STATE_SUSPENDED)
-            jthread_resume(threads[i]);
+        vm_thread_t vm_thread = jthread_get_vm_thread_ptr_safe(threads[i]);
+        if (self != vm_thread) {
+            hythread_resume((hythread_t)vm_thread);
+        }
     }
 
     if (JVMTI_ERROR_NONE != res)
@@ -579,7 +575,8 @@
         vm_thread = jthread_get_vm_thread_ptr_safe(thread);
         if (vm_thread != p_TLS_vmthread)
         {
-            jthread_suspend(thread);
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
             thread_suspended = true;
         }
     }
@@ -598,7 +595,7 @@
     }
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return errStack;
 } // jvmtiGetFrameCount
@@ -748,7 +745,8 @@
         vm_thread = jthread_get_vm_thread_ptr_safe(thread);
         if (vm_thread != p_TLS_vmthread)
         {
-            jthread_suspend(thread);
+            IDATA UNREF status = hythread_suspend_other((hythread_t)vm_thread);
+            assert(TM_ERROR_NONE == status);
             thread_suspended = true;
         }
     }
@@ -776,7 +774,7 @@
     }
 
     if (thread_suspended)
-        jthread_resume(thread);
+        hythread_resume((hythread_t)vm_thread);
 
     return errStack;
 } // jvmtiGetFrameLocation