harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r583223 [2/2] - in /harmony/enhanced/drlvm/trunk/vm: gc_cc/src/ gc_gen/src/common/ include/open/ tests/unit/thread/ tests/unit/thread/utils/ thread/src/ thread/src/linux/ thread/src/win/ vmcore/include/ vmcore/src/class_support/ vmcore/src/...
Date Tue, 09 Oct 2007 17:06:38 GMT
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?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp Tue Oct  9 10:06:34
2007
@@ -46,7 +46,6 @@
 #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"
@@ -100,21 +99,16 @@
  */
 static jint run_java_detach(jthread java_thread)
 {
-    static Method *detach = NULL;
-    const char *method_name = "detach";
-    const char *descriptor = "(Ljava/lang/Throwable;)V";
-    jvalue args[2];
-    JNIEnv *jni_env;
-    Global_Env *vm_env;
-    Class *thread_class;
-
     assert(hythread_is_suspend_enabled());
 
-    jni_env = jthread_get_JNI_env(java_thread);
-    vm_env = jni_get_vm_env(jni_env);
-    thread_class = vm_env->java_lang_Thread_Class;
+    JNIEnv *jni_env = jthread_get_JNI_env(java_thread);
+    Global_Env *vm_env = jni_get_vm_env(jni_env);
+    Class *thread_class = vm_env->java_lang_Thread_Class;
 
+    static Method *detach = NULL;
     if (detach == NULL) {
+        const char *method_name = "detach";
+        const char *descriptor = "(Ljava/lang/Throwable;)V";
         detach = class_lookup_method(thread_class, method_name, descriptor);
         if (detach == NULL) {
             TRACE("Failed to find thread's detach method " << descriptor <<
@@ -122,7 +116,9 @@
             return TM_ERROR_INTERNAL;
         }
     }
+
     // Initialize arguments.
+    jvalue args[2];
     args[0].l = java_thread;
     if (vm_env->IsVmShutdowning()) {
         args[1].l = NULL;
@@ -145,6 +141,23 @@
 }
 
 /**
+ * Runs java.lang.Thread.detach() method
+ *
+ * This function will release any resources associated with the given java thread.
+ *
+ * @param[in] java_thread Java thread to be detached
+ */
+IDATA jthread_java_detach(jthread java_thread) {
+    assert(java_thread);
+    assert(hythread_is_suspend_enabled());
+
+    // could return error if detach throws an exception,
+    // keep exception and ignore an error
+    run_java_detach(java_thread);
+    return TM_ERROR_NONE;
+}
+
+/**
  * Attaches thread current thread to VM.
  */
 jint vm_attach(JavaVM * java_vm, JNIEnv ** p_jni_env)
@@ -223,47 +236,39 @@
  */
 jint vm_detach(jthread java_thread)
 {
-    VM_thread *p_vm_thread;
-
     assert(hythread_is_suspend_enabled());
 
-    // could return error if detach throws an exception,
-    // keep exception and ignore an error
-    run_java_detach(java_thread);
+    hythread_t native_thread = jthread_get_native_thread(java_thread);
+    assert(native_thread);
+    vm_thread_t p_vm_thread = jthread_get_vm_thread(native_thread);
+    assert(p_vm_thread);
 
     // Send Thread End event
-    jvmti_send_thread_start_end_event(0);
+    jvmti_send_thread_start_end_event(p_vm_thread, 0);
 
     hythread_suspend_disable();
 
-    p_vm_thread = get_thread_ptr();
+    // change java_status for native thread
+    native_thread->java_status = TM_STATUS_ALLOCATED;
 
-    // Notify GC about thread detaching.
-    gc_thread_kill(&p_vm_thread->_gc_private_information);
-    assert(p_vm_thread->gc_frames == 0);
+    if (native_thread == hythread_self()) {
+        // Notify GC about thread detaching.
+        // FIXME - GC notify detach thread works for current thread only
+        gc_thread_kill(&p_vm_thread->_gc_private_information);
+        assert(p_vm_thread->gc_frames == 0);
+    }
 
 #ifdef PLATFORM_POSIX
     // Remove guard page on the stack on linux
-    remove_guard_stack();
-#endif
+    remove_guard_stack(p_vm_thread);
+#endif // PLATFORM_POSIX
 
-    // Destroy current VM_thread pool.
+    // Destroy current VM_thread pool and zero VM_thread structure
     jthread_deallocate_vm_thread_pool(p_vm_thread);
 
     hythread_suspend_enable();
 
     return JNI_OK;
-
-/** TODO: Check if we need these actions!!!
-#ifndef NDEBUG
-    hythread_t tm_native_thread = jthread_get_native_thread();
-    assert(tm_native_thread);
-    assert(tm_native_thread == hythread_self());
-#endif
-
-    // 3) Remove tm_thread_t pointer from java.lang.Thread object.
-    vm_jthread_set_tm_data(jthread java_thread, NULL);
-*/
 }
 
 void vm_notify_obj_alive(void *p_obj)

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp Tue Oct  9 10:06:34
2007
@@ -22,7 +22,6 @@
 
 #include <open/jthread.h>
 #include <open/hythread_ext.h>
-#include "open/thread_externals.h"
 #include "vm_threads.h"
 #include "jni.h"
 
@@ -30,9 +29,9 @@
 #include "cxxlog.h"
 
 static jmethodID jthread_get_run_method(JNIEnv * env, jthread java_thread);
-static jmethodID jthread_get_set_alive_method(JNIEnv * env, jthread java_thread);
-static IDATA jthread_associate_native_and_java_thread(JNIEnv * env,
-    jthread java_thread, hythread_t native_thread, jobject weak_ref);
+static jfieldID jthread_get_alive_field(JNIEnv * env, jthread java_thread);
+static IDATA jthread_associate_native_and_java_thread(JNIEnv *jni_env,
+    jthread java_thread, vm_thread_t vm_thread, jobject weak_ref);
 
 /**
  * Creates new Java thread.
@@ -47,30 +46,85 @@
  */
 IDATA jthread_create(JNIEnv *jni_env,
                      jthread java_thread,
-                     jthread_threadattr_t *attrs)
+                     jthread_start_proc_data_t attrs)
 {
     return jthread_create_with_function(jni_env, java_thread, attrs);
 } // jthread_create
 
-static IDATA HYTHREAD_PROC jthread_wrapper_proc(void *arg)
+/**
+ * Wrapper around user thread start proc.
+ * Used to perform some duty jobs right after thread is started
+ * and before thread is finished.
+ */
+int HYTHREAD_PROC jthread_wrapper_start_proc(void *arg)
 {
-    assert(arg);
-    jthread_threadattr_t data = *(jthread_threadattr_t*) arg;
+    // store start procedure argument to local variable
+    jthread_start_proc_data start_proc_data = *(jthread_start_proc_data_t)arg;
     STD_FREE(arg);
 
-    // Association should be already done.
-    hythread_t native_thread = hythread_self();
-    assert(native_thread);
+    // get hythread global lock
+    IDATA status = hythread_global_lock();
+    assert(status == TM_ERROR_NONE);
+
+    // get native thread
+    hythread_t native_thread = start_proc_data.hy_data.thread;
+
+    // check hythread library state
+    if (hythread_lib_state() != TM_LIBRARY_STATUS_INITIALIZED) {
+        // set TERMINATED state
+        status = hythread_set_state(native_thread, TM_THREAD_STATE_TERMINATED);
+        assert(status == TM_ERROR_NONE);
+
+        // set hythread_self()
+        hythread_set_self(native_thread);
+        assert(native_thread == hythread_self());
+
+        // release thread structure data
+        hythread_detach_ex(native_thread);
+
+        // zero hythread_self() because we don't do it in hythread_detach_ex()
+        hythread_set_self(NULL);
+
+        TRACE(("TM: native thread terminated due to shutdown: native: %p tm: %p",
+            apr_os_thread_current(), native_thread));
+
+        // FIXME - uncomment after TM state transition complete
+        //STD_FREE(native_thread);
+
+        // release hythread global lock
+        status = hythread_global_unlock();
+        assert(status == TM_ERROR_NONE);
+
+        return 0;
+    }
+
+    // register to group and set ALIVE state
+    status = hythread_set_to_group(native_thread, start_proc_data.hy_data.group);
+    assert(status == TM_ERROR_NONE);
+
+    // set hythread_self()
+    hythread_set_self(native_thread);
+    assert(native_thread == hythread_self());
+
+    // set priority
+    status = hythread_set_priority(native_thread,
+                                   hythread_get_priority(native_thread));
+    // FIXME - cannot set priority
+    //assert(status == TM_ERROR_NONE);
+
+    // get java thread
     vm_thread_t vm_thread = jthread_get_vm_thread_unsafe(native_thread);
     assert(vm_thread);
     jobject java_thread = vm_thread->java_thread;
+    assert(java_thread);
 
+    // attach java thread to VM
     JNIEnv *jni_env;
-    IDATA status = vm_attach(data.java_vm, &jni_env);
+    status = vm_attach(start_proc_data.java_vm, &jni_env);
     assert(status == JNI_OK);
 
     vm_thread->jni_env = jni_env;
-    vm_thread->daemon = data.daemon;
+    vm_thread->daemon = start_proc_data.daemon;
 
     TRACE(("TM: Java thread started: id=%d OS_handle=%p",
            hythread_get_id(native_thread), apr_os_thread_current()));
@@ -80,28 +134,76 @@
         assert(status == TM_ERROR_NONE);
     }
 
+    // set RUNNABLE state
+    status = hythread_thread_lock(native_thread);
+    assert(status == TM_ERROR_NONE);
+    IDATA state = hythread_get_state(native_thread);
+    status = hythread_set_state(native_thread, state | TM_THREAD_STATE_RUNNABLE);
+    assert(status == TM_ERROR_NONE);
+    status = hythread_thread_unlock(native_thread);
+    assert(status == TM_ERROR_NONE);
+
+    // increase started thread count
+    jthread_start_count();
+
     // Send Thread Start event.
     assert(hythread_is_alive(native_thread));
-    jni_env->CallVoidMethod(java_thread,
-        jthread_get_set_alive_method(jni_env, java_thread), true);
-    jvmti_send_thread_start_end_event(1);
-    jthread_start_count();
+    jni_env->SetBooleanField(java_thread,
+        jthread_get_alive_field(jni_env, java_thread), true);
+    jvmti_send_thread_start_end_event(vm_thread, 1);
+
+    // release hythread global lock
+    status = hythread_global_unlock();
+    assert(status == TM_ERROR_NONE);
 
-    if (data.proc != NULL) {
-        data.proc(data.jvmti_env, jni_env, (void*)data.arg);
+    jvmtiStartFunction start_jvmti_proc = start_proc_data.proc;
+    if (start_jvmti_proc != NULL) {
+        // start JVMTI thread
+        start_jvmti_proc(start_proc_data.jvmti_env, jni_env,
+            (void*)start_proc_data.arg);
     } else {
-        // for jthread_create();
+        // start Java thread
         jni_env->CallVoidMethodA(java_thread,
             jthread_get_run_method(jni_env, java_thread), NULL);
     }
 
-    status = jthread_detach(java_thread);
+    // run j.l.Thread.detach(), don't get hythread global lock here
+    status = jthread_java_detach(java_thread);
+    assert(status == TM_ERROR_NONE);
+
+    // get hythread global lock
+    status = hythread_global_lock();
+    assert(status == TM_ERROR_NONE);
+
+    // detach vm thread
+    status = jthread_vm_detach(vm_thread);
+    assert(status == TM_ERROR_NONE);
+
+    // set TERMINATED thread
+    status = hythread_thread_lock(native_thread);
+    assert(status == TM_ERROR_NONE);
+    // FIXME - remove INTERRUPTED state after TM state transition complete
+    state = hythread_get_state(native_thread);
+    status = hythread_set_state(native_thread,
+        TM_THREAD_STATE_TERMINATED | (TM_THREAD_STATE_INTERRUPTED & state));
+    assert(status == TM_ERROR_NONE);
+    status = hythread_thread_unlock(native_thread);
+    assert(status == TM_ERROR_NONE);
 
     TRACE(("TM: Java thread finished: id=%d OS_handle=%p",
-           hythread_get_id(native_thread), apr_os_thread_current()));
+        hythread_get_id(native_thread), apr_os_thread_current()));
 
