harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r449218 - in /incubator/harmony/enhanced/drlvm/trunk/vm: thread/src/ vmcore/src/jvmti/
Date Sat, 23 Sep 2006 11:22:21 GMT
Author: geirm
Date: Sat Sep 23 04:22:16 2006
New Revision: 449218

URL: http://svn.apache.org/viewvc?view=rev&rev=449218
Log:
HARMONY-1528

jvmtiStopThread as well as Thread.stop() method does not take
into account possibility to stop suspended or waiting threads,
thus the following issues may occur:

- waiting or suspended thread will not throw exceptions
- suspended thread may start processing exception but stop
  at nearest safe_point
- suspend will not suspend waiting thread but will allow
  to process notify and acquire monitor while remain suspended

Attached comment contains fix for this issue as well
as minor correction such as:

- GetAllThread should return newly created local references
- fixed tipo in jvmtiMonitorWaited handled invovation
  (jvmtiMonitorWait instead of jvmtiMonitorWaited)
- Contended monitor events should be generated around wait function


Ubuntu 6, smoke, c-unit, some kernel


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_monitors.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c Sat Sep 23 04:22:16
2006
@@ -417,6 +417,7 @@
     tm_native_thread = hythread_self();
     tm_java_thread = hythread_get_private_data(tm_native_thread);
     excn = tm_java_thread->stop_exception;
+    tm_native_thread->suspend_request = 0;
     jthread_throw_exception_object(excn);
 }
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c Sat Sep 23
04:22:16 2006
@@ -314,6 +314,7 @@
         set_wait_monitor(monitor);
         set_contended_monitor(monitor);
         jvmti_send_wait_monitor_event(monitor, (jlong)millis);
+        jvmti_send_contended_enter_or_entered_monitor_event(monitor, 1);
         set_suspend_disable(disable_count);
 
         // should be moved to event handler
@@ -347,6 +348,7 @@
     if (ti_is_enabled()){
         add_owned_monitor(monitor);
         disable_count =  reset_suspend_disable();
+        jvmti_send_contended_enter_or_entered_monitor_event(monitor, 0);
         jvmti_send_waited_monitor_event(monitor, (status == APR_TIMEUP)?(jboolean)1:(jboolean)0);
         // should be moved to event handler
         set_suspend_disable(disable_count);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c Sat Sep
23 04:22:16 2006
@@ -207,6 +207,12 @@
         status =  condvar_wait_impl(mon_ptr->condition, mon_ptr->mutex, ms, nano, interruptable);
     //printf("finishing wait: %x, %x \n", mon_ptr->condition, hythread_self());
 #endif
+        if(self->suspend_request) {
+            hymutex_unlock(mon_ptr->mutex);
+            hythread_safe_point();
+            hymutex_lock(mon_ptr->mutex);
+        }
+
         mon_ptr->recursion_count = saved_recursion;
         mon_ptr->owner = self;
         assert(mon_ptr->owner);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Sat Sep 23
04:22:16 2006
@@ -333,6 +333,7 @@
  * @param[in] callback callback function
  */
 IDATA hythread_set_safepoint_callback(hythread_t thread, tm_thread_event_callback_proc callback)
{
+    IDATA status;
     while (apr_atomic_casptr((volatile void **)&thread->safepoint_callback, (void
*)callback, (void *)NULL) != NULL);
     if(tm_self_tls == thread) {
         int old_status = thread->suspend_disable_count;
@@ -346,7 +347,13 @@
         send_suspend_request(thread);
         //let the thread execute safe point in the case it's already suspended
         ////
-        hysem_post(thread->resume_event);
+        status = hysem_post(thread->resume_event);
+        assert (status == TM_ERROR_NONE);
+    }
+    
+    if (thread->current_condition) {
+        status=hycond_notify(thread->current_condition);   
+        assert (status == TM_ERROR_NONE);
     }
 
     return TM_ERROR_NONE;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_monitors.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_monitors.c?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_monitors.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_monitors.c Sat Sep 23 04:22:16
2006
@@ -177,13 +177,12 @@
  */
 IDATA VMCALL jthread_raw_monitor_wait(jrawMonitorID mon_ptr, I_64 millis) {
     hythread_monitor_t monitor;
-    IDATA stat;
+
     if (!(monitor = (hythread_monitor_t)array_get(jvmti_monitor_table, (UDATA)mon_ptr)))
{
         return TM_ERROR_INVALID_MONITOR;
     }
-    stat = hythread_monitor_wait_interruptable(monitor, millis, 0);
-    hythread_safe_point();
-    return stat;
+
+    return hythread_monitor_wait_interruptable(monitor, millis, 0);
 }
 
 /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c Sat Sep 23 04:22:16
2006
@@ -62,7 +62,8 @@
     assert(java_thread);
     assert(nanos_ptr);
     tm_native_thread = vm_jthread_get_tm_data(java_thread);
-    return CONVERT_ERROR(apr_get_thread_time(tm_native_thread->os_handle,nanos_ptr));
+    return CONVERT_ERROR(apr_get_thread_time(tm_native_thread->os_handle,
+        (apr_int64_t*) nanos_ptr));
 }
 
 /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Sat Sep 23
04:22:16 2006
@@ -1498,8 +1498,8 @@
 
         case JVMTI_EVENT_MONITOR_WAITED: {
             jobject monitor = va_arg(args, jobject);
-            jboolean is_timed_out   = va_arg(args, jint); //jboolean);
-            ((jvmtiEventMonitorWait)callback_func)((jvmtiEnv*)ti_env, jni_env, 
+            jboolean is_timed_out   = va_arg(args, jint);
+            ((jvmtiEventMonitorWaited)callback_func)((jvmtiEnv*)ti_env, jni_env, 
                     jthread_get_java_thread(hythread_self()), monitor, is_timed_out);
             break;
         }
@@ -1524,8 +1524,18 @@
     TIEnv *ti_env, *next_env;
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     void *callback_func;
-    
+    bool unwindable;
+    jthrowable excn = NULL;
+
     if (! ti->isEnabled()) return;
+    unwindable = set_unwindable(false);
+    
+    if (!unwindable) {
+        if (excn = exn_get()) {
+            exn_clear();
+        }
+    }
+
     ti_env = ti->getEnvironments();
     va_start(args, per_thread);
     while(ti_env) {
@@ -1534,15 +1544,20 @@
                 && (!per_thread || !is_interested_thread(ti_env, event_type))) {
            ti_env = ti_env->next;
            continue;   
-            }
+        }
         
         callback_func = ti_env->get_event_callback(event_type);
         if (callback_func) call_callback(event_type, jni_env, ti_env, callback_func, args);
         ti_env = next_env;
-            }
+    }
+    
+    assert(!exn_get());
+    
+    if (excn) exn_raise_object(excn);
+
+    set_unwindable(unwindable);
     va_end(args);
-        
-        }
+}
 
 void jvmti_send_thread_start_end_event(int is_start)
 {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp?view=diff&rev=449218&r1=449217&r2=449218
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp Sat Sep 23
04:22:16 2006
@@ -128,7 +128,7 @@
         return err; 
     } 
     for (i=0;i<java_thread_count;i++)    {
-        java_threads[i]=jthread_iterator_next(&iterator);
+        java_threads[i]=jni_native_intf->NewLocalRef(jthread_iterator_next(&iterator));
     }
     *threads_count_ptr = java_thread_count;
     *threads_ptr = java_threads;



Mime
View raw message