harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject svn commit: r603102 - in /harmony/enhanced/drlvm/trunk/vm: include/open/ thread/src/ vmcore/src/init/ vmcore/src/thread/
Date Tue, 11 Dec 2007 00:16:39 GMT
Author: xli
Date: Mon Dec 10 16:16:38 2007
New Revision: 603102

URL: http://svn.apache.org/viewvc?rev=603102&view=rev
Log:
HARMONY-5247: [drlvm][init] DRL VM hangs with gc_cc in shutdown

Modified:
    harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
    harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
    harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
    harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Mon Dec 10 16:16:38 2007
@@ -549,6 +549,7 @@
 IDATA VMCALL hythread_thin_monitor_enter(hythread_thin_monitor_t *lockword);
 IDATA VMCALL hythread_thin_monitor_try_enter(hythread_thin_monitor_t *lockword);
 IDATA VMCALL hythread_thin_monitor_exit(hythread_thin_monitor_t *lockword);
+IDATA VMCALL hythread_thin_monitor_release(hythread_thin_monitor_t *lockword);
 IDATA VMCALL hythread_thin_monitor_wait(hythread_thin_monitor_t *lockword);
 IDATA VMCALL hythread_thin_monitor_wait_timed(hythread_thin_monitor_t *lockword_ptr, I_64
ms, IDATA nano);
 IDATA VMCALL hythread_thin_monitor_wait_interruptable(hythread_thin_monitor_t *lockword_ptr,
I_64 ms, IDATA nano);

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h Mon Dec 10 16:16:38 2007
@@ -139,6 +139,7 @@
 VMEXPORT IDATA jthread_monitor_enter(jobject mon);
 VMEXPORT IDATA jthread_monitor_try_enter(jobject mon);
 VMEXPORT IDATA jthread_monitor_exit(jobject mon);
+VMEXPORT IDATA jthread_monitor_release(jobject mon);
 VMEXPORT IDATA jthread_monitor_notify(jobject mon);
 VMEXPORT IDATA jthread_monitor_notify_all(jobject mon);
 VMEXPORT IDATA jthread_monitor_wait(jobject mon);

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Mon Dec 10 16:16:38 2007
@@ -81,6 +81,7 @@
 hythread_thin_monitor_enter
 hythread_thin_monitor_try_enter
 hythread_thin_monitor_exit
+hythread_thin_monitor_release
 hythread_thin_monitor_wait
 hythread_thin_monitor_wait_timed
 hythread_thin_monitor_wait_interruptable

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Mon Dec 10 16:16:38 2007
@@ -83,6 +83,7 @@
 hythread_thin_monitor_enter;
 hythread_thin_monitor_try_enter;
 hythread_thin_monitor_exit;
+hythread_thin_monitor_release;
 hythread_thin_monitor_wait;
 hythread_thin_monitor_wait_timed;
 hythread_thin_monitor_wait_interruptable;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c Mon Dec 10 16:16:38
2007
@@ -468,6 +468,36 @@
     return TM_ERROR_ILLEGAL_STATE;
 }
 
+/**
+ * Completely releases the ownership over monitor.
+ */
+IDATA VMCALL hythread_thin_monitor_release(hythread_thin_monitor_t *lockword_ptr)
+{
+    IDATA status;
+    U_32 lockword = *lockword_ptr;
+    hythread_t self = hythread_self();
+
+    if (self != hythread_thin_monitor_get_owner(lockword_ptr)) {
+        // nothing to do, thread is not an owner of monitor
+        return TM_ERROR_NONE;
+    }
+    if (IS_FAT_LOCK(lockword)) {
+        // this is fat monitor
+        hythread_monitor_t monitor =
+            locktable_get_fat_monitor(FAT_LOCK_ID(lockword));
+        monitor->recursion_count = 0;
+        status = hymutex_unlock(&monitor->mutex);
+        assert(status == TM_ERROR_NONE);
+    } else {
+        // this is thin monitor
+        while (RECURSION(lockword)) {
+            RECURSION_DEC(lockword_ptr, lockword);
+            lockword = *lockword_ptr;
+        }
+        *lockword_ptr = lockword & 0xffff;
+    }
+    return TM_ERROR_NONE;
+}
 
 IDATA thin_monitor_wait_impl(hythread_thin_monitor_t *lockword_ptr, I_64 ms, IDATA nano,
IDATA interruptable) {
     // get this thread

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp Mon Dec 10 16:16:38 2007
@@ -54,6 +54,8 @@
     return JNI_ERR; \
 } \
 