-    return status;
-} // jthread_wrapper_proc
+    hythread_detach_ex(native_thread);
+
+    // FIXME - uncomment after TM state transition complete
+    //STD_FREE(vm_thread);
+
+    // release hythread global lock
+    status = hythread_global_unlock();
+    assert(status == TM_ERROR_NONE);
+
+    return 0;
+} // jthread_wrapper_start_proc
 
 /**
  * Creates new Java thread with specific execution function.
@@ -121,7 +223,7 @@
  */
 IDATA jthread_create_with_function(JNIEnv *jni_env,
                                    jthread java_thread,
-                                   jthread_threadattr_t *given_attrs)
+                                   jthread_start_proc_data_t given_attrs)
 {
     if (jni_env == NULL || java_thread == NULL || given_attrs == NULL) {
         return TM_ERROR_NULL_POINTER;
@@ -134,8 +236,8 @@
     vm_thread->java_thread = jni_env->NewGlobalRef(java_thread);
 
     // prepare args for wrapper_proc
-    jthread_threadattr_t *attrs =
-        (jthread_threadattr_t*)STD_MALLOC(sizeof(jthread_threadattr_t));
+    jthread_start_proc_data_t attrs =
+        (jthread_start_proc_data_t)STD_MALLOC(sizeof(jthread_start_proc_data));
     if (attrs == NULL) {
         return TM_ERROR_OUT_OF_MEMORY;
     }
@@ -158,7 +260,7 @@
     }
 
     status = hythread_create_ex(native_thread, NULL, attrs->stacksize,
-                        attrs->priority, jthread_wrapper_proc, attrs);
+                        attrs->priority, jthread_wrapper_start_proc, NULL, attrs);
 
     TRACE(("TM: Created thread: id=%d", hythread_get_id(native_thread)));
 
