harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r548585 - in /harmony/enhanced/drlvm/trunk/vm: include/open/ thread/src/ vmcore/src/init/
Date Tue, 19 Jun 2007 04:42:53 GMT
Author: wjwashburn
Date: Mon Jun 18 21:42:52 2007
New Revision: 548585

URL: http://svn.apache.org/viewvc?view=rev&rev=548585
Log:
Harmony-3995, this patch layers a performance mod for lock 
unreservation over code that is known to contain race conditions
Normally this is unacceptable. The deal is that if there is any 
problems with lock reservation, no bugs will be reported. 
Instead, lock unreservation will be turned off until we 
do the general cleanup described in the April 2 dev@harmony posting.

 

Modified:
    harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.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/parse_arguments.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h Mon Jun 18 21:42:52 2007
@@ -129,6 +129,21 @@
 
 VMEXPORT void *vm_allocate_thread_dummies(JavaVM *java_vm);
 
+/**
+ * A structure for thread manager properties
+ * There is the only yet. Others to be added here.
+ */
+struct tm_props {
+    int use_soft_unreservation;
+};
+
+#if !defined(_TM_PROP_EXPORT)
+extern VMIMPORT struct tm_props *tm_properties;
+#else 
+struct tm_props *tm_properties = NULL;
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif

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?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Mon Jun 18 21:42:52 2007
@@ -159,5 +159,5 @@
 array_get
 get_java_thread_group
 
-
+tm_properties;
 Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset

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?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Mon Jun 18 21:42:52 2007
@@ -168,7 +168,7 @@
 array_delete;
 array_get;
 get_java_thread_group;
-
+tm_properties;
 Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset;
 
 

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?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- 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 Jun 18 21:42:52
2007
@@ -22,6 +22,7 @@
 
 #undef LOG_DOMAIN
 #define LOG_DOMAIN "tm.locks"
+#define _TM_PROP_EXPORT
 
 #include <open/hythread_ext.h>
 #include <open/thread_externals.h>
@@ -147,6 +148,7 @@
     assert(!IS_RESERVED(*lockword_ptr));
     TRACE(("unreserved self"));
 }
+          
 
 /*
  * Used lockword
@@ -157,6 +159,8 @@
     uint16 lock_id;
     hythread_t owner;
     IDATA status;
+    I_32 append;
+
     // trylock used to prevent cyclic suspend deadlock
     // the java_monitor_enter calls safe_point between attempts.
     /*status = hymutex_trylock(&TM_LOCK);
@@ -179,21 +183,43 @@
         assert(owner);
         assert(hythread_get_id(owner) == lock_id);
         assert(owner != hythread_self());
+        if(owner->state& 
+                          ( TM_THREAD_STATE_TERMINATED|
+                            TM_THREAD_STATE_WAITING|
+        		    TM_THREAD_STATE_WAITING_INDEFINITELY|
+        		    TM_THREAD_STATE_WAITING_WITH_TIMEOUT|
+        		    TM_THREAD_STATE_SLEEPING|
+        		    TM_THREAD_STATE_SUSPENDED|
+        		    TM_THREAD_STATE_IN_MONITOR_WAIT )
+        ) {
+            append = 0;
+        } else {
+           append = RESERVED_BITMASK;
+        }
+
         status=hythread_suspend_other(owner);
         if (status !=TM_ERROR_NONE) {
 	    return status;
         }
+    } else {
+        append = 0;
+    }
+
+    if(!tm_properties || !tm_properties->use_soft_unreservation) {
+	    append = RESERVED_BITMASK;
     }
+
     // prepare new unreserved lockword and try to CAS it with old one.
     while (IS_RESERVED(lockword)) {
         assert(!IS_FAT_LOCK(lockword));
         TRACE(("unreserving lock"));
-        lockword_new = (lockword | RESERVED_BITMASK);
         if (RECURSION(lockword) != 0) {
+            lockword_new = (lockword | RESERVED_BITMASK);
             assert(RECURSION(lockword) > 0);
             assert(RECURSION(lockword_new) > 0);
             RECURSION_DEC(&lockword_new, lockword_new);
         } else {
+            lockword_new = (lockword | append);
             lockword_new =  lockword_new & 0x0000ffff; 
         }
         if (lockword == apr_atomic_cas32 (((volatile apr_uint32_t*) lockword_ptr), 
@@ -220,8 +246,8 @@
     // To avoid race condition between checking two different
     // conditions inside of assert, the lockword contents has to be
     // loaded before checking.
-    lockword = *lockword_ptr;
-    assert(IS_FAT_LOCK(lockword) || !IS_RESERVED(lockword));
+//    lockword = *lockword_ptr;
+//    assert(IS_FAT_LOCK(lockword) || !IS_RESERVED(lockword));
     return TM_ERROR_NONE;
 }
 #else

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp Mon Jun 18 21:42:52
2007
@@ -242,6 +242,8 @@
         "            Report inlined methods with JVMTI_EVENT_COMPILED_METHOD_LOAD. Makes
sense for optimizing jit.\n"
         "    vm.bootclasspath.appendclasspath (default FALSE):\n"
         "            Append classpath to the bootclasspath.\n"
+	"    thread.soft_unreservation (default FALSE):\n"
+        "            Use soft unreservation scheme.\n"
         "\nOther properties:\n\n"
         "    vm.boot.library.path:\n"
         "            List of directories which contain additional dynamic libraries to load
into VM.\n"

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Mon Jun 18 21:42:52 2007
@@ -669,6 +669,15 @@
 
     initialize_properties(vm_env);
 
+    tm_properties = (struct tm_props*) STD_MALLOC(sizeof(struct tm_props));
+
+    if (!tm_properties) {
+        LWARN(30, "failed to allocate mem for tp properties");
+        return JNI_ERR;
+    }
+
+    tm_properties->use_soft_unreservation = get_boolean_property("thread.soft_unreservation",
FALSE, VM_PROPERTIES);
+
     parse_vm_arguments(vm_env);
 
     vm_env->verify = get_boolean_property("vm.use_verifier", TRUE, VM_PROPERTIES);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp?view=diff&rev=548585&r1=548584&r2=548585
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_properties.cpp Mon Jun 18 21:42:52
2007
@@ -273,6 +273,7 @@
         properties.set_new("vm.jvmti.compiled_method_load.inlined", "false");
         properties.set_new("vm.bootclasspath.appendclasspath", "false");
         properties.set_new("vm.dlls", PORT_DSO_NAME(GC_DLL));
+        properties.set_new("thread.soft_unreservation", "false");
 
         int n_api_dll_files = sizeof(api_dll_files) / sizeof(char *);
         /*



Mime
View raw message