+static jobject java_lang_ThreadGroup_lock_field;
+
 /**
  * Calls java.lang.System.execShutdownSequence() method.
  *
@@ -100,6 +102,9 @@
     IDATA UNUSED status = jthread_detach(java_thread);
     assert(status == TM_ERROR_NONE);
 
+    status = jthread_monitor_release(java_lang_ThreadGroup_lock_field);
+    assert(status == TM_ERROR_NONE);
+
     hythread_exit(NULL);
 }
 
@@ -133,6 +138,17 @@
 
     self = hythread_self();
 
+    // Get java.lang.ThreadGroup.lock field
+    JNIEnv *jni_env = jthread_self_vm_thread()->jni_env;
+    Class* klass = vm_env->java_lang_ThreadGroup_Class;
+    jobject class_handle = struct_Class_to_jclass(klass);
+    jfieldID lock_field_id = jni_env->GetStaticFieldID(class_handle, "lock",
+        "Ljava/lang/ThreadGroup$ThreadGroupLock;");
+    assert(lock_field_id);
+    java_lang_ThreadGroup_lock_field =
+        jni_env->GetStaticObjectField(class_handle, lock_field_id);
+    assert(java_lang_ThreadGroup_lock_field);
+
     // Collect running java threads.
     // Set callbacks to let threads exit
     TRACE2("shutdown", "stopping threads, self " << self);
@@ -158,15 +174,8 @@
 
     TRACE2("shutdown", "cancelling threads");
 
-    JNIEnv *jni_env = jthread_self_vm_thread()->jni_env;
-    Class* klass = vm_env->java_lang_ThreadGroup_Class;
-    jobject class_handle = struct_Class_to_jclass(klass);
-    jfieldID lock_field_id = jni_env->GetStaticFieldID(class_handle, "lock",
-        "Ljava/lang/ThreadGroup$ThreadGroupLock;");
-    assert(lock_field_id);
-    jobject lock_field = jni_env->GetStaticObjectField(class_handle, lock_field_id);
-    assert(lock_field);
-    IDATA status = jthread_monitor_enter(lock_field);
+    // Grab java.lang.ThreadGroup.lock
+    IDATA status = jthread_monitor_enter(java_lang_ThreadGroup_lock_field);
     assert(status == TM_ERROR_NONE);
 
     // forcedly kill remaining threads
@@ -185,7 +194,8 @@
     }
     hythread_iterator_release(&it);
 
-    status = jthread_monitor_exit(lock_field);
+    // release java.lang.ThreadGroup.lock
+    status = jthread_monitor_exit(java_lang_ThreadGroup_lock_field);
     assert(status == TM_ERROR_NONE);
 
     TRACE2("shutdown", "shutting down threads complete");

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp?rev=603102&r1=603101&r2=603102&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp Mon Dec 10
16:16:38 2007
@@ -214,6 +214,24 @@
 } // jthread_monitor_exit
 
 /**
+ * Completely releases the ownership over monitor.
+ *
+ * @param[in] monitor monitor
+ */
+IDATA VMCALL jthread_monitor_release(jobject monitor)
+{
+    assert(monitor);
+
+    hythread_suspend_disable();
+    hythread_thin_monitor_t *lockword = vm_object_get_lockword_addr(monitor);
+    IDATA status = hythread_thin_monitor_release(lockword);
+    assert(status == TM_ERROR_NONE);
+    hythread_suspend_enable();
+
+    return TM_ERROR_NONE;
+} // jthread_monitor_release
+
+/**
  * Notifies one thread waiting on the monitor.
  *
  * Only single thread waiting on the



Mime
View raw message