harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r523162 - in /harmony/enhanced/drlvm/trunk/vm: include/open/ thread/src/ vmcore/include/ vmcore/src/thread/ vmi/src/
Date Wed, 28 Mar 2007 04:20:31 GMT
Author: smishura
Date: Tue Mar 27 21:20:30 2007
New Revision: 523162

URL: http://svn.apache.org/viewvc?view=rev&rev=523162
Log:
Rollback commit r523088:
(Harmony-3065, TLS inlining to improve performance
build, build test pass on win32, RHEL4.0 32-bit w/ gcc4.0.2)

DRL VM fail on Linux x86_64 with: 
java/lang/UnsatisfiedLinkError : Failed loading library "libhytext.so": DSO load failed

Will reopen JIRA issue

Modified:
    harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h
    harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.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_init.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
    harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread.h Tue Mar 27 21:20:30 2007
@@ -21,26 +21,10 @@
 #if defined(__cplusplus)
 extern "C" {
 #endif
-#include <open/types.h>
-
 
 #include <stddef.h>
 #include "hycomp.h"
 
-/* 
- * Idea behind these declarations is to make some functions static inlined for 
- * all files that include hythread_ext.h/hythread.h except one, that 
- * will export this functions in DLL 
- */
-   
-#ifndef hy_inline
-#  ifdef PLATFORM_POSIX
-#    define hy_inline inline static
-#  else
-#     define hy_inline static __forceinline 
-#  endif //PLATFORM_POSIX
-#endif // hy_inline
-
 typedef UDATA hythread_tls_key_t;
 
 #define HYTHREAD_PROC VMCALL
@@ -48,7 +32,6 @@
 typedef IDATA (HYTHREAD_PROC* hythread_entrypoint_t)(void*);
 typedef void (HYTHREAD_PROC* hythread_tls_finalizer_t)(void*);
 typedef struct HyThread *hythread_t;
-typedef struct HyThreadGroup *hythread_group_t;
 typedef struct HyThreadMonitor *hythread_monitor_t;
 typedef struct HySemaphore *hysem_t;
 
@@ -121,7 +104,6 @@
 
 #define HYSIZEOF_HyThreadMonitorTracing 24
 
-
 extern HY_CFUNC void VMCALL
 hythread_detach PROTOTYPE((hythread_t thread));
 extern HY_CFUNC UDATA VMCALL
@@ -165,12 +147,9 @@
 hythread_monitor_init_with_name PROTOTYPE((hythread_monitor_t* handle, UDATA flags, char*
name));
 extern HY_CFUNC IDATA VMCALL 
 hythread_monitor_try_enter PROTOTYPE((hythread_monitor_t monitor));
-extern HY_CFUNC hythread_t VMCALL
-hythread_self_slow PROTOTYPE(());
 extern HY_CFUNC void VMCALL 
 hythread_jlm_thread_clear PROTOTYPE((hythread_t thread));
-
-
+extern HY_CFUNC hythread_t VMCALL hythread_self PROTOTYPE((void));
 extern HY_CFUNC IDATA VMCALL 
 hythread_tls_free PROTOTYPE((hythread_tls_key_t key));
 extern HY_CFUNC UDATA VMCALL
@@ -266,6 +245,8 @@
 hythread_monitor_get_tracing PROTOTYPE((hythread_monitor_t monitor));
 extern HY_CFUNC UDATA VMCALL 
 hythread_get_priority PROTOTYPE((hythread_t thread));
+extern HY_CFUNC void* VMCALL
+hythread_tls_get PROTOTYPE((hythread_t thread, hythread_tls_key_t key));
 extern HY_CFUNC char* VMCALL 
 hythread_monitor_get_name PROTOTYPE((hythread_monitor_t monitor));
 extern HY_CFUNC hythread_monitor_t VMCALL 
@@ -303,201 +284,6 @@
 #define hythread_global_monitor() (*(hythread_monitor_t*)hythread_global("global_monitor"))
 #define hythread_monitor_init(pMon,flags)  hythread_monitor_init_with_name(pMon,flags, #pMon)
 #define hythread_monitor_set_name(pMon,pName)
-
-/**
- * Native thread control structure's public fields.
- */
-
-typedef struct HyThread_public {
-
-#ifndef POSIX
-    // This is dummy pointer for Microsoft Visual Studio debugging
-    // If this is removed, Visual Studio, when attached to VM, will show
-    // no symbolic information
-    void* reserved;
-#endif
-
-// Public fields exported by HyThread_public. If you change these fields,
-// please, check fields in thread_private.h/HyThread
-
-    /**
-     * Number of requests made for this thread, it includes both
-     * suspend requests and safe point callback requests.
-     * The field is modified by atomic operations.
-     *
-     * Increment in functions:
-     *    1. send_suspend_request()
-     *          - sets suspend request for a given thread
-     *    2. hythread_set_safepoint_callback()
-     *          - sets safe point callback request for a given thread
-     *
-     * Decrement in functions:
-     *    1. hythread_resume()
-     *          - removes suspend request for a given thread
-     *    2. hythread_exception_safe_point()
-     *          - removes safe point callback request for current thread
-     */
-    int32 request;
-
-    /**
-     * Field indicating that thread can safely be suspended.
-     * Safe suspension is enabled on value 0.
-     *
-     * The disable_count is increased/decreaded in
-     * hythread_suspend_disable()/hythread_suspend_enable() function
-     * for current thread only.
-     *
-     * Also disable_count could be reset to value 0 and restored in
-     * reset_suspend_disable()/set_suspend_disable() function
-     * for current thread only.
-     *
-     * Function hythread_exception_safe_point() sets disable_count to
-     * value 1 before safe point callback function calling and restores
-     * it after the call.
-     *
-     * Function thread_safe_point_impl() sets disable_count to
-     * value 0 before entering to the safe point and restores it
-     * after exitting.
-     */
-    int16 disable_count;
-
-
-    /**
-     * Group for this thread. Different groups are needed in order 
-     * to be able to quickly iterate over the specific group.
-     * Examples are: Java threads, GC private threads.
-     * Equal to the address of the head of the list of threads for this group.
-     */
-    hythread_group_t  group; 
-
-    /**
-     * Array representing thread local storage
-     */
-    void *thread_local_storage[10];
-
-} HyThread_public;
-
-
-
-/* 
- * FS14_TLS_USE 
- *
- *  FS14_TLS_USE declaration turns on windows specific TLS access optimization
- *  We use free TIB slot with 14 offset, see following article for details
- *  http://www.microsoft.com/msj/archive/S2CE.aspx (currently it's used on
- *  Windows 32-bit)
- *
- * APR_TLS_USE
- *
- *  When APR_TLS_USE is declared DRLVM uses APR functions for getting current
- *  thread. (currently it's used only on Windows 64-bit)
- *
- * If none of these defined, current thread id is kept in the tm_self_tls 
- * variable which is declared as __thread, thread local variable for gcc 
- * (*note Thread-Local:: in gcc.info), in thread_native_basic.c. This 
- * way it works on Linux.
- */
-   
-
-
-#ifdef WIN32
-
-//use optimized asm monitor enter and exit helpers
-#define ASM_MONITOR_HELPER
-
-// FS14_TLS_USE define turns on windows specific TLS access optimization
-// We use free TIB slot with 14 offset, see following article for details
-// http://www.microsoft.com/msj/archive/S2CE.aspx
-#define FS14_TLS_USE
-
-#elif defined _EM64T_ && defined WINDOWS
-
-#define APR_TLS_USE
-#endif
-
-
- 
-
-#ifdef APR_TLS_USE
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-hy_inline hythread_t VMCALL hythread_self() {
-    extern hythread_t hythread_self_slow();
-    return hythread_self_slow();
-}
-
-#define tm_self_tls (hythread_self_slow())
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#elif defined FS14_TLS_USE
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-hy_inline hythread_t VMCALL hythread_self() {
-    register hythread_t t;
-    _asm { mov eax, fs:[0x14]
-           mov t, eax;
-    }
-    return t;
-}
-
-#define tm_self_tls (hythread_self())
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#else
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifdef PLATFORM_POSIX
-extern __thread hythread_t tm_self_tls;
-#else
-extern __declspec(thread) hythread_t tm_self_tls;
-#endif //PLATFORM_POSIX
-
-
-hy_inline hythread_t VMCALL hythread_self() {
-    return tm_self_tls;
-}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * Returns a thread's TLS value.
- */
-hy_inline void* VMCALL
-hythread_tls_get(hythread_t thread, hythread_tls_key_t key) {
-    return ((struct HyThread_public *)thread)->thread_local_storage[key];
-}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
 
 #if defined(__cplusplus)
 }

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?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Tue Mar 27 21:20:30 2007
@@ -123,17 +123,7 @@
 extern "C" {
 #endif
 
-#include "open/hythread.h"
-
-#include <open/types.h>
-#include <apr_pools.h>
-#include <apr_thread_mutex.h>
-#include <apr_thread_cond.h>
-#include <apr_thread_rwlock.h>
-#include <apr_portable.h>
-
-#include <assert.h>
-#include "apr_thread_ext.h"
+#include "hythread.h"
 
 //@{
 /**
@@ -155,7 +145,7 @@
 
 
 typedef struct HyLatch *hylatch_t;
-
+typedef struct HyThreadGroup *hythread_group_t;
 typedef struct HyThread *hythread_iterator_t;
 typedef struct HyThreadLibrary *hythread_library_t;
 
@@ -163,7 +153,6 @@
 
 typedef void (*hythread_event_callback_proc)(void);
 
- 
 //@}
 /** @name Thread Manager initialization / shutdown
  */
@@ -178,7 +167,6 @@
 void VMCALL hythread_shutdown();
 IDATA VMCALL hythread_lib_create(hythread_library_t * lib);
 void VMCALL hythread_lib_destroy(hythread_library_t lib);
-hythread_group_t VMCALL get_java_thread_group(void);
 
 //@}
 /** @name  Basic manipulation 
@@ -197,7 +185,7 @@
 hythread_t VMCALL hythread_get_thread(IDATA id);
 IDATA VMCALL hythread_struct_init(hythread_t *ret_thread);
 IDATA VMCALL hythread_cancel_all(hythread_group_t group);
-IDATA hythread_group_create(hythread_group_t *group);
+ IDATA hythread_group_create(hythread_group_t *group);
 IDATA VMCALL hythread_group_release(hythread_group_t group);
 IDATA VMCALL hythread_group_get_list(hythread_group_t **list, int* size);
 void* VMCALL hythread_get_private_data(hythread_t  t);
@@ -226,11 +214,10 @@
  */
 //@{
 
-hy_inline IDATA VMCALL hythread_is_suspend_enabled();
-hy_inline void VMCALL hythread_suspend_enable();
-hy_inline void VMCALL hythread_suspend_disable();
+IDATA hythread_is_suspend_enabled();
+void hythread_suspend_enable();
+void hythread_suspend_disable();
 void hythread_safe_point();
-void hythread_safe_point_other(hythread_t thread);
 void VMCALL hythread_exception_safe_point();
 IDATA VMCALL hythread_suspend_other(hythread_t thread);
 
@@ -324,102 +311,6 @@
 int VMCALL hythread_is_in_native(hythread_t thread) ;
 int VMCALL hythread_is_daemon(hythread_t thread) ;
 
-
-
-
-// inline functions declarations
-
-
-/**
- * Returns non-zero if thread is suspended.
- */
-hy_inline IDATA VMCALL hythread_is_suspend_enabled(){
-    return ((HyThread_public *)tm_self_tls)->disable_count == 0;
-}
-
-
-/**
- * Denotes the beginning of the code region where safe suspension is possible.
- *
- * The method decreases the disable_count field. The disable_count could be
- * recursive, so safe suspension region is enabled on value 0.
- *
- * <p>
- * A thread marks itself with functions hythread_suspend_enable()
- * and hythread_suspend_disable() in order to denote a safe region of code.
- * A thread may also call hythread_safe_point() method to denote a selected
- * point where safe suspension is possible.
- */
-hy_inline void VMCALL hythread_suspend_enable() {
-    assert(!hythread_is_suspend_enabled());
-
-#ifdef FS14_TLS_USE
-    // the macros could work for WIN32
-    __asm {
-        mov eax, fs:[0x14]
-        dec[eax] HyThread_public.disable_count
-    }
-#else
-    {
-        register hythread_t thread = tm_self_tls;
-        ((HyThread_public *)thread)->disable_count--;
-    }
-#endif
-}
-
-/**
- * Denotes the end of the code region where safe suspension was possible.
- *
- * The method increases the disable_count field. The disable_count could be
- * recursive, so safe suspension region is enabled on value 0.
- * If there was a suspension request set for this thread, the method invokes
- * hythread_safe_point().
- * <p>
- * A thread marks itself with functions hythread_suspend_enable()
- * and hythread_suspend_disable() in order to denote a safe region of code.
- * A thread may also call hythread_safe_point() method to denote a selected
- * point where safe suspension is possible.
- */
-hy_inline void VMCALL hythread_suspend_disable()
-{
-    register hythread_t thread;
-
-    // Check that current thread is in default thread group.
-    // Justification: GC suspends and enumerates threads from
-    // default group only.
-    assert(((HyThread_public *)tm_self_tls)->group == get_java_thread_group());
-
-#ifdef FS14_TLS_USE
-    // the macros could work for WIN32
-    __asm {
-        mov eax, fs:[0x14]
-        inc[eax] HyThread_public.disable_count
-        mov eax,[eax] HyThread_public.request
-        test eax, eax
-        jnz suspended
-    }
-    return;
-
-  suspended:
-    thread = tm_self_tls;
-
-#else
-    thread = tm_self_tls;
-    ((HyThread_public *)thread)->disable_count++;
-#endif
-
-    if (((HyThread_public *)thread)->request && 
-	((HyThread_public *)thread)->disable_count == 1) {
-        // enter to safe point if suspend request was set
-        // and suspend disable was made a moment ago
-        // (it's a point of entry to the unsafe region)
-        hythread_safe_point_other(thread);
-    }
-    return;
-}
-
-#define TM_THREAD_VM_TLS_KEY 0
-#define TM_THREAD_QUANTITY_OF_PREDEFINED_TLS_KEYS 1
 
  //@}
  /**

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=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Tue Mar 27 21:20:30 2007
@@ -62,7 +62,6 @@
 hythread_suspend_disable
 hythread_exception_safe_point
 hythread_safe_point
-hythread_safe_point_other
 hythread_suspend_other
 hythread_set_safepoint_callback
 hythread_suspend_all
@@ -150,6 +149,5 @@
 array_delete
 array_get
 get_java_thread_group
-
 
 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=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Tue Mar 27 21:20:30 2007
@@ -16,7 +16,6 @@
 hythread_monitor_init_with_name;
 hythread_monitor_try_enter;
 hythread_self;
-tm_self_tls;
 hythread_tls_free;
 hythread_yield;
 hythread_suspend;
@@ -62,7 +61,6 @@
 hythread_suspend_disable;
 hythread_exception_safe_point;
 hythread_safe_point;
-hythread_safe_point_other;
 hythread_suspend_other;
 hythread_set_safepoint_callback;
 hythread_suspend_all;
@@ -164,7 +162,6 @@
 get_java_thread_group;
 
 Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset;
-
 
 local: *;
 };

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c Tue Mar 27 21:20:30 2007
@@ -270,7 +270,7 @@
     return hymutex_unlock(&TM_LIBRARY->TM_LOCK);;
 }
 
-hythread_group_t VMCALL get_java_thread_group(void) {
+hythread_group_t  get_java_thread_group(void) {
     return TM_DEFAULT_GROUP;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_monitors.c Tue Mar 27 21:20:30
2007
@@ -359,7 +359,7 @@
     return status;
 }
 
-void add_owned_monitor(jobject monitor){
+void add_owned_monitor(jobject monitor) {
     hythread_t tm_native_thread = hythread_self();
     jvmti_thread_t tm_java_thread = hythread_get_private_data(tm_native_thread);
     int disable_status;
@@ -415,7 +415,7 @@
     //assert(0); monitor - it is no valid monitor
 }
 
-void set_contended_monitor(jobject monitor){
+void set_contended_monitor(jobject monitor) {
     hythread_t tm_native_thread = hythread_self();
     IDATA suspend_status;
     
@@ -429,7 +429,7 @@
     set_suspend_disable(suspend_status);
 }
 
-void set_wait_monitor(jobject monitor){
+void set_wait_monitor(jobject monitor) {
     hythread_t tm_native_thread = hythread_self();
     IDATA suspend_status;
     

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Tue Mar 27 21:20:30 2007
@@ -28,22 +28,16 @@
 #undef LOG_DOMAIN
 #define LOG_DOMAIN "tm.native"
 
-#ifdef PLATFORM_POSIX
-#   define hy_inline inline
-#else
-#   define hy_inline
-#endif //PLATFORM_POSIX
-
 #include <open/hythread_ext.h>
 #include "thread_private.h"
 
-
 typedef struct {
     hythread_t thread;
     hythread_group_t group;
     hythread_entrypoint_t start_proc;
     void * start_proc_args;
 } thread_start_proc_data;
+
 extern hythread_group_t TM_DEFAULT_GROUP;
 extern hythread_library_t TM_LIBRARY;
 static int VMAPICALL thread_start_proc(void *arg);
@@ -350,7 +344,7 @@
  * @see hythread_attach
  *
  */
-hythread_t hythread_self_slow() {
+hythread_t hythread_self() {
     hythread_t  thread;
     apr_status_t UNUSED apr_status;
     
@@ -376,8 +370,11 @@
  * @see hythread_attach
  *
  */
-hythread_t hythread_self_slow() {
-    return hythread_self();
+NAKED hythread_t hythread_self() {
+    _asm { mov eax, fs:[0x14]
+           ret;
+    }
+    //return tm_self_tls;
 }
 
 static void thread_set_self(hythread_t  thread) {
@@ -398,8 +395,8 @@
  * @see hythread_attach
  *
  */
-hythread_t hythread_self_slow() {
-    return hythread_self();
+hythread_t hythread_self() {
+    return tm_self_tls;
 }
 
 static void thread_set_self(hythread_t  thread) {
@@ -736,7 +733,6 @@
         monitor->recursion_count = 0;
         hythread_monitor_exit(monitor);
     }
-
     os_thread_exit(0);
     // unreachable statement
     abort();

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Tue Mar 27 21:20:30
2007
@@ -35,6 +35,95 @@
 //@{
 
 /**
+ * Returns non-zero if thread is suspended.
+ */
+IDATA VMCALL hythread_is_suspend_enabled()
+{
+    return tm_self_tls->disable_count == 0;
+}
+
+
+/**
+ * Denotes the beginning of the code region where safe suspension is possible.
+ *
+ * The method decreases the disable_count field. The disable_count could be
+ * recursive, so safe suspension region is enabled on value 0.
+ *
+ * <p>
+ * A thread marks itself with functions hythread_suspend_enable()
+ * and hythread_suspend_disable() in order to denote a safe region of code.
+ * A thread may also call hythread_safe_point() method to denote a selected
+ * point where safe suspension is possible.
+ */
+void VMCALL hythread_suspend_enable()
+{
+    assert(!hythread_is_suspend_enabled());
+
+#ifdef FS14_TLS_USE
+    // the macros could work for WIN32
+    __asm {
+        mov eax, fs:[0x14]
+        dec[eax] HyThread.disable_count
+    }
+#else
+    {
+        register hythread_t thread = tm_self_tls;
+        thread->disable_count--;
+    }
+#endif
+}
+
+/**
+ * Denotes the end of the code region where safe suspension was possible.
+ *
+ * The method increases the disable_count field. The disable_count could be
+ * recursive, so safe suspension region is enabled on value 0.
+ * If there was a suspension request set for this thread, the method invokes
+ * hythread_safe_point().
+ * <p>
+ * A thread marks itself with functions hythread_suspend_enable()
+ * and hythread_suspend_disable() in order to denote a safe region of code.
+ * A thread may also call hythread_safe_point() method to denote a selected
+ * point where safe suspension is possible.
+ */
+void VMCALL hythread_suspend_disable()
+{
+    register hythread_t thread;
+
+    // Check that current thread is in default thread group.
+    // Justification: GC suspends and enumerates threads from
+    // default group only.
+    assert(tm_self_tls->group == TM_DEFAULT_GROUP);
+
+#ifdef FS14_TLS_USE
+    // the macros could work for WIN32
+    __asm {
+        mov eax, fs:[0x14]
+        inc[eax] HyThread.disable_count
+        mov eax,[eax] HyThread.request
+        test eax, eax
+        jnz suspended
+    }
+    return;
+
+  suspended:
+    thread = tm_self_tls;
+
+#else
+    thread = tm_self_tls;
+    thread->disable_count++;
+#endif
+
+    if (thread->request && thread->disable_count == 1) {
+        // enter to safe point if suspend request was set
+        // and suspend disable was made a moment ago
+        // (it's a point of entry to the unsafe region)
+        thread_safe_point_impl(thread);
+    }
+    return;
+}
+
+/**
  * Denotes a single point where safe exception throwing is possible.
  */
 void VMCALL hythread_exception_safe_point()
@@ -100,16 +189,6 @@
 {
     thread_safe_point_impl(tm_self_tls);
 }
-
-/**
- * Same as hythread_safe_point, but inserts safe point for given thread 
- * other thread.
- */
-void VMCALL hythread_safe_point_other(hythread_t thread)
-{
-    thread_safe_point_impl(tm_self_tls);
-}
-
 
 /**
  * Denotes a single point where safe suspension is

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=523162&r1=523161&r2=523162
==============================================================================
--- 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 Tue Mar 27 21:20:30
2007
@@ -112,8 +112,8 @@
     I_32 lockword_new;
     TRACE(("unreserve self_id %d lock owner %d", hythread_get_id(hythread_self()), THREAD_ID(lockword)));
     assert(hythread_get_id(hythread_self()) == THREAD_ID(lockword));
-    assert (!IS_FAT_LOCK(*lockword_ptr));
-    assert (IS_RESERVED(lockword));
+    assert(!IS_FAT_LOCK(*lockword_ptr));
+    assert(IS_RESERVED(lockword));
     TRACE(("Unreserved self %d \n", ++unreserve_count_self/*, vm_get_object_class_name(lockword_ptr-1)*/));
 
        
     // Set reservation bit to 1 and reduce recursion count

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c Tue Mar 27 21:20:30 2007
@@ -29,7 +29,7 @@
 //@{
 
 int16 tm_tls_capacity = 16;
-int16 tm_tls_size = TM_THREAD_QUANTITY_OF_PREDEFINED_TLS_KEYS;
+int16 tm_tls_size = 0;
 
 static void tls_finalizer_placeholder(void *args) {}
 
@@ -73,6 +73,13 @@
     }
 
     return -1;
+}
+
+/**
+ * Returns a thread's TLS value.
+ */
+void* VMCALL hythread_tls_get(hythread_t thread, hythread_tls_key_t key) {
+    return thread->thread_local_storage[key];
 }
 
 /**

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h Tue Mar 27 21:20:30 2007
@@ -62,13 +62,48 @@
 // FS14_TLS_USE define turns on windows specific TLS access optimization 
 // We use free TIB slot with 14 offset, see following article for details 
 // http://www.microsoft.com/msj/archive/S2CE.aspx
-//#define FS14_TLS_USE
+#define FS14_TLS_USE
 #endif
 
+/*
+#ifdef _EM64T_
+#define APR_TLS_USE
+#endif
+*/
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
+// optimization code
+#if !defined (APR_TLS_USE ) && !defined (FS14_TLS_USE) 
 
+#ifdef PLATFORM_POSIX
+extern __thread hythread_t tm_self_tls;
+#else
+extern __declspec(thread) hythread_t tm_self_tls;
+#endif //PLATFORM_POSIX
+
+#else
+#if defined (WIN32) && defined (FS14_TLS_USE)
+
+__forceinline hythread_t tmn_self_macro() {
+    register hythread_t t;
+    _asm { mov eax, fs:[0x14]
+           mov t, eax;
+    }
+    return t;
+}
+
+
+#define store_tm_self(self)  (__asm(mov self, fs:[0x14]))
+#define tm_self_tls (tmn_self_macro())
+#endif 
+
+#endif
+
+#ifdef APR_TLS_USE
+#define tm_self_tls (hythread_self())
+#endif
 
 
 #ifdef __linux__
@@ -111,9 +146,13 @@
     void* reserved;
 #endif
 
-// Public fields exported by HyThread_public. If you change these fields,
-// please, check fields in hythread.h/HyThread_public
+    /**
+     * Each thread keeps a pointer to the library it belongs to.
+     */
+    HyThreadLibrary * library;
 
+// Suspension 
+    
     /**
      * Number of requests made for this thread, it includes both
      * suspend requests and safe point callback requests.
@@ -134,6 +173,15 @@
     int32 request;
 
     /**
+     * Number of suspend requests made for this thread.
+     * The field is modified by atomic operations.
+     *
+     * After increment/decrement of suspend_count, request field
+     * should be incremented/decremented too.
+     */
+    int32 suspend_count;
+    
+    /**
      * Field indicating that thread can safely be suspended.
      * Safe suspension is enabled on value 0.
      *
@@ -154,40 +202,6 @@
      * after exitting.
      */
     int16 disable_count;
-
-
-    /**
-     * Group for this thread. Different groups are needed in order 
-     * to be able to quickly iterate over the specific group.
-     * Examples are: Java threads, GC private threads.
-     * Equal to the address of the head of the list of threads for this group.
-     */
-    hythread_group_t  group; 
-
-    /**
-     * Array representing thread local storage
-     */
-    void *thread_local_storage[10];
-
-
-// Private fields
-
-    /**
-     * Each thread keeps a pointer to the library it belongs to.
-     */
-    HyThreadLibrary * library;
-
-// Suspension 
-    
-    /**
-     * Number of suspend requests made for this thread.
-     * The field is modified by atomic operations.
-     *
-     * After increment/decrement of suspend_count, request field
-     * should be incremented/decremented too.
-     */
-    int32 suspend_count;
-    
         
     /**
      * Function to be executed at safepoint upon thread resume.
@@ -206,6 +220,14 @@
     hysem_t resume_event;
 
 // Basic manipulation fields
+
+    /**
+     * Group for this thread. Different groups are needed in order 
+     * to be able to quickly iterate over the specific group.
+     * Examples are: Java threads, GC private threads.
+     * Equal to the address of the head of the list of threads for this group.
+     */
+    hythread_group_t  group; 
     
     /**
      * Points to the next thread within the group.
@@ -299,6 +321,11 @@
      * APR thread attributes
      */
     apr_threadattr_t *apr_attrs;
+
+    /**
+     * Array representing thread local storage
+     */
+    void *thread_local_storage[10];
 
     /**
      * Extension to the standard local storage slot.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h Tue Mar 27 21:20:30 2007
@@ -34,8 +34,7 @@
 #include <apr_pools.h>
 
 #include "open/types.h"
-//#include "open/hythread.h"
-#include <open/hythread_ext.h>
+#include "open/hythread.h"
 #include "open/ti_thread.h"
 
 #include "vm_core_types.h"
@@ -47,7 +46,7 @@
 
 
 // 
-#define tmn_suspend_disable assert(hythread_is_suspend_enabled());hythread_suspend_disable
+#define tmn_suspend_disable assert(hythread_is_suspend_enabled());hythread_suspend_disable

 #define tmn_suspend_enable assert(!hythread_is_suspend_enabled());hythread_suspend_enable
 #define tmn_suspend_disable_recursive hythread_suspend_disable
 #define tmn_suspend_enable_recursive hythread_suspend_enable
@@ -174,28 +173,14 @@
 typedef  VM_thread *vm_thread_accessor();
 VMEXPORT extern vm_thread_accessor *get_thread_ptr;
 
-//VMEXPORT VM_thread *get_vm_thread(hythread_t thr);
-//VMEXPORT VM_thread *get_vm_thread_self();
-
-inline VM_thread *get_vm_thread_fast_self() {
-	register hythread_t thr = hythread_self();
-
-    return (VM_thread *)hythread_tls_get(thr, TM_THREAD_VM_TLS_KEY);
-}
-
-inline VM_thread *get_vm_thread(hythread_t thr) {
-    if (thr == NULL) {
-        return NULL;
-    }
-    return (VM_thread *)hythread_tls_get(thr, TM_THREAD_VM_TLS_KEY);
-}
+VMEXPORT VM_thread *get_vm_thread(hythread_t thr);
 
 VMEXPORT void init_TLS_data();
 
 VMEXPORT void set_TLS_data(VM_thread *thread) ;
 uint16 get_self_stack_key();
 
-#define p_TLS_vmthread (get_vm_thread_fast_self())
+#define p_TLS_vmthread (get_thread_ptr())
 
 Registers *thread_gc_get_context(VM_thread *, VmRegisterContext &);
 void thread_gc_set_context(VM_thread *);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp Tue Mar 27 21:20:30
2007
@@ -44,10 +44,8 @@
 #include <apr_pools.h>
 
 #include "open/hythread.h"
-#include "open/hythread_ext.h"
 #include "open/jthread.h"
 #include "open/thread_externals.h"
-
 #include "open/types.h"
 #include "open/vm_util.h"
 #include "open/gc.h"
@@ -214,12 +212,14 @@
     // mode until current thread is not attaced to VM.
     assert(hythread_is_suspend_enabled());
 
+    hythread_t hythread = hythread_self();
+
     if (p_vmt_dummies != NULL) {
 	// VMThread structure is already allocated, we only need to set
 	// TLS
 	set_TLS_data (p_vm_thread);
     } else {
-	p_vm_thread = get_vm_thread(hythread_self());
+	p_vm_thread = get_vm_thread(hythread);
 	
 	if (p_vm_thread != NULL) {
 	    assert (java_vm == p_vm_thread->jni_env->vm); 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp Tue Mar 27 21:20:30
2007
@@ -122,6 +122,13 @@
     }
     return p_vmthread;
 } 
+            
+VM_thread *get_vm_thread(hythread_t thr) {
+    if (thr == NULL) {
+        return NULL;
+    }
+    return (VM_thread *)hythread_tls_get(thr, TLS_key_pvmthread);
+}
 
 VM_thread *get_vm_thread_ptr_safe(JNIEnv *jenv, jobject jThreadObj)
 {
@@ -139,8 +146,12 @@
   
 vm_thread_accessor* get_thread_ptr = get_thread_ptr_stub;
 void init_TLS_data() {
-    //printf ("init TLS data, TLS key = %x \n", TLS_key_pvmthread);
-    TLS_key_pvmthread = TM_THREAD_VM_TLS_KEY;
+    hythread_tls_alloc(&TLS_key_pvmthread);
+#ifndef _EM64T_
+    get_thread_ptr = (vm_thread_accessor*) get_tls_helper(TLS_key_pvmthread);
+    //printf ("init fast call %p\n", get_thread_ptr);
+#endif
+
 }
   
 void set_TLS_data(VM_thread *thread) {

Modified: harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp?view=diff&rev=523162&r1=523161&r2=523162
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp Tue Mar 27 21:20:30 2007
@@ -23,7 +23,7 @@
 
 #include "platform_lowlevel.h"
 #include "vm_trace.h"
-#include "open/hythread.h"
+
 #include "zipsup.h"
 #include "environment.h"
 #include "properties.h"



Mime
View raw message