You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/12/26 19:25:55 UTC
svn commit: r606926 - in /harmony/enhanced/drlvm/trunk/vm: include/open/
tests/unit/thread/ tests/unit/thread/utils/ thread/src/ vmcore/build/
vmcore/include/ vmcore/src/class_support/ vmcore/src/init/
vmcore/src/jvmti/ vmcore/src/kernel_classes/javasr...
Author: gshimansky
Date: Wed Dec 26 10:25:53 2007
New Revision: 606926
URL: http://svn.apache.org/viewvc?rev=606926&view=rev
Log:
Applied patch from HARMONY-4937
[drlvm][thread] suspend_enable()/suspend_disable() race condition detector
Modified:
harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c
harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_local_storage.c
harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c
harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_suspend.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_instr.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_others.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_timing.cpp
Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Wed Dec 26 10:25:53 2007
@@ -422,11 +422,13 @@
IDATA VMCALL hythread_attach_ex(hythread_t new_handle, hythread_library_t lib, hythread_group_t group);
void VMCALL hythread_detach_ex(hythread_t thread);
IDATA VMCALL hythread_set_to_group(hythread_t thread, hythread_group_t group);
+IDATA VMCALL hythread_remove_from_group(hythread_t thread);
void VMCALL hythread_set_self(hythread_t thread);
UDATA VMCALL hythread_clear_interrupted_other(hythread_t thread);
IDATA VMCALL hythread_join(hythread_t t);
IDATA VMCALL hythread_join_timed(hythread_t t, I_64 millis, IDATA nanos);
IDATA VMCALL hythread_join_interruptable(hythread_t t, I_64 millis, IDATA nanos);
+void VMCALL hythread_yield_other(hythread_t thread);
IDATA VMCALL hythread_get_self_id();
IDATA VMCALL hythread_get_id(hythread_t t);
hythread_t VMCALL hythread_get_thread(IDATA id);
@@ -486,6 +488,7 @@
void hythread_safe_point();
void hythread_safe_point_other(hythread_t thread);
void VMCALL hythread_exception_safe_point();
+void VMCALL hythread_send_suspend_request(hythread_t thread);
IDATA VMCALL hythread_suspend_other(hythread_t thread);
IDATA VMCALL hythread_set_safepoint_callback(hythread_t thread, hythread_event_callback_proc callback);
Modified: harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h Wed Dec 26 10:25:53 2007
@@ -86,8 +86,6 @@
*/
//@{
-
-VMEXPORT hythread_t jthread_get_native_thread(jthread thread);
VMEXPORT jthread jthread_get_java_thread(hythread_t thread);
@@ -160,10 +158,10 @@
*/
//@{
-VMEXPORT IDATA jthread_suspend(jthread thread);
-VMEXPORT IDATA jthread_suspend_all(jvmtiError* results, jint count, const jthread* thread_list);
-VMEXPORT IDATA jthread_resume(jthread thread);
-VMEXPORT IDATA jthread_resume_all(jvmtiError* results, jint count, const jthread* thread_list);
+VMEXPORT IDATA jthread_suspend(jobject thread);
+VMEXPORT IDATA jthread_suspend_all(jvmtiError* results, jint count, const jobject* thread_list);
+VMEXPORT IDATA jthread_resume(jobject thread);
+VMEXPORT IDATA jthread_resume_all(jvmtiError* results, jint count, const jobject* thread_list);
VMEXPORT IDATA jthread_cancel_all();
#ifdef __cplusplus
Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c Wed Dec 26 10:25:53 2007
@@ -194,7 +194,7 @@
while(next_tested_thread(&tts)){
tf_assert_same(jthread_exception_stop(tts->java_thread, excn), TM_ERROR_NONE);
check_tested_thread_phase(tts, TT_PHASE_ANY);
- hythread = vm_jthread_get_tm_data(tts->java_thread);
+ hythread = jthread_get_native_thread(tts->java_thread);
tf_assert(hythread);
vm_thread = jthread_get_vm_thread(hythread);
tf_assert(vm_thread);
@@ -237,7 +237,7 @@
tf_assert_same(tts->excn, NULL);
tf_assert_same(jthread_stop(tts->java_thread), TM_ERROR_NONE);
- hythread = vm_jthread_get_tm_data(tts->java_thread);
+ hythread = jthread_get_native_thread(tts->java_thread);
tf_assert(hythread);
vm_thread = jthread_get_vm_thread(hythread);
tf_assert(vm_thread);
Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c Wed Dec 26 10:25:53 2007
@@ -58,7 +58,7 @@
tts->attrs.arg = tts;
tf_assert_same(jthread_create_with_function(jni_env, tts->java_thread, &tts->attrs), TM_ERROR_NONE);
tested_thread_wait_started(tts);
- tts->native_thread = (hythread_t) vm_jthread_get_tm_data(tts->java_thread);
+ tts->native_thread = jthread_get_native_thread(tts->java_thread);
check_tested_thread_phase(tts, TT_PHASE_RUNNING);
tf_assert_same(jthread_get_thread_count(&thread_count), TM_ERROR_NONE);
tf_assert_same(jthread_get_all_threads(&threads, &all_threads_count), TM_ERROR_NONE);
Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_local_storage.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_local_storage.c?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_local_storage.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_local_storage.c Wed Dec 26 10:25:53 2007
@@ -35,14 +35,14 @@
reset_tested_thread_iterator(&tts);
while (next_tested_thread(&tts)) {
- hythread = vm_jthread_get_tm_data(tts->java_thread);
+ hythread = jthread_get_native_thread(tts->java_thread);
tf_assert(hythread);
tf_assert_same(hythread_tls_set(hythread, TEST_TLS_KEY, tts),
TM_ERROR_NONE);
}
reset_tested_thread_iterator(&tts);
while (next_tested_thread(&tts)) {
- hythread = vm_jthread_get_tm_data(tts->java_thread);
+ hythread = jthread_get_native_thread(tts->java_thread);
tf_assert(hythread);
data = hythread_tls_get(hythread, TEST_TLS_KEY);
tf_assert_same(data, tts);
Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c Wed Dec 26 10:25:53 2007
@@ -238,7 +238,7 @@
tts->attrs.arg = tts;
tf_assert_same_v(jthread_create_with_function(jni_env, tts->java_thread, &tts->attrs), TM_ERROR_NONE);
tested_thread_wait_started(tts);
- tts->native_thread = (hythread_t) vm_jthread_get_tm_data(tts->java_thread);
+ tts->native_thread = jthread_get_native_thread(tts->java_thread);
}
}
@@ -336,10 +336,10 @@
jvmti_thread_t jvmti_thread;
hythread_t hythread;
- hythread = (hythread_t) vm_jthread_get_tm_data(java_thread);
- tf_assert_same(hythread, tts->native_thread);
- vm_thread = jthread_get_vm_thread(hythread);
+ vm_thread = jthread_get_vm_thread_from_java(java_thread);
tf_assert(vm_thread);
+ hythread = (hythread_t)vm_thread;
+ tf_assert_same(hythread, tts->native_thread);
jvmti_thread = &(vm_thread->jvmti_thread);
tf_assert(jvmti_thread);
return TEST_PASSED;
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Wed Dec 26 10:25:53 2007
@@ -23,6 +23,7 @@
hythread_self_slow
hythread_tls_free
hythread_yield
+hythread_yield_other
hythread_suspend
hythread_interrupt
hythread_tls_set
@@ -67,6 +68,7 @@
hythread_exception_safe_point
hythread_safe_point
hythread_safe_point_other
+hythread_send_suspend_request
hythread_suspend_other
hythread_set_safepoint_callback
hythread_suspend_all
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Wed Dec 26 10:25:53 2007
@@ -22,6 +22,7 @@
tm_self_tls;
hythread_tls_free;
hythread_yield;
+hythread_yield_other;
hythread_suspend;
hythread_interrupt;
hythread_tls_set;
@@ -68,6 +69,7 @@
hythread_exception_safe_point;
hythread_safe_point;
hythread_safe_point_other;
+hythread_send_suspend_request;
hythread_suspend_other;
hythread_set_safepoint_callback;
hythread_suspend_all;
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Wed Dec 26 10:25:53 2007
@@ -166,13 +166,20 @@
hythread_group_t group)
{
IDATA status;
+ hythread_t self = hythread_self();
assert(new_thread);
hythread_struct_init(new_thread);
assert(lib == NULL);
+
new_thread->library = TM_LIBRARY;
- new_thread->os_handle = os_thread_current();
+ if (self) {
+ // to avoid creating multiple OS handle
+ new_thread->os_handle = self->os_handle;
+ } else {
+ new_thread->os_handle = os_thread_current();
+ }
assert(new_thread->os_handle);
TRACE(("TM: native attached: native: %p ", new_thread));
@@ -182,6 +189,11 @@
hythread_set_self(new_thread);
assert(new_thread == hythread_self());
+ if (self) {
+ // remove old attached thread
+ hythread_remove_from_group(self);
+ self->thread_id = new_thread->thread_id;
+ }
return status;
}
@@ -203,25 +215,23 @@
* @see hythread_detach
*/
IDATA VMCALL hythread_attach(hythread_t *handle) {
- IDATA status;
- hythread_t self;
+ hythread_t thread;
+ IDATA status = TM_ERROR_NONE;
+ hythread_t self = hythread_self();
- hythread_t thread = (hythread_t)calloc(1, hythread_get_struct_size());
- assert(thread);
+ if (self) {
+ // thread is already attached, nothing to do
+ thread = self;
+ } else {
+ // create thread
+ thread = (hythread_t)calloc(1, hythread_get_struct_size());
+ assert(thread);
+ // attach thread
+ status = hythread_attach_ex(thread, NULL, NULL);
+ }
if (handle) {
*handle = thread;
}
-
- // get current thread
- self = hythread_self();
-
- // attach thread
- status = hythread_attach_ex(thread, NULL, NULL);
-
- // restore current thread
- if (self) {
- hythread_set_self(self);
- }
return status;
}
@@ -264,20 +274,7 @@
assert(thread);
// Detach if thread is attached to group.
- if (thread->group) {
- // The thread can be detached from the other thread in case
- // of forceful termination by hythread_cancel(), but thread
- // local storage can be zeroed only for current thread.
- if (thread == hythread_self() ) {
- hythread_set_self(NULL);
- }
- fast_thread_array[thread->thread_id] = NULL;
-
- thread->prev->next = thread->next;
- thread->next->prev = thread->prev;
- thread->group->threads_count--;
- thread->group = NULL;
- }
+ hythread_remove_from_group(thread);
// Send join event to those threads who called join on this thread.
status = hylatch_count_down(thread->join_event);
@@ -331,10 +328,18 @@
* @return none
*/
void VMCALL hythread_yield() {
- //apr_thread_yield returns void
apr_thread_yield();
}
+/**
+ * Yield the processor for another thread.
+ *
+ * @return none
+ */
+void VMCALL hythread_yield_other(hythread_t thread) {
+ os_thread_yield_other(thread->os_handle);
+}
+
/**
* Return the hythread_t for the current thread.
*
@@ -583,6 +588,39 @@
hymutex_lock(&thread->mutex);
thread->state |= TM_THREAD_STATE_ALIVE | TM_THREAD_STATE_RUNNABLE;
hymutex_unlock(&thread->mutex);
+
+ status = hythread_global_unlock();
+ assert(status == TM_ERROR_NONE);
+
+ return TM_ERROR_NONE;
+}
+
+/**
+ * Detach thread from group if it is attached to.
+ */
+IDATA VMCALL hythread_remove_from_group(hythread_t thread)
+{
+ IDATA status;
+
+ if (!thread->group) {
+ return TM_ERROR_NONE;
+ }
+
+ status = hythread_global_lock();
+ assert(status == TM_ERROR_NONE);
+
+ // The thread can be detached from the other thread in case
+ // of forceful termination by hythread_cancel(), but thread
+ // local storage can be zeroed only for current thread.
+ if (thread == hythread_self() ) {
+ hythread_set_self(NULL);
+ }
+ fast_thread_array[thread->thread_id] = NULL;
+
+ thread->prev->next = thread->next;
+ thread->next->prev = thread->prev;
+ thread->group->threads_count--;
+ thread->group = NULL;
status = hythread_global_unlock();
assert(status == TM_ERROR_NONE);
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Wed Dec 26 10:25:53 2007
@@ -106,7 +106,7 @@
*/
void VMCALL hythread_safe_point_other(hythread_t thread)
{
- thread_safe_point_impl(tm_self_tls);
+ thread_safe_point_impl(thread);
}
@@ -152,16 +152,21 @@
* Calling wait_safe_region_event() could be called
* to wait for safe region or safe point.
*/
-static void send_suspend_request(hythread_t thread)
+void VMCALL hythread_send_suspend_request(hythread_t thread)
{
// increment suspend count
apr_atomic_inc32(&thread->suspend_count);
apr_atomic_inc32(&thread->request);
+
+ if (thread != hythread_self()) {
+ // notify target thread about suspend request change
+ hythread_yield_other(thread);
+ }
}
/**
* Waits until a given thread reaches a safe region.
- * The method is called after send_suspend_request() function
+ * The method is called after hythread_send_suspend_request() function
* as the second part of suspension.
*/
static IDATA wait_safe_region_event(hythread_t thread)
@@ -201,7 +206,7 @@
{
hythread_t self = tm_self_tls;
- send_suspend_request(self);
+ hythread_send_suspend_request(self);
hymutex_lock(&self->mutex);
self->state |= TM_THREAD_STATE_SUSPENDED;
@@ -250,7 +255,7 @@
}
// suspend another thread
- send_suspend_request(thread);
+ hythread_send_suspend_request(thread);
if (wait_safe_region_event(thread) != TM_ERROR_NONE) {
hythread_resume(thread);
return TM_ERROR_EBUSY;
@@ -377,7 +382,7 @@
iter = hythread_iterator_create(group);
while ((next = hythread_iterator_next(&iter)) != NULL) {
if (next != self) {
- send_suspend_request(next);
+ hythread_send_suspend_request(next);
}
}
hythread_iterator_reset(&iter);
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp Wed Dec 26 10:25:53 2007
@@ -418,6 +418,7 @@
jthread_get_thread_user_cpu_time;
jthread_get_thread_waited_time;
jthread_get_thread_waited_times_count;
+ jthread_get_tm_data;
jthread_get_total_started_thread_count;
jthread_get_vm_thread_ptr_safe;
jthread_get_waited_count;
@@ -461,6 +462,7 @@
jthread_set_priority;
jthread_set_thread_contention_monitoring_enabled;
jthread_set_thread_cpu_time_enabled;
+ jthread_set_tm_data;
jthread_sleep;
jthread_stop;
jthread_suspend;
@@ -631,8 +633,6 @@
vm_hint_finalize;
vm_instanceof_class;
vm_iterate_object;
- vm_jthread_get_tm_data;
- vm_jthread_set_tm_data;
vm_load_jit;
vm_managed_calling_convention;
vm_max_fast_instanceof_depth;
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h Wed Dec 26 10:25:53 2007
@@ -87,6 +87,7 @@
Lock_Manager *p_method_call_lock;
Lock_Manager *p_handle_lock;
Lock_Manager *p_dclist_lock;
+ Lock_Manager *p_suspend_lock;
/**
* If set to true by the <code>-compact_fields</code> command-line option,
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h Wed Dec 26 10:25:53 2007
@@ -169,12 +169,18 @@
struct ClassLoader *onload_caller;
/**
- * Flag to detect if a class is not found on bootclasspath,
- * as opposed to linkage errors.
- * Used for implementing default delegation model.
- */
+ * Flag to detect if a class is not found on bootclasspath,
+ * as opposed to linkage errors.
+ * Used for implementing default delegation model.
+ */
unsigned char class_not_found;
+ /**
+ * Flag to detect if a thread is suspend.
+ * Used for serialization Java suspend.
+ */
+ unsigned char suspend_flag;
+
// In case exception is thrown, Exception object is put here
volatile struct Exception thread_exception;
@@ -293,7 +299,7 @@
/**
* Frees java related resources before thread exit.
*/
-VMEXPORT jint vm_detach(jthread java_thread);
+VMEXPORT jint vm_detach(jobject java_thread);
/**
* Stores a pointer to TM-specific data in the <code>java.lang.Thread</code> object.
@@ -305,7 +311,7 @@
* is going to be used for data storage
* @param[in] data_ptr - a pointer to data to be stored
*/
-VMEXPORT void vm_jthread_set_tm_data(jthread thread, void *data_ptr);
+VMEXPORT void jthread_set_tm_data(jobject thread, void *data_ptr);
/**
* Retrieves TM-specific data from the <code>java.lang.Thread</code> object.
@@ -315,7 +321,7 @@
* @return TM-specific data previously stored, or <code>NULL</code>,
* if there are none.
*/
-VMEXPORT hythread_t vm_jthread_get_tm_data(jthread thread);
+VMEXPORT void* jthread_get_tm_data(jobject thread);
/**
* <code>vm_objects_are_equal<br>
@@ -365,6 +371,29 @@
return (native && native->java_status != TM_STATUS_WITHOUT_JAVA)
? ((vm_thread_t)native) : NULL;
} // jthread_get_vm_thread_unsafe
+
+/**
+ * Gets native thread associated with a given Java thread.
+ * @return native thread
+ */
+hy_inline hythread_t jthread_get_native_thread(jobject java_thread)
+{
+ assert(java_thread);
+ return (hythread_t)jthread_get_tm_data(java_thread);
+} // jthread_get_native_thread
+
+/**
+ * Gets VM_thread associated with a given Java thread.
+ * @return pointer to VM_thread or NULL
+ */
+hy_inline vm_thread_t jthread_get_vm_thread_from_java(jobject java_thread)
+{
+ vm_thread_t vm_thread;
+ assert(java_thread);
+ vm_thread = (vm_thread_t)jthread_get_tm_data(java_thread);
+ return (vm_thread && ((hythread_t)vm_thread)->java_status == TM_STATUS_INITIALIZED)
+ ? vm_thread : NULL;
+} // jthread_get_vm_thread_from_java
#ifdef __cplusplus
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp Wed Dec 26 10:25:53 2007
@@ -142,6 +142,7 @@
p_handle_lock = new Lock_Manager();
p_method_call_lock = new Lock_Manager();
p_dclist_lock = new Lock_Manager();
+ p_suspend_lock = new Lock_Manager();
//
// preloaded classes
@@ -247,6 +248,7 @@
delete p_handle_lock;
delete p_method_call_lock;
delete p_dclist_lock;
+ delete p_suspend_lock;
// Unload jit instances.
vm_delete_all_jits();
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Wed Dec 26 10:25:53 2007
@@ -703,6 +703,7 @@
vm_env = java_vm->vm_env;
vm_thread_t main_thread = jthread_allocate_thread();
+ assert(main_thread);
if (hythread_attach_ex((hythread_t)main_thread, NULL, NULL) != TM_ERROR_NONE) {
return JNI_ERR;
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp Wed Dec 26 10:25:53 2007
@@ -197,8 +197,6 @@
if (state & JVMTI_THREAD_STATE_SUSPENDED)
return JVMTI_ERROR_THREAD_SUSPENDED;
-
-
return (jvmtiError)jthread_suspend(thread);
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java Wed Dec 26 10:25:53 2007
@@ -876,23 +876,12 @@
* @deprecated
*/
public final void suspend() {
- int status;
-
- checkAccess();
-
- // We can receive EBUSY from VMThreadManager.suspend() if we are
- // requested to suspend ourselves. If we are requested to suspend we
- // cannot to suspend other threads, so we need to try to suspend
- // again.
-
- do {
- status = VMThreadManager.suspend(this);
- } while (status == VMThreadManager.TM_ERROR_EBUSY);
-
- if (status != VMThreadManager.TM_ERROR_NONE) {
- throw new InternalError(
- "Thread Manager internal error " + status);
- }
+ checkAccess();
+
+ int status = VMThreadManager.suspend(this);
+ if (status != VMThreadManager.TM_ERROR_NONE) {
+ throw new InternalError("Thread Manager internal error " + status);
+ }
}
/**
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp?rev=606926&r1=606925&r2=606926&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp Wed Dec 26 10:25:53 2007
@@ -226,7 +226,7 @@
{
hythread_t tm_native_thread;
- tm_native_thread = (hythread_t )vm_jthread_get_tm_data((jthread)thread);
+ tm_native_thread = jthread_get_native_thread(thread);
assert(tm_native_thread);
return hythread_is_alive(tm_native_thread) ? 1 : 0;
}
@@ -249,12 +249,19 @@
* Signature: (Ljava/lang/Thread;)I
*/
JNIEXPORT jint JNICALL Java_java_lang_VMThreadManager_getState
- (JNIEnv * UNREF jenv, jclass clazz, jobject jthread)
+ (JNIEnv * UNREF jenv, jclass clazz, jobject java_thread)
{
- hythread_t tm_native_thread = jthread_get_native_thread(jthread);
- IDATA retval = hythread_get_state(tm_native_thread);
+ jint state;
+ assert(java_thread);
+ jthread_get_jvmti_state(java_thread, &state);
- return retval;
+ // FIXME - need to set WAITING state instead
+ hythread_t native_thread = jthread_get_native_thread(java_thread);
+ assert(native_thread);
+ if (hythread_is_parked(native_thread)) {
+ state |= TM_THREAD_STATE_PARKED;
+ }
+ return state;
}
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -241,7 +241,7 @@
/**
* Detaches current thread from VM.
*/
-jint vm_detach(jthread java_thread)
+jint vm_detach(jobject java_thread)
{
assert(hythread_is_suspend_enabled());
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -223,7 +223,7 @@
if (jni_env == NULL || java_thread == NULL || given_attrs == NULL) {
return TM_ERROR_NULL_POINTER;
}
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
+ hythread_t native_thread = jthread_get_native_thread(java_thread);
assert(native_thread);
vm_thread_t vm_thread = jthread_get_vm_thread_unsafe(native_thread);
@@ -441,7 +441,7 @@
(weak_ref) ? jni_env->NewGlobalRef(weak_ref) : NULL;
// Associate java thread with native thread
- vm_jthread_set_tm_data(java_thread, vm_thread);
+ jthread_set_tm_data(java_thread, vm_thread);
return TM_ERROR_NONE;
} // jthread_associate_native_and_java_thread
@@ -482,9 +482,7 @@
IDATA jthread_stop(jthread java_thread)
{
assert(java_thread);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- assert(native_thread);
- vm_thread_t vm_thread = jthread_get_vm_thread(native_thread);
+ vm_thread_t vm_thread = (vm_thread_t)jthread_get_tm_data(java_thread);
assert(vm_thread);
JNIEnv *env = vm_thread->jni_env;
assert(env);
@@ -506,9 +504,7 @@
IDATA jthread_exception_stop(jthread java_thread, jobject excn)
{
assert(java_thread);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- assert(native_thread);
- vm_thread_t vm_thread = jthread_get_vm_thread(native_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
assert(vm_thread);
// Install safepoint callback that would throw exception
@@ -516,7 +512,7 @@
assert(env);
vm_thread->stop_exception = env->NewGlobalRef(excn);
- return hythread_set_thread_stop_callback(native_thread, stop_callback);
+ return hythread_set_thread_stop_callback((hythread_t)vm_thread, stop_callback);
} // jthread_exception_stop
/**
@@ -619,17 +615,6 @@
assert(java_thread);
return java_thread;
} // jthread_get_thread
-
-/**
- * Returns native thread associated with the given Java <code>thread</code>.
- *
- * @return native thread
- */
-hythread_t jthread_get_native_thread(jthread thread)
-{
- assert(thread);
- return vm_jthread_get_tm_data(thread);
-} // jthread_get_native_thread
/**
* Returns Java thread associated with the given native <code>thread</code>.
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -20,9 +20,14 @@
* @brief Java thread suspend/resume functions
*/
+#define LOG_DOMAIN "tm.suspend"
+#include "clog.h"
+
#include <open/jthread.h>
#include <open/hythread_ext.h>
+#include <open/vm_util.h>
#include "vm_threads.h"
+#include "environment.h"
/**
* Resumes the suspended thread <code>thread</code> execution.
@@ -34,10 +39,61 @@
* @param[in] java_thread thread to be resumed
* @sa java.lang.Thread.resume(), JVMTI::ResumeThread()
*/
-IDATA VMCALL jthread_resume(jthread java_thread)
+IDATA VMCALL jthread_resume(jobject java_thread)
{
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- hythread_resume(native_thread);
+ assert(java_thread);
+
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ if (!vm_thread || vm_thread->suspend_flag == 0) {
+ // it is a fast path
+ // thread is not alive or is not suspended, nothing to do
+
+ TRACE(("java resume exit, self: %p, thread: %p",
+ hythread_self(), vm_thread));
+
+ return TM_ERROR_NONE;
+ }
+
+ TRACE(("java resume enter, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+
+ Lock_Manager *suspend_lock = VM_Global_State::loader_env->p_suspend_lock;
+ suspend_lock->_lock();
+
+ TRACE(("java resume lock enter, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+ vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ if (!vm_thread || vm_thread->suspend_flag == 0) {
+ // thread is not alive or is already suspended,
+ // release the lock and exit
+
+ TRACE(("java resume exit, self: %p, thread: %p",
+ hythread_self(), vm_thread));
+
+ suspend_lock->_unlock();
+ return TM_ERROR_NONE;
+ }
+
+ hythread_t hy_thread = (hythread_t)vm_thread;
+ if (vm_thread->suspend_flag != 0) {
+ hythread_resume(hy_thread);
+ vm_thread->suspend_flag = 0;
+ }
+
+ TRACE(("java resume lock exit, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+ suspend_lock->_unlock();
+
+ TRACE(("java resume exit, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
return TM_ERROR_NONE;
} // jthread_resume
@@ -52,11 +108,25 @@
IDATA VMCALL
jthread_resume_all(jvmtiError *results,
jint count,
- const jthread *thread_list)
+ const jobject *thread_list)
{
+ assert(results);
+ assert(thread_list);
+
+ if (!count) {
+ return TM_ERROR_NONE;
+ }
+
+ TRACE(("java resume all"));
+
+ Lock_Manager *suspend_lock = VM_Global_State::loader_env->p_suspend_lock;
+ suspend_lock->_lock();
+
for (jint i = 0; i < count; i++) {
results[i] = (jvmtiError)jthread_resume(thread_list[i]);
}
+
+ suspend_lock->_unlock();
return TM_ERROR_NONE;
} // jthread_resume_all
@@ -78,16 +148,90 @@
* @param[in] java_thread thread to be suspended
* @sa java.lang.Thread.suspend(), JVMTI::SuspendThread()
*/
-IDATA VMCALL jthread_suspend(jthread java_thread)
+IDATA VMCALL jthread_suspend(jobject java_thread)
{
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
IDATA status;
+ assert(java_thread);
+
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ if (!vm_thread || vm_thread->suspend_flag) {
+ // it is a fast path
+ // thread is not alive or is already suspended, nothing to do
+
+ TRACE(("java suspend enter, self: %p, thread: %p",
+ hythread_self(), vm_thread));
+
+ return TM_ERROR_NONE;
+ }
+
+ TRACE(("java suspend enter, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+ Lock_Manager *suspend_lock = VM_Global_State::loader_env->p_suspend_lock;
+ suspend_lock->_lock();
+
+ TRACE(("java suspend lock enter, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+ vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ if (!vm_thread || vm_thread->suspend_flag) {
+ // thread is not alive or is already suspended,
+ // release the lock and exit
+
+ TRACE(("java suspend exit, self: %p, thread: %p, ",
+ hythread_self(), vm_thread));
+
+ suspend_lock->_unlock();
+ return TM_ERROR_NONE;
+ }
+
+ hythread_t hy_thread = (hythread_t)vm_thread;
+ if (hy_thread == hythread_self()) {
+ // suspend self
+ hythread_send_suspend_request(hy_thread);
+
+ // set SUSPEND state
+ vm_thread->suspend_flag = 1;
+ status = hythread_thread_lock(hy_thread);
+ assert(status == TM_ERROR_NONE);
+ IDATA state = hythread_get_state(hy_thread) | TM_THREAD_STATE_SUSPENDED;
+ status = hythread_set_state(hy_thread, state);
+ assert(status == TM_ERROR_NONE);
+ status = hythread_thread_unlock(hy_thread);
+ assert(status == TM_ERROR_NONE);
+
+ TRACE(("java suspend lock exit, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+ suspend_lock->_unlock();
- while ((status= hythread_suspend_other(native_thread)) != TM_ERROR_NONE)
- {
hythread_safe_point();
- hythread_exception_safe_point();
+
+ suspend_lock->_lock();
+
+ TRACE(("java suspend lock enter, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+ } else {
+ while ((status = hythread_suspend_other(hy_thread)) != TM_ERROR_NONE) {
+ hythread_safe_point();
+ hythread_exception_safe_point();
+ }
+ vm_thread->suspend_flag = 1;
+
}
+ TRACE(("java suspend lock exit, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
+
+ suspend_lock->_unlock();
+
+ TRACE(("java suspend exit, self: %p, thread: %p, "
+ "suspend_flag: %d", hythread_self(), vm_thread,
+ vm_thread->suspend_flag));
return TM_ERROR_NONE;
} // jthread_suspend
@@ -115,10 +259,24 @@
IDATA VMCALL
jthread_suspend_all(jvmtiError *results,
jint count,
- const jthread *thread_list)
+ const jobject *thread_list)
{
+ assert(results);
+ assert(thread_list);
+
+ if (!count) {
+ return TM_ERROR_NONE;
+ }
+
+ TRACE(("java suspend all"));
+
+ Lock_Manager *suspend_lock = VM_Global_State::loader_env->p_suspend_lock;
+ suspend_lock->_lock();
+
for (jint i = 0; i < count; i++) {
results[i] = (jvmtiError)jthread_suspend(thread_list[i]);
}
+
+ suspend_lock->_unlock();
return TM_ERROR_NONE;
} // jthread_suspend_all
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -96,6 +96,15 @@
// Destroy current VM_thread pool.
apr_pool_destroy(vm_thread->pool);
+ // resume thread if it was suspended
+ // dead thread resume has no affect
+ Lock_Manager *suspend_lock = VM_Global_State::loader_env->p_suspend_lock;
+ suspend_lock->_lock();
+ if (vm_thread->suspend_flag) {
+ hythread_resume((hythread_t)vm_thread);
+ }
+ suspend_lock->_unlock();
+
// zero VM_thread structure
memset(&vm_thread->java_thread, 0,
sizeof(VM_thread) - offsetof(VM_thread, java_thread));
@@ -218,51 +227,43 @@
return (char *) (((ManagedObject *) ptr)->vt()->clss->get_name()->bytes);
}
-hythread_t vm_jthread_get_tm_data(jthread thread)
+void* jthread_get_tm_data(jobject thread)
{
static int offset = -1;
- Class *clazz;
- Field *field;
- ManagedObject *thread_obj;
- Byte *java_ref;
- POINTER_SIZE_INT val;
hythread_suspend_disable();
- thread_obj = ((ObjectHandle) thread)->object;
+ ManagedObject *thread_obj = ((ObjectHandle) thread)->object;
if (offset == -1) {
- clazz = thread_obj->vt()->clss;
- field = class_lookup_field_recursive(clazz, "vm_thread", "J");
+ Class *clazz = thread_obj->vt()->clss;
+ Field *field = class_lookup_field_recursive(clazz, "vm_thread", "J");
offset = field->get_offset();
}
- java_ref = (Byte *) thread_obj;
- val = *(POINTER_SIZE_INT *) (java_ref + offset);
+ Byte *java_ref = (Byte *) thread_obj;
+ void **val = (void**)(java_ref + offset);
hythread_suspend_enable();
- return (hythread_t) val;
-}
+ return *val;
+} // jthread_get_tm_data
-void vm_jthread_set_tm_data(jthread thread, void *val)
+void jthread_set_tm_data(jobject thread, void *val)
{
+ static unsigned offset = -1;
+
hythread_suspend_disable();
ManagedObject *thread_obj = ((ObjectHandle) thread)->object;
-
- // offset 0 has an virtual table of object,
- // thus field "vm_thread" cannot have such offset value
- static unsigned offset = 0;
- if (!offset) {
+ if (offset == -1) {
Class *clazz = thread_obj->vt()->clss;
Field *field = class_lookup_field_recursive(clazz, "vm_thread", "J");
offset = field->get_offset();
}
-
Byte *java_ref = (Byte *) thread_obj;
*(jlong *) (java_ref + offset) = (jlong) (POINTER_SIZE_INT) val;
hythread_suspend_enable();
-}
+} // jthread_set_tm_data
int vm_objects_are_equal(jobject obj1, jobject obj2)
{
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -282,12 +282,14 @@
assert(state);
assert(java_thread);
+ hythread_t native_thread = jthread_get_native_thread(java_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread(native_thread);
*state = 0;
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
if (!native_thread) {
// Not started yet
return TM_ERROR_NONE;
}
+
if (hythread_is_alive(native_thread)) {
*state |= JVMTI_THREAD_STATE_ALIVE;
}
@@ -315,9 +317,6 @@
if (hythread_is_parked(native_thread)) {
*state |= JVMTI_THREAD_STATE_PARKED;
}
- if (hythread_is_suspended(native_thread)) {
- *state |= JVMTI_THREAD_STATE_SUSPENDED;
- }
if (hythread_interrupted(native_thread)) {
*state |= JVMTI_THREAD_STATE_INTERRUPTED;
}
@@ -327,6 +326,9 @@
if (hythread_is_terminated(native_thread)) {
*state |= JVMTI_THREAD_STATE_TERMINATED;
}
+ if (vm_thread && vm_thread->suspend_flag) {
+ *state |= JVMTI_THREAD_STATE_SUSPENDED;
+ }
return TM_ERROR_NONE;
} // jthread_get_jvmti_state
@@ -362,8 +364,9 @@
jthread_get_contended_monitor(jthread java_thread, jobject * monitor)
{
assert(java_thread);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread(native_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ assert(vm_thread);
+ jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;
if (jvmti_thread)
*monitor = jvmti_thread->contended_monitor;
else
@@ -381,8 +384,9 @@
IDATA VMCALL jthread_get_wait_monitor(jthread java_thread, jobject * monitor)
{
assert(java_thread);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread(native_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ assert(vm_thread);
+ jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;
if (jvmti_thread)
*monitor = jvmti_thread->wait_monitor;
else
@@ -430,7 +434,7 @@
{
assert(monitor);
- hythread_t given_thread = owner ? vm_jthread_get_tm_data(owner) : NULL;
+ hythread_t given_thread = owner ? jthread_get_native_thread(owner) : NULL;
hythread_suspend_disable();
hythread_thin_monitor_t *lockword = vm_object_get_lockword_addr(monitor);
@@ -468,8 +472,10 @@
if (status != TM_ERROR_NONE) {
return status;
}
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread(native_thread);
+ assert(java_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ assert(vm_thread);
+ jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;
if (!jvmti_thread)
{
status = hythread_global_unlock();
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -105,9 +105,9 @@
JVMTILocalStorage *jthread_get_jvmti_local_storage(jthread java_thread)
{
assert(java_thread);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- assert(native_thread);
- jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread(native_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ assert(vm_thread);
+ jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;
assert(jvmti_thread);
return &jvmti_thread->jvmti_local_storage;
} // jthread_get_jvmti_local_storage
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=606926&r1=606925&r2=606926&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 Wed Dec 26 10:25:53 2007
@@ -44,9 +44,9 @@
{
assert(java_thread);
assert(nanos_ptr);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- assert(native_thread);
- jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread(native_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ assert(vm_thread);
+ jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;
if (jvmti_thread)
*nanos_ptr = jvmti_thread->blocked_time;
else
@@ -67,7 +67,7 @@
assert(nanos_ptr);
hythread_t native_thread = (NULL == java_thread)
- ? hythread_self() : vm_jthread_get_tm_data(java_thread);
+ ? hythread_self() : jthread_get_native_thread(java_thread);
assert(native_thread);
return hythread_get_thread_times(native_thread, &kernel_time,
nanos_ptr);
@@ -94,14 +94,14 @@
{
assert(nanos_ptr);
assert(java_thread);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
+ hythread_t native_thread = jthread_get_native_thread(java_thread);
assert(native_thread);
int64 kernel_time;
int64 user_time;
IDATA status = hythread_get_thread_times(native_thread,
&kernel_time, &user_time);
- assert(status != TM_ERROR_NONE);
+ assert(status == TM_ERROR_NONE);
*nanos_ptr = user_time;
return TM_ERROR_NONE;
} // jthread_get_thread_user_cpu_time
@@ -117,9 +117,9 @@
{
assert(java_thread);
assert(nanos_ptr);
- hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
- assert(native_thread);
- jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread(native_thread);
+ vm_thread_t vm_thread = jthread_get_vm_thread_from_java(java_thread);
+ assert(vm_thread);
+ jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;
if (jvmti_thread)
*nanos_ptr = jvmti_thread->waited_time;
else