@@ -186,14 +288,14 @@
 
     hythread_t native_thread = hythread_self();
     assert(native_thread);
-    IDATA status = jthread_associate_native_and_java_thread(jni_env, java_thread,
-                        native_thread, NULL);
+    vm_thread_t vm_thread = jthread_get_vm_thread(native_thread);
+    assert(vm_thread);
+    IDATA status = jthread_associate_native_and_java_thread(jni_env,
+        java_thread, vm_thread, NULL);
     if (status != TM_ERROR_NONE) {
         return status;
     }
 
-    vm_thread_t vm_thread = jthread_get_vm_thread(native_thread);
-    assert(vm_thread);
     vm_thread->java_thread = jni_env->NewGlobalRef(java_thread);
     vm_thread->jni_env = jni_env;
     vm_thread->daemon = daemon;
@@ -204,7 +306,7 @@
 
     // Send Thread Start event.
     assert(hythread_is_alive(native_thread));
-    jvmti_send_thread_start_end_event(1);
+    jvmti_send_thread_start_end_event(vm_thread, 1);
     jthread_start_count();
 
     TRACE(("TM: Current thread attached to jthread=%p", java_thread));
@@ -216,41 +318,39 @@
  *
  * @param[in] env JNI environment that will be associated with the created Java thread
  * @param[in] java_thread the Java thread for the association
