You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/08/23 18:49:21 UTC

svn commit: r434076 [12/18] - in /incubator/harmony/enhanced/drlvm/trunk: build/make/components/ build/make/components/vm/ build/make/targets/ build/patches/lnx/ build/patches/lnx/APR/ build/patches/lnx/APR/threadproc/ build/patches/lnx/APR/threadproc/...

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/mon_enter_exit.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/mon_enter_exit.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/mon_enter_exit.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/mon_enter_exit.h Wed Aug 23 09:48:41 2006
@@ -31,103 +31,17 @@
 extern "C" {
 #endif
 
-
-//      object header bits layout
-//
-//      31..............16      15......8           7......0
-//      stack_key               recursion_count      ^^^^^^^7-bit hash
-//                                                  ^contention_bit 
-
-#define FREE_MONITOR 0
-
 #define P_HASH_CONTENTION_BYTE(x) ( (uint8 *)(x->get_obj_info_addr()) )
-#define P_STACK_KEY_SHORT(x)      ( (uint16 *)((((ManagedObject*)x)->get_obj_info_addr())) + 1 )
-
-#define P_HASH_CONTENTION(x)      P_HASH_CONTENTION_BYTE(x)
-#define P_RECURSION(x)            P_RECURSION_BYTE(x)
-#define P_STACK_KEY(x)            P_STACK_KEY_SHORT(x)
-
-#define HASH_CONTENTION(x)        ( *P_HASH_CONTENTION(x) )
-#define RECURSION(x)              ( *P_RECURSION(x) )
-#define STACK_KEY(x)              ( *P_STACK_KEY(x) )
-
-
+#define P_HASH_CONTENTION(x)      ((POINTER_SIZE_INT)P_HASH_CONTENTION_BYTE(x))
 
 // This is called once at startup, before any classes are loaded,
 // and after arguments are parsed.  It should set function pointers
 // to the appropriate values.
 void vm_monitor_init();
-
-// Tries to acquire the lock, but will not block or allow GC to
-// happen if it is already locked by another thread.
-// It is only called from block_on_mon_enter() which is called
-// from vm_monitor_enter_slow() and thread_object_wait(),
-// which basically means that it is not part of the general
-// locking interface.
-Boolean vm_try_monitor_enter(ManagedObject *p_obj);
-
 // Does a monitorexit operation.
 extern void (*vm_monitor_exit)(ManagedObject *p_obj);
-extern void (*vm_monitor_exit_handle)(jobject jobj);
-
-// Does a monitorenter, possibly blocking if the object is already
-// locked.
-void vm_monitor_enter_slow(ManagedObject *p_obj);
-VMEXPORT void vm_monitor_enter_slow_handle (jobject jobj);
-
 extern void (*vm_monitor_enter)(ManagedObject *p_obj);
-
-// Called only from vm_monitor_enter_slow() and thread_object_wait(),
-// which basically means that it is not part of the general
-// locking interface.
-void block_on_mon_enter(jobject obj);
-
-// Tries to find a thread that is waiting on the lock for p_obj.
-// If one is found, it is unblocked so that it can try again to
-// acquire the lock.
-void find_an_interested_thread(ManagedObject *p_obj);
-
-#define RECURSION_OFFSET 1
-#define STACK_KEY_OFFSET 2
-#define INPUT_ARG_OFFSET 4
-#define HASH_CONTENTION_AND_RECURSION_OFFSET 0
-#define CONTENTION_MASK 0x80
 #define HASH_MASK 0x7e
-
-#define SPIN_LOOP_COUNT 0x2
-
-void set_hash_bits(ManagedObject *p_obj);
-
-typedef struct mon_enter_fields {
-    ManagedObject *p_obj;
-    VM_thread *p_thr;
-} mon_enter_fields;
-
-extern mon_enter_fields mon_enter_array[];
-extern ManagedObject *obj_array[];
-
-typedef struct mon_wait_fields {
-    ManagedObject *p_obj;
-    VM_thread *p_thr;
-} mon_wait_fields;
-
-extern mon_wait_fields mon_wait_array[];
-
-#ifdef _DEBUG
-extern VM_thread *thread_array_for_debugging_only[];
-extern int max_notifyAll;
-extern int max_recursion;
-extern int total_sleep_timeouts;
-extern int total_sleep_interrupts;
-extern int total_wait_timeouts;
-extern int total_wait_interrupts;
-extern int total_illegal_mon_state_exceptions;
-extern int iterations_per_thread[];
-extern int max_block_on_mon_enter_loops;
-#endif
-
-extern volatile int active_thread_count;
-
 
 #ifdef __cplusplus
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_generic.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_generic.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_generic.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_generic.h Wed Aug 23 09:48:41 2006
@@ -29,7 +29,7 @@
 void
 java_lang_Object_notifyAll(jobject);
 
-int
+jint
 java_lang_Object_wait(jobject, jlong);
 
 void

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h Wed Aug 23 09:48:41 2006
@@ -33,7 +33,7 @@
 
 #include <assert.h>
 #include "open/types.h"
-#include "open/thread.h"
+#include "open/hythread_ext.h"
 #include "jni.h"
 #include "open/vm.h"
 typedef struct VTable VTable;
@@ -87,14 +87,14 @@
             return ((ManagedObjectUncompressedVtablePtr *)this)->vt_unsafe();
     }
     VTable *vt() {
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         if (are_vtable_pointers_compressed())
             return ((ManagedObjectCompressedVtablePtr *)this)->vt();
         else
             return ((ManagedObjectUncompressedVtablePtr *)this)->vt();
     }
     uint32 get_obj_info() {
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         if (are_vtable_pointers_compressed())
             return ((ManagedObjectCompressedVtablePtr *)this)->get_obj_info();
         else
@@ -103,7 +103,7 @@
     uint32 *get_obj_info_addr() { return (uint32 *)((char *)this + header_offset()); }
 
     void set_obj_info(uint32 value) {
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         if (are_vtable_pointers_compressed())
             ((ManagedObjectCompressedVtablePtr *)this)->set_obj_info(value);
         else

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/suspend_checker.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/suspend_checker.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/suspend_checker.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/suspend_checker.h Wed Aug 23 09:48:41 2006
@@ -22,19 +22,19 @@
 #ifndef _SUSPEND_CHECKER_H_
 #define _SUSPEND_CHECKER_H_
 
-#include "open/thread.h"
+#include "open/hythread_ext.h"
 
 class SuspendEnabledChecker
 {
 public:
     inline SuspendEnabledChecker()
     {
-        assert(tmn_is_suspend_enabled());
+        assert(hythread_is_suspend_enabled());
     }
 
     inline ~SuspendEnabledChecker()
     {
-        assert(tmn_is_suspend_enabled());
+        assert(hythread_is_suspend_enabled());
     }
 };
 
@@ -43,12 +43,12 @@
 public:
     inline SuspendDisabledChecker()
     {
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
     }
 
     inline ~SuspendDisabledChecker()
     {
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
     }
 };
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_generic.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_generic.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_generic.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_generic.h Wed Aug 23 09:48:41 2006
@@ -29,33 +29,11 @@
 extern "C" {
 #endif
 
-#define MAX_VM_THREADS 2048
-
-#define java_lang_Thread_NORM_PRIORITY 5L
-
-VM_thread *get_vm_thread_ptr(void *p_ref);
-
-void Java_java_lang_Thread_setPriority_generic(VM_thread *p_thr, long pty);
-jint Java_java_lang_Thread_countStackFrames_generic(VM_thread *p_thr);
-
 VMEXPORT VM_thread *get_vm_thread_ptr_safe(JNIEnv *, jobject);
 
-
 /////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////
 
-
-void Java_java_lang_Thread_start_generic(JNIEnv *, jobject,
-                                         jvmtiEnv * jvmtiEnv, jvmtiStartFunction proc, 
-                                         const void* arg, jint priority);
-
-void Java_java_lang_Thread_interrupt_generic(VM_thread *) ;
-
-void Java_java_lang_Thread_sleep_generic(JNIEnv *, VM_thread *, int64);
-
-void set_interrupt_flag_in_thread_object(JNIEnv *, jobject );
-
-void wait_until_non_daemon_threads_are_dead();
 
 #ifdef __cplusplus
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h Wed Aug 23 09:48:41 2006
@@ -27,44 +27,20 @@
 extern "C" {
 #endif
 
-struct tm_iterator_t{
-    bool init;
-    VM_thread * current;
-};
-
-void tm_acquire_tm_lock();
-void tm_release_tm_lock();
-bool tm_try_acquire_tm_lock();
-
-tm_iterator_t * tm_iterator_create();
-int             tm_iterator_release(tm_iterator_t *);
-int             tm_iterator_reset(tm_iterator_t *);
-VM_thread *     tm_iterator_next(tm_iterator_t *);
  
 void vm_thread_shutdown();
 void vm_thread_init(Global_Env *p_env);
 
-VM_thread * get_a_thread_block();
-void tmn_thread_attach();
+void vm_thread_attach();
+void vm_thread_detach();
 
 void free_this_thread_block(VM_thread *);
+VM_thread * get_a_thread_block();
 
-extern VM_thread *p_free_thread_blocks;
-extern VM_thread *p_active_threads_list;
-extern VM_thread *p_threads_iterator;
 
 extern volatile VM_thread *p_the_safepoint_control_thread;  // only set when a gc is happening
 extern volatile safepoint_state global_safepoint_status;
 
-extern unsigned non_daemon_thread_count;
-
-extern VmEventHandle non_daemon_threads_dead_handle;
-extern VmEventHandle new_thread_started_handle;
-
-extern VmEventHandle non_daemon_threads_are_all_dead;
-
-extern thread_array quick_thread_id[];
-extern POINTER_SIZE_INT hint_free_quick_thread_id;
 
 #ifdef __cplusplus
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/verify_stack_enumeration.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/verify_stack_enumeration.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/verify_stack_enumeration.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/verify_stack_enumeration.h Wed Aug 23 09:48:41 2006
@@ -29,7 +29,7 @@
  * BEWARE! This code is used in _DEBUG configuration only 
  */
 
-#include "open/thread.h"
+#include "vm_threads.h"
 
 extern int verify_stack_enumeration_period;
 extern int verify_stack_enumeration_counter;
@@ -42,7 +42,7 @@
 {
     // We verify stack enumeration only when the thread
     // is about to enable suspend, or just disabled it
-    if (p_TLS_vmthread->suspend_enabled_status != 1) return;
+    if (hythread_is_suspend_enabled()) return;
 
     // NB: safepoints in suspend enabled mode are ignored
     // such safepoints are used in suspend.cpp to avoid deadlocks

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h Wed Aug 23 09:48:41 2006
@@ -17,6 +17,6 @@
 #ifndef _VERSION_SVN_TAG_
 #define _VERSION_SVN_TAG_
 
-#define VERSION_SVN_TAG  "431478"
+#define VERSION_SVN_TAG  "433609"
 
 #endif // _VERSION_SVN_TAG_

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_log.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_log.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_log.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_log.h Wed Aug 23 09:48:41 2006
@@ -72,7 +72,7 @@
 * The convenience method for logging managed objects.
 */
 inline LoggerString& operator<<(LoggerString& log, /*const*/ ManagedObject* object) {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     if (object) {
         log << object->vt()->clss << "@" << (void*) object;
     } else {
@@ -85,13 +85,13 @@
 * The convenience method for logging JNI object handles.
 */
 inline LoggerString& operator<<(LoggerString& log, const jobject jobj) {
-    tmn_suspend_disable_recursive();
+    hythread_suspend_disable();
     if (jobj) {
         log << jobj->object;
     } else {
         log << "<null jobject>";
     }
-    tmn_suspend_enable_recursive();
+    hythread_suspend_enable();
     return log;
 }
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h Wed Aug 23 09:48:41 2006
@@ -31,28 +31,22 @@
 #endif
 
 #include "open/types.h"
+#include "open/hythread.h"
+#include "open/ti_thread.h"
 #include "vm_core_types.h"
 #include "object_layout.h"
 #include "open/vm_gc.h"
 #include "jvmti.h"
 
-#define GC_BYTES_IN_THREAD_LOCAL (20 * sizeof(void *))
-#define MAX_OWNED_MONITORS 100
 
+// 
+#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
 
-// for SMP use the below
-#define vm_lock_prefix lock
+#define GC_BYTES_IN_THREAD_LOCAL (20 * sizeof(void *))
 
-enum java_state {
-    zip = 0,
-    thread_is_sleeping,
-    thread_is_waiting,
-    thread_is_timed_waiting, 
-    thread_is_birthing,
-    thread_is_running,
-    thread_is_blocked,
-    thread_is_dying
-};
 // These are thread level gc states. 
 enum gc_state {
     zero = 0,
@@ -61,26 +55,6 @@
     gc_enumeration_done
 };
 
-#if defined(PLATFORM_POSIX) && defined(_IPF_)
-enum register_state {
-    NOT_VALID = (uint64)-1,
-};
-
-enum suspend_state {
-    NOT_SUSPENDED = 0,
-    SUSPENDED_IN_SIGNAL_HANDLER = 1,
-    SUSPENDED_IN_DISABLE_GC_FOR_THREAD = 2,
-};
-#endif
-
-typedef struct _thread_array {
-    VM_thread *p_vmthread;
-} thread_array;
-
-typedef struct {
-    jvmtiEnv * env;
-    void * data;
-} JVMTILocalStorage;
 
 struct jvmti_frame_pop_listener;
 
@@ -93,10 +67,6 @@
     // has corrupted list of modules and no debug info at all.
     void* system_private_data;
 
-    // Pointer to java.lang.Thread associated with this VM_thread
-    // TODO: replace with jthread?
-    volatile Java_java_lang_Thread*   p_java_lang_thread;
-
     // In case exception is thrown, Exception object is put here
     // TODO: Needs to be replaced with jobject!
     volatile ManagedObject*           p_exception_object;
@@ -110,30 +80,12 @@
     // Should JVMTI code be notified about exception in p_exception_object
     bool                              ti_exception_callback_pending;
 
-    VM_thread*                        p_free;
-    
-    // Next active thread in the global tread list
-    VM_thread*                        p_active;
-
-    // ??
-    java_state                        app_status;
-
     // ??
     gc_state                          gc_status; 
-
-    // Thread states as specified by JVMTI (alive, running, e.t.c.)
-    unsigned                          jvmti_thread_state;
-
+    int                               finalize_thread_flags;
     // Flag indicating whether thread stopped. Duplicate of thread_state?
     bool                              is_stoped;
 
-    // ??
-    bool                              interrupt_a_waiting_thread;
-
-
-    // JVMTI support. Seems to be duplicate.
-    jobject                           jvmti_owned_monitors[MAX_OWNED_MONITORS];
-    int                               jvmti_owned_monitor_count;
     JVMTILocalStorage                 jvmti_local_storage;
     jvmti_frame_pop_listener          *frame_pop_listener;
 
@@ -154,40 +106,6 @@
     bool                              gc_wait_for_enumeration;
     bool                              restore_context_after_gc_and_resume;
     
-    int                              finalize_thread_flags;
-
-    VmEventHandle                    event_handle_monitor;
-    VmEventHandle                    event_handle_sleep;
-    VmEventHandle                    event_handle_interrupt;
-    VmThreadHandle                   thread_handle;
-    VmEventHandle                    jvmti_resume_event_handle;
-    pthread_t                         thread_id;
-
-    VmEventHandle                    park_event;
-    // OS specifics goes below
-    
-        // ============== new SUSPEND related variables: =====================
-    volatile int           suspend_enabled_status; // reentrant implementation
-                                              // 0 --enable, >0 disable
-    volatile int suspend_request; // request to suspend the thread, countable
-                                 // should relplace suspend_count
-    
-    VmEventHandle suspended_event; // set when thread is suspended 
-                                   // should replace is_suspended
-
-    VmEventHandle resume_event;
-    //sem_t sem_resume;              // post it to resume
-                                   // should replace suspend_sem
-    //old suspend related variables 
-        // How many times thread was suspended? Need to be resumed same amount of time. 
-    int                               suspend_count;
-
-    // Flag indicating whether thread suspended. Duplicate of thread_state?
-    bool                              is_suspended;
-
-#if defined(PLATFORM_POSIX)
-    sem_t                             yield_other_sem;
-#endif    
     
 #if defined(PLATFORM_POSIX) && defined(_IPF_)
     // Linux/IPF
@@ -202,195 +120,32 @@
                                             // t[0] <= rnat, t[1] <= bsp      for other   thread context
 #endif
 
-    // ??
-    int                               thread_index;
-
-    // object wait/notify event
-    int                               notify_recursion_count;
-    VmEventHandle                    event_handle_notify_or_interrupt;    
-
-    unsigned short                    stack_key;
-    // ??
     void *lastFrame;
     void *firstFrame;
     int interpreter_state;
+    void** stack_end;       /// The upper boundary of the stack to scan when verifying stack enumeration
 
     void* get_ip_from_regs() { return regs.get_ip(); }
     void reset_regs_ip() { return regs.reset_ip(); }
 
-    // TODO: need to be moved from here to the right place
-    int setPriority(int priority);
-    // is it used??
-    void * jvmtiLocalStorage;
-
-    // JVMTI support. Also needs to be moved somewhere.
-    jint get_jvmti_thread_state(jthread thread);
-    void set_jvmti_thread_state(int one_bit_state);
-
-    // dead-lock checks code
-#define MAX_THREAD_LOCKS 256
-#ifdef _DEBUG 
-    void* locks[MAX_THREAD_LOCKS];
-    int locks_size;
-    void* contendent_lock;
-    void** stack_end;       /// The upper boundary of the stack to scan when verifying stack enumeration
-#endif //_DEBUG
 
 };
 
-   // dead-lock checks code
-
-#ifdef _DEBUG 
-void push_lock(VM_thread *thread, void* lock);
-void pop_lock(VM_thread *thread, void* lock);
-void contends_lock(VM_thread *thread, void* lock);
-#define JAVA_CODE_PSEUDO_LOCK ((void*)-2)
-
-#define DEBUG_PUSH_LOCK(lock) push_lock(p_TLS_vmthread, lock)
-#define DEBUG_POP_LOCK(lock) pop_lock(p_TLS_vmthread, lock)
-#define DEBUG_CONTENDS_LOCK(lock) contends_lock(p_TLS_vmthread, lock)
-#else //_DEBUG
-#define DEBUG_PUSH_LOCK(lock) 
-#define DEBUG_POP_LOCK(lock)
-#define DEBUG_CONTENDS_LOCK(lock)
-#endif //_DEBUG
+typedef  VM_thread *vm_thread_accessor();
+VMEXPORT extern vm_thread_accessor *get_thread_ptr;
 
+VMEXPORT VM_thread *get_vm_thread(hythread_t thr);
 
-extern int next_thread_index;
+VMEXPORT void init_TLS_data();
 
-#if defined(PLATFORM_POSIX) || defined(_IPF_) || defined (_IPF) || defined (WIN64)
-#define USE_TLS_API
-#endif
-
-#ifdef USE_TLS_API
-#ifdef PLATFORM_POSIX
-extern __thread VM_thread *p_TLS_vmthread;
-//#define p_TLS_vmthread ((VM_thread *)pthread_getspecific(TLS_key_pvmthread))
-#define init_TLS_data() //pthread_key_create(&TLS_key_pvmthread, NULL) 
-#define set_TLS_data(pvmthread) do {    \
-    /*pthread_setspecific(TLS_key_pvmthread, (const void *)pvmthread);*/    \
-    p_TLS_vmthread = pvmthread; \
-    if (pvmthread != (void*)NULL) \
-        ((VM_thread *)pvmthread)->stack_key = \
-            (unsigned short)((VM_thread *)pvmthread)->thread_index;      \
-  } while(0);
-#else //PLATFORM_POSIX
-extern __declspec( thread ) VM_thread *p_TLS_vmthread;
-#define set_TLS_data(pvmthread) do { \
-     p_TLS_vmthread = pvmthread;\
-    if (pvmthread != (void*)NULL) \
-         ((VM_thread *)pvmthread)->stack_key = \
-             ((VM_thread *)pvmthread)->thread_index; \
-  } while(0);
-#endif //!PLATFORM_POSIX 
+VMEXPORT void set_TLS_data(VM_thread *thread) ;
 uint16 get_self_stack_key();
-VM_thread *get_thread_ptr();
 
-#else //USE_TLS_API
-
-#pragma warning(push) 
-#pragma warning(disable:4035)
-inline VM_thread *get_thread_ptr()
-{
-    VM_thread *p_thr;
-    _asm{ mov eax, fs:[0x14]
-          mov p_thr, eax 
-    }
-    return p_thr;
-
-}
-#pragma warning(pop) 
-inline void set_TLS_data(VM_thread *pvmthread)  
-{ 
-    _asm{ 
-        mov eax, pvmthread
-        mov fs:[0x14], eax
-    }
-    if (pvmthread != (void*)NULL)
-        pvmthread->stack_key = pvmthread->thread_index; 
-}
 #define p_TLS_vmthread (get_thread_ptr())
-uint16 get_self_stack_key();
-#endif //!USE_TLS_API
-
-#ifdef PLATFORM_POSIX
-bool SuspendThread(unsigned tid);
-bool ResumeThread(unsigned tid);
-#define SUSPEND_THREAD(vmthread) SuspendThread((vmthread)->thread_id)
-#define RESUME_THREAD(vmthread) ResumeThread((vmthread)->thread_id)
-
-#else //PLATFORM_POSIX
-
-#define SUSPEND_THREAD(vmthread) SuspendThread((vmthread)->thread_handle)
-#define RESUME_THREAD(vmthread) ResumeThread((vmthread)->thread_handle)
-#endif //!PLATFORM_POSIX
-
-
-bool thread_suspend_generic(VM_thread *thread);
-bool thread_resume_generic(VM_thread *thread);
-
-void suspend_all_threads_except_current_generic();
-void resume_all_threads_generic();
-
-VMEXPORT void suspend_all_threads_except_current();
-
-VMEXPORT void resume_all_threads();
-
-void jvmti_thread_resume(VM_thread *thread);
-
-void object_locks_init();
-
-void __cdecl call_the_run_method( void * p_xx );
 
-/*
- * Thread park/unpark methods for java.util.concurrent.LockSupport;
- */
-int park(void);
-int parktimed(jlong milis, jint nanos);
-int parkuntil(jlong milis, jint nanos);
-int unpark(VM_thread *thread);
-
-
-
-void thread_gc_suspend_one(VM_thread *);
-uint32 thread_gc_number_of_threads(); 
-VM_thread *thread_gc_enumerate_one();
 Registers *thread_gc_get_context(VM_thread *, VmRegisterContext &);
 void thread_gc_set_context(VM_thread *);
 
 struct Global_Env;
 
-#ifdef __cplusplus
-extern "C" {
-#endif
- 
-void vm_thread_shutdown();
-void vm_thread_init(Global_Env *p_env);
-
-VM_thread * get_a_thread_block();
-
-void free_this_thread_block(VM_thread *);
-
-extern VM_thread *p_free_thread_blocks;
-extern VM_thread *p_active_threads_list;
-extern VM_thread *p_threads_iterator;
-
-extern volatile VM_thread *p_the_safepoint_control_thread;  // only set when a gc is happening
-extern volatile safepoint_state global_safepoint_status;
-
-extern unsigned non_daemon_thread_count;
-
-extern VmEventHandle non_daemon_threads_dead_handle;
-extern VmEventHandle new_thread_started_handle;
-
-extern VmEventHandle non_daemon_threads_are_all_dead;
-
-extern thread_array quick_thread_id[];
-extern POINTER_SIZE_INT hint_free_quick_thread_id;
-
-#ifdef __cplusplus
-}
-#endif
-
-     
 #endif //!_VM_THREADS_H_

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Wed Aug 23 09:48:41 2006
@@ -28,7 +28,8 @@
 #include "vm_arrays.h"
 #include "vm_strings.h"
 #include "properties.h"
-#include "open/thread.h"
+
+#include "open/hythread_ext.h"
 #include "thread_manager.h"
 
 #include "Verifier_stub.h"
@@ -995,7 +996,7 @@
 
 Class_Handle class_find_class_from_loader(ClassLoaderHandle loader, const char* n, Boolean init)
 {
-    assert(tmn_is_suspend_enabled()); // -salikh
+    assert(hythread_is_suspend_enabled()); // -salikh
     char *new_name = strdup(n);
     char *p = new_name;
     while (*p) {
@@ -1009,7 +1010,7 @@
         ch = class_load_verify_prepare_by_loader_jni(
             VM_Global_State::loader_env, name, loader);
     } else {
-        assert(tmn_is_suspend_enabled());
+        assert(hythread_is_suspend_enabled());
         ch = class_load_verify_prepare_from_jni(VM_Global_State::loader_env, name);
     }
     if (!ch) return NULL;
@@ -1181,7 +1182,7 @@
 
 Class_Handle method_get_throws(Method_Handle mh, unsigned idx)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     assert(mh);
     Method* m = (Method*)mh;
     String* exn_name = m->get_exception_name(idx);
@@ -1758,7 +1759,7 @@
 // -gc magic needs this to do the recursive load.
 Class_Handle field_get_class_of_field_value(Field_Handle fh)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     assert(fh);
     Class_Handle ch = class_load_class_by_descriptor(field_get_descriptor(fh), 
                                           field_get_class(fh));
@@ -2291,7 +2292,7 @@
 void vm_gc_lock_enum()
 {
     tmn_suspend_enable();
-    tm_acquire_tm_lock();
+    hythread_global_lock();
     tmn_suspend_disable();
 } // vm_gc_lock_enum
 
@@ -2299,7 +2300,7 @@
 
 void vm_gc_unlock_enum()
 {
-    tm_release_tm_lock();
+     hythread_global_unlock();
 } // vm_gc_unlock_enum
 
 
@@ -2481,40 +2482,12 @@
     // patches done by JIT on IPF: it replaces the branch offset in a single bundle containing 
     // a branch long. Note that this function does not synchronize the I- or D-caches.
 
-    bool gc_enabled = false;
-    if ((p_TLS_vmthread != NULL) && !tmn_is_suspend_enabled()) {
-        tmn_suspend_enable();
-        gc_enabled = true;
-    }
-    tm_acquire_tm_lock();
-    if (gc_enabled) {
-        tmn_suspend_disable();
-    }
-
     // Run through list of active threads and suspend the other ones.
-    tm_iterator_t * iterator = tm_iterator_create();
-    VM_thread *thread = tm_iterator_next(iterator);
-    while (thread != NULL) {
-        if (thread != p_TLS_vmthread) {
-            SUSPEND_THREAD(thread);
-        }
-        thread = tm_iterator_next(iterator);
-    }
-
+     hythread_suspend_all(NULL, NULL);
     patch_code_with_threads_suspended(code_block, new_code, size);
 
-    // Resume each of the other threads.
-    tm_iterator_reset(iterator);
-    thread = tm_iterator_next(iterator);
-    while (thread != NULL) {
-        if (thread != p_TLS_vmthread) {
-            RESUME_THREAD(thread);
-        }
-        thread = tm_iterator_next(iterator);
-    }
-    tm_iterator_release(iterator);
+     hythread_resume_all(NULL);
 
-    tm_release_tm_lock();
 } //vm_patch_code_block
 
 
@@ -2663,5 +2636,7 @@
 } //vm_managed_calling_convention
 
 unsigned thread_get_suspend_request_offset() {
-    return APR_OFFSETOF(VM_thread, suspend_request);
+    //FIXME: 
+    //return APR_OFFSETOF(VM_thread, suspend_request);
+    return 0;
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Wed Aug 23 09:48:41 2006
@@ -316,7 +316,7 @@
 //
 ManagedObject *struct_Class_to_java_lang_Class(Class *clss)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     assert(clss);
     ManagedObject** hjlc = clss->class_handle;
     assert(hjlc);
@@ -369,7 +369,7 @@
 */
 jclass struct_Class_to_jclass(Class *c)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     tmn_suspend_disable(); // ------------------------vvv
     ObjectHandle h = oh_allocate_local_handle();
     h->object = struct_Class_to_java_lang_Class(c);
@@ -400,7 +400,7 @@
 // Given a class instance, find its corresponding struct Class.
 Class *java_lang_Class_to_struct_Class(ManagedObject *jlc)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     assert(jlc != NULL);
     assert(jlc->vt());
     assert(jlc->vt()->clss == VM_Global_State::loader_env->JavaLangClass_Class);
@@ -432,7 +432,7 @@
 void class_report_failure(Class* target, uint16 cp_index, jthrowable exn)
 {
     assert(cp_index > 0 && cp_index < target->cp_size);
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     if (exn_raised()) {
         TRACE2("classloader.error", "runtime exception in classloading");
         return;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp Wed Aug 23 09:48:41 2006
@@ -30,7 +30,6 @@
 #include "Class.h"
 #include "vm_strings.h"
 #include "open/vm_util.h"
-#include "open/thread.h"
 #include "bytereader.h"
 #include "compile.h"
 #include "jit_intf_cpp.h"
@@ -2175,7 +2174,7 @@
                                                const String* classname,
                                                ClassLoader* cl)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     // if no class loader passed, re-route to bootstrap
     if(!cl) cl = env->bootstrap_class_loader;
     Class* clss = cl->LoadVerifyAndPrepareClass(env, classname);
@@ -2185,7 +2184,7 @@
 
 Class *class_load_verify_prepare_from_jni(Global_Env *env, const String *classname)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Class *clss = env->bootstrap_class_loader->LoadVerifyAndPrepareClass(env, classname);
     return clss;
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp Wed Aug 23 09:48:41 2006
@@ -22,11 +22,12 @@
 #include "cxxlog.h"
 
 #include "environment.h"
+#include "Package.h"
 #include "String_Pool.h"
 #include "Class.h"
 #include "nogc.h"
 #include "GlobalClassLoaderIterator.h"
-#include "open/thread.h"
+
 #include "verifier.h"
 #include "native_overrides.h"
 
@@ -151,6 +152,7 @@
     tmn_suspend_disable();
     GlobalClassLoaderIterator ClIterator;
     ClassLoader *cl = ClIterator.first();
+    
     while(cl) {
         ClassLoader* cltmp = cl;
         cl = ClIterator.next();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp Wed Aug 23 09:48:41 2006
@@ -22,22 +22,21 @@
 #include "cxxlog.h"
 
 #include "Class.h"
-#include "open/thread.h"
-#include "mon_enter_exit.h"
+#include "open/jthread.h"
 #include "exceptions.h"
 #include "thread_manager.h"
 #include "Verifier_stub.h"
 #include "vm_strings.h"
 #include "classloader.h"
 #include "ini.h"
-
+#include "vm_threads.h"
 
 // Initializes a class.
 
 static void class_initialize1(Class *clss)
 {
     assert(!exn_raised());
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
 
     // the following code implements the 11-step class initialization program
     // described in page 226, section 12.4.2 of Java Language Spec, 1996
@@ -47,38 +46,21 @@
 
     // ---  step 1   ----------------------------------------------------------
 
-    assert(!tmn_is_suspend_enabled());
-    vm_monitor_enter_slow(struct_Class_to_java_lang_Class(clss));
-
-#ifdef _DEBUG
-    if (clss->p_initializing_thread){
-        tmn_suspend_enable();
-        tm_iterator_t * iterator = tm_iterator_create();
-        tmn_suspend_disable();
-        volatile VM_thread *p_scan = tm_iterator_next(iterator);
-        while (p_scan) {
-            if (p_scan == (VM_thread *)clss->p_initializing_thread) break;
-            p_scan = tm_iterator_next(iterator);
-        }
-        tm_iterator_release(iterator);
-        assert(p_scan);     // make sure p_initializer_thread is legit
-    }
-#endif  
+    assert(!hythread_is_suspend_enabled());
+    jobject jlc = struct_Class_to_java_lang_Class_Handle(clss);
+    jthread_monitor_enter(jlc);
 
     // ---  step 2   ----------------------------------------------------------
     TRACE2("class.init", "initializing class " << clss->name->bytes << " STEP 2" ); 
 
-    jobject jlc = struct_Class_to_java_lang_Class_Handle(clss);
     while(((VM_thread *)(clss->p_initializing_thread) != p_TLS_vmthread) &&
         (clss->state == ST_Initializing) ) {
         // thread_object_wait had been expecting the only unsafe reference
         // to be its parameter, so enable_gc() should be safe here -salikh
-        tmn_suspend_enable();
-        thread_object_wait(jlc, 0);
-        tmn_suspend_disable();
+         jthread_monitor_wait(jlc);
         jthrowable exc = exn_get();
         if (exc) {
-            vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+             jthread_monitor_exit(jlc);
             return;
         }
     }
@@ -86,26 +68,27 @@
     // ---  step 3   ----------------------------------------------------------
 
     if ( (VM_thread *)(clss->p_initializing_thread) == p_TLS_vmthread) {
-        vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+        jthread_monitor_exit(jlc);
         return;
     }
 
     // ---  step 4   ----------------------------------------------------------
 
     if (clss->state == ST_Initialized) {
-        vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+        jthread_monitor_exit(jlc);
         return;
     }
 
     // ---  step 5   ----------------------------------------------------------
 
     if (clss->state == ST_Error) {
-        vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+        jthread_monitor_exit(jlc);
         tmn_suspend_enable();
         jthrowable exn = exn_create("java/lang/NoClassDefFoundError",
             clss->name->bytes);
         tmn_suspend_disable();
         exn_raise_only(exn);
+       
         return;
     }
 
@@ -116,7 +99,7 @@
     clss->state = ST_Initializing;
     assert(clss->p_initializing_thread == 0);
     clss->p_initializing_thread = (void *)p_TLS_vmthread;
-    vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+    jthread_monitor_exit(jlc);
 
     // ---  step 7 ------------------------------------------------------------
 
@@ -124,15 +107,16 @@
         class_initialize_ex(clss->super_class);
 
         if (clss->super_class->state == ST_Error) { 
-            vm_monitor_enter_slow(struct_Class_to_java_lang_Class(clss));
+            jthread_monitor_enter(jlc);
             tmn_suspend_enable();
             REPORT_FAILED_CLASS_CLASS_EXN(clss->class_loader, clss,
                 class_get_error_cause(clss->super_class));
             tmn_suspend_disable();
             clss->p_initializing_thread = 0;
-            assert(!tmn_is_suspend_enabled());
-            thread_object_notify_all(struct_Class_to_java_lang_Class_Handle(clss));
-            vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+            clss->state = ST_Error;
+            assert(!hythread_is_suspend_enabled());
+            jthread_monitor_notify_all(jlc);
+            jthread_monitor_exit(jlc);
             return;
         }
     }
@@ -183,22 +167,20 @@
 
     Method *meth = clss->static_initializer;
     if (meth == NULL) {
-        vm_monitor_enter_slow(struct_Class_to_java_lang_Class(clss));
+        jthread_monitor_enter(jlc);
         clss->state = ST_Initialized;
         TRACE2("classloader", "class " << clss->name->bytes << " initialized");
         clss->p_initializing_thread = 0;
-        assert(!tmn_is_suspend_enabled());
-        thread_object_notify_all (struct_Class_to_java_lang_Class_Handle(clss));
-        vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+        assert(!hythread_is_suspend_enabled());
+        jthread_monitor_notify_all(jlc);
+        jthread_monitor_exit(jlc);
         return;
     }
 
     TRACE2("class.init", "initializing class " << clss->name->bytes << " STEP 8" ); 
     jthrowable p_error_object;
-    int tmn_suspend_disable_count();   
-    assert(tmn_suspend_disable_count()==1);
 
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     vm_execute_java_method_array((jmethodID) meth, 0, 0);
     p_error_object = exn_get();
 
@@ -206,30 +188,30 @@
     TRACE2("class.init", "initializing class " << clss->name->bytes << " STEP 9" ); 
 
     if(!p_error_object) {
-        vm_monitor_enter_slow(struct_Class_to_java_lang_Class(clss));
+        jthread_monitor_enter(jlc);
         clss->state = ST_Initialized;
         TRACE2("classloader", "class " << clss->name->bytes << " initialized");
         clss->p_initializing_thread = 0;
         assert(clss->p_error == 0);
-        assert(!tmn_is_suspend_enabled());
-        thread_object_notify_all (struct_Class_to_java_lang_Class_Handle(clss));
-        vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+        assert(!hythread_is_suspend_enabled());
+        jthread_monitor_notify_all(jlc);
+        jthread_monitor_exit(jlc);
         return;
     }
 
     // ---  step 10  ----------------------------------------------------------
 
     if(p_error_object) {
-        assert(!tmn_is_suspend_enabled());
+       assert(!hythread_is_suspend_enabled());
         clear_current_thread_exception();
         Class *p_error_class = p_error_object->object->vt()->clss;
         Class *jle = VM_Global_State::loader_env->java_lang_Error_Class;
         while(p_error_class && p_error_class != jle) {
             p_error_class = p_error_class->super_class;
         }
-        assert(!tmn_is_suspend_enabled());
+        assert(!hythread_is_suspend_enabled());
         if((!p_error_class) || (p_error_class != jle) ) {
-#ifdef _DEBUG
+#ifdef _DEBUG_REMOVED
             Class* eiie = VM_Global_State::loader_env->java_lang_ExceptionInInitializerError_Class;
             assert(eiie);
 #endif
@@ -245,13 +227,13 @@
         tmn_suspend_disable();
 
         // ---  step 11  ----------------------------------------------------------
-        assert(!tmn_is_suspend_enabled());
-        vm_monitor_enter_slow(struct_Class_to_java_lang_Class(clss));
+        assert(!hythread_is_suspend_enabled());
+        jthread_monitor_enter(jlc);
         clss->state = ST_Error;
         clss->p_initializing_thread = 0;
-        assert(!tmn_is_suspend_enabled());
-        thread_object_notify_all(struct_Class_to_java_lang_Class_Handle(clss));
-        vm_monitor_exit(struct_Class_to_java_lang_Class(clss));
+        assert(!hythread_is_suspend_enabled());
+        jthread_monitor_notify_all(jlc);
+        jthread_monitor_exit(jlc);
         exn_raise_only(p_error_object);
     }
     // end of 11 step class initialization program
@@ -265,7 +247,7 @@
 #endif
 void class_initialize_from_jni(Class *clss)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     // check verifier constraints
     if(!class_verify_constraints(VM_Global_State::loader_env, clss)) {
@@ -297,7 +279,7 @@
 
 void class_initialize_ex(Class *clss)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
 
     // check verifier constraints
     tmn_suspend_enable();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp Wed Aug 23 09:48:41 2006
@@ -36,7 +36,6 @@
 #include "compile.h"
 #include "interpreter_exports.h"
 #include "interpreter.h"
-#include "open/thread.h"
 #include "lil.h"
 #include "lil_code_generator.h"
 
@@ -1393,7 +1392,7 @@
         if(!env->InBootstrap())
         {
             autoUnlocker.ForceUnlock();
-            assert(tmn_is_suspend_enabled());
+            assert(hythread_is_suspend_enabled());
             if (init_fields) {
                 jvmti_send_class_prepare_event(clss);
             }
@@ -1607,7 +1606,7 @@
     if (!assign_values_to_class_static_final_fields(clss)) 
     { 
         //OOME happened
-        assert(tmn_is_suspend_enabled());
+        assert(hythread_is_suspend_enabled());
         return false;
     }
 
@@ -1640,7 +1639,7 @@
     if(!env->InBootstrap())
     {
         autoUnlocker.ForceUnlock();
-        assert(tmn_is_suspend_enabled());
+        assert(hythread_is_suspend_enabled());
         jvmti_send_class_prepare_event(clss);
     }
     TRACE2("classloader.prepare", "END class prepare, class name = " << clss->name->bytes);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp Wed Aug 23 09:48:41 2006
@@ -104,7 +104,7 @@
 
 #include "open/bytecodes.h"
 #include "open/vm_util.h"
-#include "open/thread.h"
+
 
 #define CLASS_REPORT_FAILURE(target, cp_index, exnclass, exnmsg)    \
 {                                                               \
@@ -132,7 +132,7 @@
                              Class *clss,
                              unsigned cp_index)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Const_Pool *cp = clss->const_pool;
 
     clss->m_lock->_lock();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp Wed Aug 23 09:48:41 2006
@@ -46,7 +46,7 @@
     // Spin until lock is m_free.
     while (apr_atomic_casptr(
         (volatile void **)&string_pool_lock, (void *)1, (void *)0) != 0) {
-        Sleep (0);
+        hythread_yield();
     }
 }
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Wed Aug 23 09:48:41 2006
@@ -38,7 +38,7 @@
 #include "jvmti_internal.h"
 #include "ini.h"
 #include "open/gc.h"
-#include "open/thread.h"
+#include "open/hythread_ext.h"
 #include "open/vm_util.h"
 #include "suspend_checker.h"
 #include "verifier.h"
@@ -157,18 +157,6 @@
         delete m_package_table;
 }
 
-bool ClassLoader::LoadingClass::CreateWaitingEvent(const String* className) 
-{
-    if(m_loadWaitEvent == 0)
-        m_loadWaitEvent = vm_create_event(NULL, TRUE, FALSE, NULL);
-    if(m_loadWaitEvent == 0) {
-        DIE2("classloader", "Event creation failed for class " << className->bytes
-            << ", which is loaded concurrently");
-        return false;
-    }
-    return true;
-}
-
 void ClassLoader::LoadingClass::EnqueueInitiator(VM_thread* new_definer, ClassLoader* cl, const String* clsname) 
 {
     if(!IsInitiator(new_definer)) {
@@ -392,7 +380,7 @@
 
 Class* ClassLoader::LoadVerifyAndPrepareClass(Global_Env* env, const String* name)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     Class* clss = LoadClass(env, name);
     if(!clss) return NULL;
@@ -804,11 +792,6 @@
                 // avoid preliminary removal of LoadingClass
                 loading->AddWaitingThread(cur_thread, this, className);
                 // lazy wait event creation
-                if(!loading->CreateWaitingEvent(className)) {
-                    // should never get here
-                    DIE("Event creation failure was not reported: should never get here!");
-                    return NULL;
-                }
                 aulock.ForceUnlock();
                 // only wait for class loading if we are in bootstrap class loader
                 loading->WaitLoading();
@@ -894,12 +877,6 @@
                 // defining thread should not get here
                 assert(!loading->IsDefiner(cur_thread));
                 assert(loading->AlreadyWaiting(cur_thread));
-                // lazy wait event creation
-                if(!loading->CreateWaitingEvent(className)) {
-                    // should never get here
-                    DIE("Event creation failure was not reported: should never get here!");
-                    return NULL;
-                }
                 m_lock._unlock();
                 TRACE2("classloader.collisions", this << " " << cur_thread << " WAITING " << className->bytes);
                 // wait class loading
@@ -1663,7 +1640,7 @@
     // wgs's comment here:
     //  * (Ljava/lang/String;Z) is not abstract in current JDK version
     //  * Generally (Ljava/lang/String;) are overloaded
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     assert(!exn_raised());
     tmn_suspend_disable();
 
@@ -1932,7 +1909,7 @@
 VMEXPORT GenericFunctionPointer
 classloader_find_native(const Method_Handle method)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     assert( !exn_raised() );
 
     // get class and class loader of a given method

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/method.cpp Wed Aug 23 09:48:41 2006
@@ -21,7 +21,7 @@
 #define LOG_DOMAIN "vm.core"
 #include "cxxlog.h"
 
-#include "open/thread.h"
+
 #include "Class.h"
 #include "classloader.h"
 #include "environment.h"
@@ -118,7 +118,7 @@
 
 Class_Handle method_get_return_type_class(Method_Handle m)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Method *method = (Method *)m;
     Global_Env *env = VM_Global_State::loader_env;
     Java_Type UNUSED t = method->get_return_java_type();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp Wed Aug 23 09:48:41 2006
@@ -29,7 +29,7 @@
 #include "m2n.h"
 #include "object_handles.h"
 #include "vm_strings.h"
-#include "open/thread.h"
+
 
 // internal declaration of functions
 void __stdcall set_current_thread_exception_internal(ManagedObject * exn);
@@ -48,7 +48,7 @@
 
 void exn_throw_only(jthrowable exc)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     // Temporary fix of incorrect using of throw_by name in the interpreter 
     if (interpreter_enabled()) {
         exn_raise_only(exc);
@@ -140,7 +140,7 @@
 static jthrowable create_exception(const char *exception_name)
 {
 
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Class *exc_clss = get_class(exception_name);
     if (exc_clss == NULL) {
         assert(exn_raised());
@@ -165,7 +165,7 @@
 static jthrowable create_exception(const char *exception_name,
     jthrowable cause)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Class *exc_clss = get_class(exception_name);
     if (exc_clss == NULL) {
         assert(exn_raised());
@@ -202,7 +202,7 @@
     jthrowable cause, const char *message)
 {
     // XXX salikh: change to unconditional thread_disable_suspend()
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     Class *exc_clss = get_class(exception_name);
     if (exc_clss == NULL) {
@@ -293,7 +293,7 @@
 
 void exn_throw_by_name(const char *exception_name)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     jthrowable exc = create_exception(exception_name);
     tmn_suspend_disable();
     exn_throw_only(exc);
@@ -303,7 +303,7 @@
 
 void exn_throw_by_name(const char *exception_name, const char *message)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     jthrowable exc = create_exception(exception_name, NULL, message);
     tmn_suspend_disable();
     exn_throw_only(exc);
@@ -484,7 +484,7 @@
 
 void __stdcall set_current_thread_exception_internal(ManagedObject * exn)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     p_TLS_vmthread->p_exception_object = (volatile ManagedObject *) exn;
     p_TLS_vmthread->ti_exception_callback_pending = true;
 }
@@ -508,7 +508,7 @@
     // function should be only called from suspend disabled mode
     // it changes enumeratable reference to zero which is not
     // gc safe operation.
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     p_TLS_vmthread->p_exception_object = NULL;
 
     if (p_TLS_vmthread->restore_guard_page) {
@@ -563,7 +563,7 @@
 // prints stackTrace via jni
 inline void exn_jni_print_stack_trace(FILE * f, jthrowable exc)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     // finds java environment
     JNIEnv_Internal *jenv = jni_native_intf;
 
@@ -698,7 +698,7 @@
         }
     }
 
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 }
 
 inline void exn_native_print_stack_trace(FILE * f, ManagedObject * exn)
@@ -738,7 +738,7 @@
 // prints stack trace using 3 ways: via java, via jni, and native
 void exn_print_stack_trace(FILE * f, ManagedObject * exn)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     // saves curent thread exception and clear to allow java to work
     Java_java_lang_Throwable *cte = get_current_thread_exception();
     jthrowable j = oh_allocate_local_handle();
@@ -798,7 +798,7 @@
 void print_uncaught_exception_message(FILE * f, char *context_message,
     ManagedObject * exn)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     fprintf(f, "** During %s uncaught exception: %s\n", context_message,
         exn->vt()->clss->name->bytes);
     exn_print_stack_trace(f, exn);
@@ -811,9 +811,9 @@
 static ManagedObject *create_lazy_exception(StackIterator * UNREF throw_si,
     Class_Handle exn_class, Method_Handle exn_constr, uint8 * exn_constr_args)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     volatile ManagedObject *exn_obj = 0;
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     exn_obj =
         class_alloc_new_object_and_run_constructor((Class *) exn_class,
         (Method *) exn_constr, exn_constr_args);
@@ -839,7 +839,7 @@
     ManagedObject ** exn_obj, Class_Handle exn_class,
     Method_Handle exn_constr, uint8 * exn_constr_args)
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     ASSERT_NO_INTERPRETER assert(*exn_obj || exn_class);
 
     // Save the throw context
@@ -940,7 +940,8 @@
         // No appropriate handler found, undo synchronization
         if (method->is_synchronized()) {
             if (method->is_static()) {
-                assert(!tmn_is_suspend_enabled());
+                assert(!hythread_is_suspend_enabled());
+                TRACE2("tm.locks", ("unlock staic sync methods... %x",  exn_obj));
                 vm_monitor_exit(struct_Class_to_java_lang_Class(method->
                         get_class()));
             }
@@ -948,6 +949,7 @@
                 void **p_this =
                     (void **) jit->get_address_of_this(method,
                     si_get_jit_context(si));
+                TRACE2("tm.locks", ("unlock sync methods...%x" , *p_this));
                 vm_monitor_exit((ManagedObject *) * p_this);
             }
         }
@@ -969,7 +971,7 @@
             create_lazy_exception(throw_si, exn_class, exn_constr,
             exn_constr_args);
     }
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
 
     CodeChunkInfo *catch_cci = si_get_code_chunk_info(si);
     Method *catch_method = NULL;
@@ -1025,7 +1027,7 @@
  * !!!! RELEASE BUILD WILL BE BROKEN          !!!
  * !!!! NO TRACE2, INFO, WARN, ECHO, ASSERT, ...
  */
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     //TRACE2("exn","exn_athrow");
     ASSERT_NO_INTERPRETER if ((exn_obj == NULL) && (exn_class == NULL)) {
         Global_Env *env = VM_Global_State::loader_env;
@@ -1240,7 +1242,7 @@
 // Return the type of negative array size exception
 Class_Handle exn_get_negative_array_size_exception_type()
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Class *exn_clss;
 
 
@@ -1277,6 +1279,45 @@
 }   //exn_get_rth_throw_negative_array_size
 
 
+// Return the type of illegal state exception
+Class_Handle exn_get_illegal_state_exception_type()
+{
+    assert(hythread_is_suspend_enabled());
+    Class *exn_clss;
+
+
+    Global_Env *env = VM_Global_State::loader_env;
+    String *exc_str =
+        env->string_pool.lookup("java/lang/IllegalMonitorStateException");
+    exn_clss =
+        env->bootstrap_class_loader->LoadVerifyAndPrepareClass(env, exc_str);
+    assert(exn_clss);
+
+    return exn_clss;
+}
+
+// rth_throw_negative_array_size throws a negative array size exception (lazily)
+NativeCodePtr exn_get_rth_throw_illegal_state_exception()
+{
+    static NativeCodePtr addr = NULL;
+    if (addr) {
+        return addr;
+    }
+
+    LilCodeStub *cs = lil_parse_code_stub("entry 0:managed::void;"
+        "std_places 1;" "sp0=%0i;" "tailcall %1i;",
+        exn_get_illegal_state_exception_type(),
+        lil_npc_to_fp(exn_get_rth_throw_lazy_trampoline()));
+    assert(lil_is_valid(cs));
+    addr =
+        LilCodeGenerator::get_platform()->compile(cs,
+        "rth_throw_illegal_state_exception", dump_stubs);
+    lil_free_code_stub(cs);
+
+    return addr;
+}   //exn_get_rth_throw_illegal_state_exception
+
+
 // rth_throw_array_store throws an array store exception (lazily)
 NativeCodePtr exn_get_rth_throw_array_store()
 {
@@ -1326,7 +1367,7 @@
 // Return the type of class cast exception
 Class_Handle exn_get_class_cast_exception_type()
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Class *exn_clss;
 
     Global_Env *env = VM_Global_State::loader_env;
@@ -1362,7 +1403,7 @@
 // Return the type of incompatible class change exception
 Class_Handle exn_get_incompatible_class_change_exception_type()
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     Class *exn_clss;
 
     Global_Env *env = VM_Global_State::loader_env;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp Wed Aug 23 09:48:41 2006
@@ -26,6 +26,7 @@
 #ifndef USE_GC_STATIC
 
 #include <apr_dso.h>
+#include <apr_errno.h>
 #include "dll_gc.h"
 #include "open/gc.h"
 #include "open/vm_util.h"
@@ -284,15 +285,21 @@
     
     apr_dso_handle_t *handle;
     bool result = false;
-    if (apr_dso_load(&handle, dll_filename, pool) == APR_SUCCESS)
+    apr_status_t stat;
+    if ((stat = apr_dso_load(&handle, dll_filename, pool)) == APR_SUCCESS)
     {
         apr_dso_handle_sym_t tmp;
         if (apr_dso_sym(&tmp, handle, "gc_init") == APR_SUCCESS) {
             result = true;
         }
         apr_dso_unload(handle);
+    } else {
+        char buf[1024];
+        apr_dso_error(handle, buf, 1024);
+        WARN("Loading error" << buf);
+        //apr_strerror(stat, buf, 1024);
+        //printf("error %s, is %d, expected %d\n", buf, stat, APR_SUCCESS);
     }
-
     return result;
 } //vm_is_a_gc_dll
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp Wed Aug 23 09:48:41 2006
@@ -227,9 +227,6 @@
 void vm_enumerate_root_set_single_thread_not_on_stack(VM_thread *thread)
 {
     assert(thread);
-    if (thread->p_java_lang_thread != NULL) {
-        vm_enumerate_root_reference((void **)&(thread->p_java_lang_thread), FALSE);
-    }
     if (thread->p_exception_object != NULL) {
         vm_enumerate_root_reference((void **)&(thread->p_exception_object), FALSE);
     }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp Wed Aug 23 09:48:41 2006
@@ -55,12 +55,12 @@
 vm_enumerate_the_current_thread()
 {
     // Process roots for the current thread
-    assert(p_TLS_vmthread->gc_status == zero);
-    p_TLS_vmthread->gc_status = gc_at_safepoint;
+    //assert(p_TLS_vmthread->gc_status == zero);
+    //p_TLS_vmthread->gc_status = gc_at_safepoint;
     vm_enumerate_thread(p_TLS_vmthread);
 
     // Enumeration for this thread is complete.
-    p_TLS_vmthread->gc_status = gc_enumeration_done;
+    //p_TLS_vmthread->gc_status = gc_enumeration_done;
 
 } // vm_enumerate_the_current_thread
 
@@ -84,28 +84,33 @@
 
     INFO2("threads","Start thread suspension ");
     vm_time_start_hook(&_start_time);   //thread suspension time measurement        
-    suspend_all_threads_except_current();
+
+      hythread_iterator_t  iterator;
+    hythread_suspend_all(&iterator, NULL);
+
     thread_suspend_time = vm_time_end_hook(&_start_time, &_end_time);
-    INFO2("threads","Thread suspension time: "<< thread_suspend_time <<" mksec");
+    INFO2("tm.suspend","Thread suspension time: "<< thread_suspend_time <<" mksec");
 
     class_unloading_clear_mark_bits();
 
     // Run through list of active threads and enumerate each one of them.
-    tmn_suspend_enable(); // to make tm_iterator_create()happy: it uses assert(tmn_is_suspend_enabled());
-    tm_iterator_t * iterator = tm_iterator_create();
-    tmn_suspend_disable();
-    VM_thread *thread = tm_iterator_next(iterator);
-    while(thread) {
-        if (thread != p_TLS_vmthread) {
+    hythread_t tm_thread = hythread_iterator_next(&iterator);
+    
+    //VM_thread *thread = get_vm_thread (hythread_iterator_next(&iterator));
+    while(tm_thread) {
+        VM_thread *thread = get_vm_thread(tm_thread);
+        if (thread && thread != p_TLS_vmthread) {
             vm_enumerate_thread(thread);
             // Enumeration for this thread is complete.
-            thread->gc_status = gc_enumeration_done;
+            //thread->gc_status = gc_enumeration_done;
+            //assert(thread->gc_status==gc_enumeration_done);
+            //thread->gc_status=gc_enumeration_done;
         }
-        thread = tm_iterator_next(iterator);
+        tm_thread = hythread_iterator_next(&iterator);
     }
-    tm_iterator_release(iterator);
 
     vm_enumerate_the_current_thread();
+
     // finally, process all the global refs
     vm_enumerate_root_set_global_refs();
 
@@ -121,7 +126,7 @@
 void 
 vm_enumerate_root_set_all_threads()
 {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     // it is convenient to have gc_enabled_status == disabled
     // during the enumeration -salikh
 
@@ -135,14 +140,7 @@
 
     stop_the_world_root_set_enumeration();
     
-    // ASSERT that enumeration is done for all threads...
-    int n_threads = thread_gc_number_of_threads();
-    for(int i = 0; i < n_threads; i++) {
-        VM_thread * UNUSED thread = (VM_thread *) thread_gc_enumerate_one();
-        assert (thread->gc_status == gc_enumeration_done);
-    }
-
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     // vm_gc_unlock_enum expects suspend enabled, enable it here
 
 } //vm_enumerate_root_set_all_threads
@@ -161,7 +159,7 @@
     class_unloading_start();
 
     // Run through list of active threads and resume each one of them.
-    resume_all_threads();
+    hythread_resume_all( NULL);
 
     // Make sure register stack is up-to-date with the potentially updated backing store
     si_reload_registers();
@@ -174,10 +172,10 @@
     // which itself operates either with 
     // gc_enabled_status == disabled, e.g. from managed code,
     // but at the GC-safe point (because the collection was done)
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
 
     tmn_suspend_enable();
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     // Finalizers and reference enqueuing is performed from vm_hint_finalize(),
     // GC guarantees to call this function after the completion of collection,
@@ -212,8 +210,7 @@
     }
     StackIterator* si;
     TRACE2("enumeration", "Enumerating thread " << thread << 
-    (thread == p_TLS_vmthread ? ", this thread" : ", suspended in native code")
-                << ", GCEnabled=" << (thread -> suspend_enabled_status));
+    (thread == p_TLS_vmthread ? ", this thread" : ", suspended in native code"));
      si = si_create_from_native(thread);
     vm_enumerate_root_set_single_thread_on_stack(si);    
     // Enumerate references associated with a thread that are not stored on the thread's stack.

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalize.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalize.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalize.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalize.cpp Wed Aug 23 09:48:41 2006
@@ -36,7 +36,7 @@
 #include "jit_runtime_support.h"
 #include "vm_synch.h"
 #include "finalize.h"
-#include "open/thread.h"
+
 
 #define LOG_DOMAIN "vm.object_queue"
 #include "classloader.h"
@@ -75,7 +75,7 @@
 // weak/soft/phantom references.
 //
 
-VmEventHandle begin_run_finalizer;
+hylatch_t begin_run_finalizer;
 
 class Object_Queue
 {
@@ -149,6 +149,7 @@
  * Allocates array to save objects. Should be called from synchronized block.
  * Now it's called from add_object only.
  */
+ 
 void Object_Queue::reallocate(unsigned new_capacity)
 {
     ManagedObject **new_table =
@@ -261,7 +262,7 @@
 // workaround method to ignore classes java.nio.charset.CharsetEncoder
 // java.io.FileDescriptor & java.io.FileOutputStream during finalization on exit
 bool Objects_To_Finalize::is_class_ignored(Class* test) {
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     
     if (!classes_cached) {
     
@@ -299,7 +300,7 @@
 
 void Objects_To_Finalize::run_finalizers()
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     Class* finalizer_thread = VM_Global_State::loader_env->finalizer_thread;
 
@@ -468,13 +469,13 @@
 void vm_run_pending_finalizers()
 {
     NativeObjectHandles nhs;
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     objects_to_finalize.run_finalizers();
 } //vm_run_pending_finalizers
 
 int vm_do_finalization(int quantity)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     return objects_to_finalize.do_finalization(quantity);
 } //vm_run_pending_finalizers
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp Wed Aug 23 09:48:41 2006
@@ -46,7 +46,9 @@
 #include "nogc.h"
 
 #include "object_generic.h"
-#include "open/thread.h"
+
+#include "open/hythread_ext.h"
+#include "open/jthread.h"
 #include "component_manager.h"
 #include "lock_manager.h"
 #include "root_set_enum_internal.h"
@@ -207,10 +209,8 @@
 {
     // Send VM_Death event and switch phase to VM_Death
     jvmti_send_vm_death_event();
-void terminate_all_threads();
     if (vm_get_boolean_property_value_with_default("vm.cleanupOnExit"))
-        terminate_all_threads();
-
+        jthread_cancel_all();
     /* FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME *
      * gregory - JVMTI shutdown should be part of DestroyVM after current VM shutdown      *
      * problems are fixed                                                                  *

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Wed Aug 23 09:48:41 2006
@@ -39,8 +39,7 @@
     p_jit_a_method_lock = new Lock_Manager();
     p_vtable_patch_lock = new Lock_Manager();
     p_meth_addr_table_lock = new Lock_Manager();
-    p_thread_lock = new Lock_Manager();
-    p_tm_lock = new Lock_Manager();
+    p_handle_lock = new Lock_Manager();
 
     // 20040224 Support for recording which methods (actually, CodeChunkInfo's) call which other methods.
     p_method_call_lock = new Lock_Manager();
@@ -51,8 +50,7 @@
     delete p_jit_a_method_lock;
     delete p_vtable_patch_lock;
     delete p_meth_addr_table_lock;
-    delete p_thread_lock;
-    delete p_tm_lock;
+    delete p_handle_lock;
 
     delete p_method_call_lock;
 } //vm_uninitialize_critical_sections
@@ -127,7 +125,7 @@
 
 static void bootstrap_initial_java_classes(Global_Env *env)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     TRACE2("init", "bootstrapping initial java classes");
     
     /*
@@ -203,21 +201,19 @@
     return true;
 } //initialize_system_class_loader
 
+static bool init_thread_object(JNIEnv *);
 
 bool vm_init(Global_Env *env)
 {
     if(vm_is_initialized)
         return false;
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     vm_is_initialized = true;
     TRACE2("init","Initializing VM");
 
     vm_monitor_init();
 
-    vm_thread_init(env);
-    active_thread_count = 1;
-
     env->bootstrap_class_loader = new BootstrapClassLoader(env); // !!! use proper MM
     env->bootstrap_class_loader->Initialize();
 
@@ -326,7 +322,7 @@
     Method *m = class_lookup_method(env->java_lang_Throwable_Class, 
         env->Init_String, env->VoidVoidDescriptor_String);
     assert(m);
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     m->set_side_effects(MSE_False);
 
     m = class_lookup_method(env->java_lang_Throwable_Class,
@@ -354,13 +350,12 @@
     env->ReadyForExceptions();
 
     TRACE2("init", "initializing thread group");
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
-    bool init_threadgroup();
-    if (! init_threadgroup())
+    JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
+    if (! init_thread_object(jni_env))
         return false;
 
-    JNIEnv *jni_env = (JNIEnv *)jni_native_intf;
 
     TRACE2("init", "Invoking the java.lang.Class constructor");
     Class *jlc = env->JavaLangClass_Class;
@@ -442,3 +437,42 @@
 
     return true;
 } //vm_init
+
+static bool init_thread_object(JNIEnv *jenv)
+{
+    Global_Env *env = VM_Global_State::loader_env;
+
+    assert(hythread_is_suspend_enabled());
+
+    // Load, prepare and initialize the "Thread class"
+    String *ss = env->string_pool.lookup("java/lang/VMStart");
+    Class *thread_clss = env->bootstrap_class_loader->LoadVerifyAndPrepareClass(env, ss);
+    assert(thread_clss);
+    assert(hythread_is_suspend_enabled());
+    tmn_suspend_disable();
+    class_initialize(thread_clss);
+    assert(!hythread_is_suspend_enabled());
+
+    ObjectHandle jThreadClass = oh_allocate_local_handle();
+    jThreadClass->object = struct_Class_to_java_lang_Class(thread_clss);
+    tmn_suspend_enable();
+
+    jmethodID main_method = jenv->GetStaticMethodID(jThreadClass, "mainThreadInit", "()V");
+    if (ExceptionOccurred(jenv) || !main_method) {
+        WARN("*** Error: exception occured in main Thread constructor.");
+        ExceptionDescribe(jenv);
+        ExceptionClear(jenv);
+        return false;
+    }
+
+    jenv->CallStaticVoidMethod(jThreadClass, main_method);
+    
+    if (ExceptionOccurred(jenv)) {
+        WARN("*** Error: exception occured in main Thread constructor.");
+        ExceptionDescribe(jenv);
+        ExceptionClear(jenv);
+        return false;
+    }
+
+    return true;
+} //init_thread_object

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_main.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_main.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_main.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_main.cpp Wed Aug 23 09:48:41 2006
@@ -23,6 +23,7 @@
 
 #include "thread_generic.h"
 #include "open/vm_util.h"
+#include "open/hythread_ext.h"
 #include "properties.h"
 #include <apr_env.h>
 #include "vm_synch.h"
@@ -76,14 +77,19 @@
 
 bool parallel_jit = true;
 
+static bool begin_shutdown_hooks = false;
+
 static M2nFrame* p_m2n = NULL;
 
 typedef union {
     ObjectHandlesOld old;
     ObjectHandlesNew nw;
 } HandlesUnion;
+
 static HandlesUnion* p_handles = NULL;
 
+hythread_library_t hythread_lib;
+
 static void initialize_javahome(Global_Env* p_env)
 {
     PropertiesHandle ph = (PropertiesHandle)&p_env->properties;
@@ -198,7 +204,7 @@
 
 static int run_java_main(char *class_name, char **java_args, int java_args_num)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     JNIEnv* jenv = (JNIEnv*) jni_native_intf;
 
@@ -241,7 +247,7 @@
 
 static int run_java_init()
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     JNIEnv* jenv = (JNIEnv*) jni_native_intf;
 
@@ -262,7 +268,7 @@
 
 static int run_java_shutdown()
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     JNIEnv* jenv = (JNIEnv*) jni_native_intf;
 
@@ -293,9 +299,8 @@
 
 void create_vm(Global_Env *p_env, JavaVMInitArgs* vm_arguments) 
 {
-#ifdef PLATFORM_POSIX
-    init_linux_thread_system();
-#elif defined(PLATFORM_NT)
+    
+#if defined(PLATFORM_NT)
     OSVERSIONINFO osvi;
     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
     BOOL ok = GetVersionEx(&osvi);
@@ -312,24 +317,18 @@
         exit(1);
     }
 #endif
-
-
-    non_daemon_threads_dead_handle = vm_create_event( 
-            NULL,   // pointer to security attributes 
-            FALSE,  // flag for manual-reset event  -- auto reset mode 
-            FALSE,  // flag for initial state 
-            NULL    // pointer to event-object name 
-        ); 
-    assert(non_daemon_threads_dead_handle);
+    hythread_init(hythread_lib);
+    vm_thread_init(&env);
 
     VM_Global_State::loader_env = &env;
-
-    tmn_thread_attach();
+    hythread_attach(NULL);
+    // should be removed
+    vm_thread_attach();
     MARK_STACK_END
 
     p_env->TI = new DebugUtilsTI;
 
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
 
     vm_initialize_critical_sections();
     initialize_vm_cmd_state(p_env, vm_arguments); //PASS vm_arguments to p_env->vm_arguments and free vm_arguments 
@@ -392,7 +391,7 @@
     // Initialize memory allocation
     vm_init_mem_alloc();
     gc_init();
-    gc_thread_init(&p_TLS_vmthread->_gc_private_information);
+   // gc_thread_init(&p_TLS_vmthread->_gc_private_information);
 
     // Prepares to load natives
     bool UNREF status = natives_init();
@@ -456,10 +455,8 @@
         }
     }
 
-    assert(p_TLS_vmthread->app_status == thread_is_birthing);
-
     // create first m2n frame
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     tmn_suspend_disable();
     p_m2n = (M2nFrame*) p_env->mem_pool.alloc(sizeof(M2nFrame));
     p_handles = (HandlesUnion*) p_env->mem_pool.alloc(sizeof(HandlesUnion));
@@ -481,15 +478,6 @@
     // Send VM init event
     jvmti_send_vm_init_event(p_env);
 
-    // Signal the GC that the VM is now completely 
-    // initialized. Hence GC stop-the-world events
-    // can occur at any time, since the VM is now
-    // ready to enumerate live references when asked.
-    gc_vm_initialized();
-
-    assert(p_TLS_vmthread->app_status == thread_is_birthing);
-    // Now, we set it to "running" just before entering user code.
-    p_TLS_vmthread->app_status = thread_is_running;
 
     int result = run_java_init();
 
@@ -553,7 +541,6 @@
 
 void destroy_vm(Global_Env *p_env) 
 {
-    assert(p_TLS_vmthread->app_status == thread_is_running);
 
     run_java_shutdown();
 
@@ -593,13 +580,14 @@
 
 static inline
 void dump_all_java_stacks() {
-    tm_iterator_t * iterator = tm_iterator_create();
-    VM_thread *thread = tm_iterator_next(iterator);
+    hythread_iterator_t  iterator;
+    hythread_suspend_all(&iterator, NULL);
+    VM_thread *thread = get_vm_thread (hythread_iterator_next(&iterator));
     while(thread) {
         interpreter.stack_dump(thread);
-        thread = tm_iterator_next(iterator);
+        thread = get_vm_thread (hythread_iterator_next(&iterator));
     }
-    tm_iterator_release(iterator);
+    hythread_resume_all( NULL);
     INFO("****** END OF JAVA STACKS *****\n");
 }
 
@@ -618,7 +606,8 @@
     }
 }
 
-void interrupt_handler(int UNREF x) {
+void interrupt_handler(int UNREF x)
+{
     if (VM_Global_State::loader_env->shutting_down != 0) {
         // too late for quit handler
         // required infrastructure can be missing.
@@ -626,10 +615,10 @@
         return;
     }
 
-    static bool begin_shutdown_hooks = false;
     if(!begin_shutdown_hooks){
         begin_shutdown_hooks = true;
-        vm_set_event(non_daemon_threads_dead_handle);
+        //FIXME: integration should do int another way.
+        //vm_set_event(non_daemon_threads_dead_handle);
     }else
         exit(1); //vm_exit(1);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp Wed Aug 23 09:48:41 2006
@@ -29,9 +29,11 @@
 #include "jit_intf_cpp.h"
 #include "em_intf.h"
 #include "heap.h"
-#include "open/thread.h"
+ 
+
 #include "vm_stats.h"
 #include "vm_strings.h"
+
 #include "compile.h"
 #include "jit_runtime_support.h"
 #include "lil_code_generator.h"
@@ -421,7 +423,7 @@
     cs = lil_parse_onto_end(cs,
                             "out platform::void;"
                             "call %0i;",
-                            tmn_suspend_enable);
+                            hythread_suspend_enable);
     assert(cs);
 
     //***** Part 5: Set up arguments
@@ -502,7 +504,7 @@
     cs = lil_parse_onto_end(cs,
                             "out platform::void;"
                             "call %0i;",
-                            tmn_suspend_disable);
+                            hythread_suspend_disable);
     assert(cs);
 
     //***** Part 9: Synchronise
@@ -733,7 +735,7 @@
 // Assumes that GC is disabled, but a GC-safe point
 static JIT_Result compile_do_compilation(Method* method, JIT_Flags flags)
 {
-    assert(tmn_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());
     tmn_suspend_disable();
     class_initialize_ex(method->get_class());
     tmn_suspend_enable();
@@ -777,7 +779,7 @@
 static ManagedObject* compile_make_exception(const char* name, Method* method)
 { // FIXME: prototype should be changed to getrid of managed objects as parameters.
   // Now it works in gc disabled mode because of prototype.
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     ObjectHandle old_exn = oh_allocate_local_handle();
     old_exn->object = get_current_thread_exception();
     clear_current_thread_exception();
@@ -834,9 +836,7 @@
 NativeCodePtr compile_jit_a_method(Method* method)
 {
     { // Start of block with GcFrames
-    int tmn_suspend_disable_count();   
-    TRACE2("compile", "compile_jit_a_method " << method << " sus_copunt:" << tmn_suspend_disable_count());
-    assert(tmn_suspend_disable_count()==1);
+    TRACE2("compile", "compile_jit_a_method " << method );
  
     ASSERT_NO_INTERPRETER;
 
@@ -851,7 +851,6 @@
     tmn_suspend_enable(); 
     JIT_Result res = compile_do_compilation(method, flags);
     tmn_suspend_disable();
-
     if (res == JIT_SUCCESS) {
         assert(&gc == p_TLS_vmthread->gc_frames); 
         NativeCodePtr entry_point = method->get_code_addr();
@@ -861,11 +860,12 @@
         return entry_point;
     }
 
-    assert(!tmn_is_suspend_enabled());
+    assert(!hythread_is_suspend_enabled());
     
     INFO2("compile", "Could not compile " << method);
-    
     const char* exn_class;
+
+
     ManagedObject *cause = get_current_thread_exception();
     if (!cause) {
         if (method->is_native()) {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp?rev=434076&r1=434075&r2=434076&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/ini.cpp Wed Aug 23 09:48:41 2006
@@ -25,22 +25,19 @@
 #include "ini.h"
 #include "environment.h"
 #include "open/em_vm.h"
-#include "open/thread.h"
+
 
 void
 vm_execute_java_method_array(jmethodID method, jvalue *result, jvalue *args) {
     // TODO: select jit which compiled the method
-    assert(!tmn_is_suspend_enabled());
-         int tmn_suspend_disable_count();    
-    assert(tmn_suspend_disable_count()==1);
-    DEBUG_PUSH_LOCK(JAVA_CODE_PSEUDO_LOCK);
+    assert(!hythread_is_suspend_enabled());
+    //FIXME integration
+    //DEBUG_PUSH_LOCK(JAVA_CODE_PSEUDO_LOCK);
     assert(NULL != VM_Global_State::loader_env);
     assert(NULL != VM_Global_State::loader_env->em_interface);
     assert(NULL != VM_Global_State::loader_env->em_interface->ExecuteMethod);
     VM_Global_State::loader_env->em_interface->ExecuteMethod(method, result, args);
-    DEBUG_POP_LOCK(JAVA_CODE_PSEUDO_LOCK);
-    int tmn_suspend_disable_count();    
-    assert(tmn_suspend_disable_count()==1);
+    //DEBUG_POP_LOCK(JAVA_CODE_PSEUDO_LOCK);
  
 }