- * @param[in] weak_ref java.lang.WeakReference to the <code>java_thread</code>
that used for native resource deletion
- * @param[in] dead_thread the native thread for the association
  * @return the native thread
  */
-jlong jthread_thread_init(JNIEnv *env,
+jlong jthread_thread_init(JNIEnv *jni_env,
                           jthread java_thread,
                           jobject weak_ref,
                           hythread_t dead_thread)
 {
-    hythread_t native_thread = NULL;
+    vm_thread_t vm_thread = NULL;
     if (dead_thread) {
-        native_thread = (hythread_t)((IDATA) dead_thread);
-        vm_thread_t vm_thread = jthread_get_vm_thread_unsafe(native_thread);
+        vm_thread = jthread_get_vm_thread_unsafe(dead_thread);
         assert(vm_thread);
         if (vm_thread->weak_ref) {
             // delete used weak reference
-            env->DeleteGlobalRef(vm_thread->weak_ref);
+            jni_env->DeleteGlobalRef(vm_thread->weak_ref);
         }
     } else {
-        native_thread = (hythread_t)jthread_allocate_thread();
+        vm_thread = jthread_allocate_thread();
     }
-    
-    IDATA status = hythread_struct_init(native_thread);
+
+    IDATA status = hythread_struct_init((hythread_t)vm_thread);
     if (status != TM_ERROR_NONE) {
         return 0;
     }
 
-    status = jthread_associate_native_and_java_thread(env, java_thread,
-                    native_thread, weak_ref);
+    status = jthread_associate_native_and_java_thread(jni_env,
+        java_thread, vm_thread, weak_ref);
     if (status != TM_ERROR_NONE) {
         return 0;
     }
-    return (jlong)((IDATA)native_thread);
+    return (jlong)((IDATA)vm_thread);
 } // jthread_thread_init
 
+
 /**
  * Detaches the selected thread from java VM.
  *
@@ -260,62 +360,90 @@
  */
 IDATA jthread_detach(jthread java_thread)
 {
-    // Check input arg
     assert(java_thread);
     assert(hythread_is_suspend_enabled());
 
-    TRACE(("TM: jthread_detach %x", hythread_self()));
+    // detach java thread
+    IDATA status = jthread_java_detach(java_thread);
 
+    // get hythread global lock
+    IDATA lock_status = hythread_global_lock();
+    assert(lock_status == TM_ERROR_NONE);
+
+    // get vm_thread
     hythread_t native_thread = jthread_get_native_thread(java_thread);
     assert(native_thread);
     vm_thread_t vm_thread = jthread_get_vm_thread(native_thread);
     assert(vm_thread);
-    JNIEnv *jni_env = vm_thread->jni_env;
 
-    IDATA status;
+    // detach vm thread
+    status |= jthread_vm_detach(vm_thread);
+
+    // release hythread global lock
+    lock_status = hythread_global_unlock();
+    assert(lock_status == TM_ERROR_NONE);
+
+    return status;
+} // jthread_detach
+
+/**
+ * Detaches the selected vm_thread.
+ *
+ * This function will release any resources associated with the given vm_thread.
+ *
+ * @param[in] java_thread Java thread to be detached
+ */
+IDATA jthread_vm_detach(vm_thread_t vm_thread)
+{
+    assert(vm_thread);
+    assert(hythread_is_suspend_enabled());
+
+    TRACE(("TM: jthread_vm_detach(%p)", vm_thread));
     if (!vm_thread->daemon) {
-        status = hythread_decrease_nondaemon_threads_count(native_thread, 1);
+        hythread_t native_thread = (hythread_t)vm_thread;
+        IDATA status = hythread_decrease_nondaemon_threads_count(native_thread, 1);
         assert(status == TM_ERROR_NONE);
     }
 
     // Detach from VM.
-    status = vm_detach(java_thread);
+    jobject java_thread = vm_thread->java_thread;
+    JNIEnv *jni_env = vm_thread->jni_env;
+    jint status = vm_detach(java_thread);
     if (status != JNI_OK) {
         return TM_ERROR_INTERNAL;
     }
 
+    // FIXME - uncomment after TM state transition complete
+    //status = jthread_associate_native_and_java_thread(java_thread, NULL);
+    //if (status != TM_ERROR_NONE) {
+    //    return status;
+    //}
+
     // Delete global reference to current thread object.
-    jni_env->DeleteGlobalRef(vm_thread->java_thread);
-    // jthread_self() will return NULL now.
-    vm_thread->java_thread = NULL;
+    jni_env->DeleteGlobalRef(java_thread);
 
     // Decrease alive thread counter
     jthread_end_count();
     assert(hythread_is_suspend_enabled());
 
     return TM_ERROR_NONE;
-} // jthread_detach
+} // jthread_vm_detach
 
 static IDATA
 jthread_associate_native_and_java_thread(JNIEnv * jni_env,
                                          jthread java_thread,
-                                         hythread_t native_thread,
+                                         vm_thread_t vm_thread,
                                          jobject weak_ref)
 {
-    if ((jni_env == NULL) || (java_thread == NULL)
-        || (native_thread == NULL))
+    if ((jni_env == NULL) || (java_thread == NULL))
     {
         return TM_ERROR_NULL_POINTER;
     }
-
-    vm_thread_t vm_thread = jthread_get_vm_thread_unsafe(native_thread);
-    assert(vm_thread);
-
-    vm_thread->weak_ref = 
+    vm_thread->weak_ref =
         (weak_ref) ? jni_env->NewGlobalRef(weak_ref) : NULL;
 
     // Associate java thread with native thread      
-    vm_jthread_set_tm_data(java_thread, native_thread);
+    vm_jthread_set_tm_data(java_thread, vm_thread);
 
     return TM_ERROR_NONE;
 } // jthread_associate_native_and_java_thread
@@ -589,27 +717,27 @@
 
 static jmethodID jthread_get_run_method(JNIEnv * env, jthread java_thread)
 {
-    static jmethodID run_method = NULL;
+    static jmethodID runImpl_method = NULL;
 
     TRACE("run method find enter");
-    if (!run_method) {
+    if (!runImpl_method) {
         jclass clazz = env->GetObjectClass(java_thread);
-        run_method = env->GetMethodID(clazz, "runImpl", "()V");
+        runImpl_method = env->GetMethodID(clazz, "runImpl", "()V");
     }
     TRACE("run method find exit");
-    return run_method;
+    return runImpl_method;
 } // jthread_get_run_method
 
-static jmethodID jthread_get_set_alive_method(JNIEnv * env, jthread java_thread)
+static jfieldID jthread_get_alive_field(JNIEnv * env, jthread java_thread)
 {
-    static jmethodID set_alive_method = NULL;
+    static jfieldID isAlive_field = NULL;
 
     TRACE("run method find enter");
-    if (!set_alive_method) {
+    if (!isAlive_field) {
         jclass clazz = env->GetObjectClass(java_thread);
-        set_alive_method = env->GetMethodID(clazz, "setAlive", "(Z)V");
+        isAlive_field = env->GetFieldID(clazz, "isAlive", "Z");
     }
     TRACE("run method find exit");
-    return set_alive_method;
+    return isAlive_field;
 } // jthread_get_run_method
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp Tue Oct  9
10:06:34 2007
@@ -22,7 +22,6 @@
 #include <open/hythread_ext.h>
 #include <open/jthread.h>
 #include <open/hythread_ext.h>
-#include <open/thread_externals.h>
 #include "vm_threads.h"
 #include "jni.h"
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_suspend.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_suspend.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_suspend.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_suspend.cpp Tue Oct  9 10:06:34
2007
@@ -22,7 +22,6 @@
 
 #include <open/jthread.h>
 #include <open/hythread_ext.h>
-#include <open/thread_externals.h>
 #include "vm_threads.h"
 
 /**

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?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp Tue Oct  9 10:06:34
2007
@@ -20,8 +20,6 @@
  */
 
 
-#include "open/thread_externals.h"
-
 #include "platform_lowlevel.h"
 #include <assert.h>
 
@@ -101,9 +99,6 @@
     // zero VM_thread structure
     memset(&vm_thread->java_thread, 0,
         sizeof(VM_thread) - offsetof(VM_thread, java_thread));
-
-    // change java_status
-    ((hythread_t)(vm_thread))->java_status = TM_STATUS_ALLOCATED;
 }
 
 vm_thread_t jthread_get_vm_thread_ptr_safe(jobject thread_obj)

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_instr.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_instr.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_instr.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_instr.cpp Tue Oct  9 10:06:34
2007
@@ -23,7 +23,6 @@
 #include <open/ti_thread.h>
 #include <open/hythread_ext.h>
 #include <open/jthread.h>
-#include <open/thread_externals.h>
 #include "vm_threads.h"
 #include "object_handles.h"
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_others.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_others.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_others.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_others.cpp Tue Oct  9 10:06:34
2007
@@ -23,7 +23,6 @@
 #include <open/jthread.h>
 #include <open/hythread_ext.h>
 #include <open/ti_thread.h>
-#include <open/thread_externals.h>
 #include "vm_threads.h"
 
 #define THREAD_CONTENTION_MONITORING_SUPPORTED 1

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_timing.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_timing.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_timing.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_timing.cpp Tue Oct  9 10:06:34
2007
@@ -23,7 +23,6 @@
 #include <open/ti_thread.h>
 #include <open/hythread_ext.h>
 #include <open/jthread.h>
-#include <open/thread_externals.h>
 #include "vm_threads.h"
 #include "apr_thread_ext.h"
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp Tue Oct  9 10:06:34
2007
@@ -393,7 +393,7 @@
 
     if (available_stack_size < required_size) {
         if (available_stack_size < get_guard_stack_size()) {
-            remove_guard_stack();
+            remove_guard_stack(p_TLS_vmthread);
         }
         Global_Env *env = VM_Global_State::loader_env;
         exn_raise_by_class(env->java_lang_StackOverflowError_Class);
@@ -416,7 +416,7 @@
     return get_restore_stack_size() < available_stack_size;
 }
 
-void remove_guard_stack() {
+void remove_guard_stack(vm_thread_t vm_thread) {
     int err;
     char* stack_addr = (char*) get_stack_addr();
     size_t stack_size = get_stack_size();
@@ -433,7 +433,7 @@
 
     err = sigaltstack (&sigalt, NULL);
 
-    p_TLS_vmthread->restore_guard_page = true;
+    vm_thread->restore_guard_page = true;
 }
 
 bool check_stack_overflow(siginfo_t *info, ucontext_t *uc) {
@@ -477,7 +477,7 @@
             throw_from_sigcontext(
                 uc, env->java_lang_StackOverflowError_Class);
         } else {
-            remove_guard_stack();
+            remove_guard_stack(p_TLS_vmthread);
             exn_raise_by_class(env->java_lang_StackOverflowError_Class);
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp Tue Oct  9 10:06:34
2007
@@ -440,7 +440,7 @@
 
     if (available_stack_size < required_size) {
         if (available_stack_size < get_guard_stack_size()) {
-            remove_guard_stack();
+            remove_guard_stack(p_TLS_vmthread);
         }
         Global_Env *env = VM_Global_State::loader_env;
         exn_raise_by_class(env->java_lang_StackOverflowError_Class);
@@ -463,7 +463,7 @@
     return get_restore_stack_size() < available_stack_size;
 }
 
-void remove_guard_stack() {
+void remove_guard_stack(vm_thread_t vm_thread) {
     int err;
     char* stack_addr = (char*) get_stack_addr();
     size_t stack_size = get_stack_size();
@@ -482,7 +482,7 @@
 
     err = sigaltstack (&sigalt, NULL);
 
-    p_TLS_vmthread->restore_guard_page = true;
+    vm_thread->restore_guard_page = true;
 }
 
 bool check_stack_overflow(siginfo_t *info, ucontext_t *uc) {
@@ -526,9 +526,10 @@
             throw_from_sigcontext(
                 uc, env->java_lang_StackOverflowError_Class);
         } else {
-            remove_guard_stack();
+            vm_thread_t vm_thread = p_TLS_vmthread;
+            remove_guard_stack(vm_thread);
             exn_raise_by_class(env->java_lang_StackOverflowError_Class);
-            p_TLS_vmthread->restore_guard_page = true;
+            vm_thread->restore_guard_page = true;
         }
     }
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp Tue Oct  9 10:06:34
2007
@@ -336,7 +336,7 @@
 
     if (available_stack_size < required_size) {
         if (available_stack_size < get_guard_stack_size()) {
-            remove_guard_stack();
+            remove_guard_stack(p_TLS_vmthread);
         }
         exn_raise_by_name("java/lang/StackOverflowError");
         return false;
@@ -359,7 +359,7 @@
 }
 
 
-void remove_guard_stack() {
+void remove_guard_stack(vm_thread_t vm_thread) {
     int err;
     char* stack_addr = (char*) get_stack_addr();
     size_t stack_size = get_stack_size();
@@ -418,9 +418,10 @@
             throw_from_sigcontext(
                 uc, env->java_lang_StackOverflowError_Class);
         } else {
-            remove_guard_stack();
+            vm_thread_t vm_thread = p_TLS_vmthread;
+            remove_guard_stack(vm_thread);
             exn_raise_by_name("java/lang/StackOverflowError");
-            p_TLS_vmthread->restore_guard_page = true;
+            vm_thread->restore_guard_page = true;
         }
     }
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp
Tue Oct  9 10:06:34 2007
@@ -196,7 +196,7 @@
     jthread_self_vm_thread_unsafe()->restore_guard_page = false;
 }
 
-void remove_guard_stack() {
+void remove_guard_stack(vm_thread_t vm_thread) {
     void* stack_addr = get_stack_addr();
     size_t stack_size = get_stack_size();
     size_t page_size = get_guard_page_size();
@@ -204,7 +204,7 @@
     DWORD oldProtect;
 
     assert(((size_t)(&stack_addr)) > ((size_t)((char*)stack_addr - stack_size + 3
* page_size)));
-    p_TLS_vmthread->restore_guard_page = true;
+    vm_thread->restore_guard_page = true;
 
     if (!VirtualProtect((char*)stack_addr - stack_size + page_size + guard_stack_size,
         page_size, PAGE_READWRITE, &oldProtect)) {
@@ -241,7 +241,7 @@
     size_t available_stack_size = get_available_stack_size();
     if (available_stack_size < required_size) {
         if (available_stack_size < get_guard_stack_size()) {
-            remove_guard_stack();
+            remove_guard_stack(p_TLS_vmthread);
         }
         Global_Env *env = VM_Global_State::loader_env;
         exn_raise_by_class(env->java_lang_StackOverflowError_Class);



Mime
View raw message