diff --git vm/thread/src/thread_helpers.cpp vm/thread/src/thread_helpers.cpp index d19ea78..947eed1 100644 --- vm/thread/src/thread_helpers.cpp +++ vm/thread/src/thread_helpers.cpp @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.11 $ - */ - /** * @file thread_helpers.cpp * @brief Set of VM helpers @@ -85,7 +80,7 @@ char* gen_monitorenter_fast_path_helper(char *ss, const R_Opnd & input_param1) { #ifdef LOCK_RESERVATION //get lock_id ss = mov(ss, eax_opnd, M_Base_Opnd(ecx_reg, 0)); - // move thread_id to AX + // move thread_id to AX ss = shift(ss, ror_opc, eax_opnd, Imm_Opnd(16)); // test this recursion call @@ -131,7 +126,7 @@ char* gen_monitorenter_fast_path_helper(char *ss, const R_Opnd & input_param1) { offset2 = (signed)ss - (signed)backpatch_address__recursion_inc2 - 1; *backpatch_address__recursion_inc2 = (char)offset2; - // restore lock_id + // restore lock_id ss = shift(ss, ror_opc, eax_opnd, Imm_Opnd(16)); ss = alu(ss, add_opc, eax_opnd, Imm_Opnd(size_16, 0x800), size_16); ss = mov(ss, M_Base_Opnd(ecx_reg, 0), eax_opnd, size_16); @@ -203,11 +198,11 @@ char* gen_monitor_exit_helper(char *ss, const R_Opnd & input_param1) { ss = test(ss, eax_opnd, eax_opnd); ss = branch8(ss, Condition_NZ, Imm_Opnd(size_8, 0)); char *backpatch_address__fat_monitor = ((char *)ss) - 1; - + // recursion or reservation => dec recursion count - ss = alu(ss, sub_opc, edx_opnd, Imm_Opnd(0x800)); - ss = mov(ss, M_Base_Opnd(ecx_reg,0), edx_opnd); - ss = ret(ss, Imm_Opnd(4)); + ss = alu(ss, sub_opc, edx_opnd, Imm_Opnd(0x800)); + ss = mov(ss, M_Base_Opnd(ecx_reg,0), edx_opnd); + ss = ret(ss, Imm_Opnd(4)); signed offset = (signed)ss - (signed)backpatch_address__thin_monitor - 1; *backpatch_address__thin_monitor = (char)offset; @@ -215,8 +210,8 @@ char* gen_monitor_exit_helper(char *ss, const R_Opnd & input_param1) { ss = ret(ss, Imm_Opnd(4)); - offset = (signed)ss - (signed)backpatch_address__fat_monitor - 1; - *backpatch_address__fat_monitor = (char)offset; + offset = (signed)ss - (signed)backpatch_address__fat_monitor - 1; + *backpatch_address__fat_monitor = (char)offset; #endif diff --git vm/thread/src/thread_helpers_ipf.c vm/thread/src/thread_helpers_ipf.c index 9c8c522..9f852c0 100644 --- vm/thread/src/thread_helpers_ipf.c +++ vm/thread/src/thread_helpers_ipf.c @@ -15,10 +15,6 @@ * limitations under the License. */ -/** - * @author Ivan Volosyuk - */ - /** * @file thread_helpers_ipf.c * Missing definition to ipf compile diff --git vm/thread/src/thread_init.c vm/thread/src/thread_init.c index 5842fc3..ab2f078 100644 --- vm/thread/src/thread_init.c +++ vm/thread/src/thread_init.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/* - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.14 $ - */ - /** * @file thread_init.c * @brief hythread init/shutdown functions @@ -38,7 +33,7 @@ hythread_library_t TM_LIBRARY = NULL; //Thread manager memory pool -apr_pool_t *TM_POOL = NULL; +apr_pool_t *TM_POOL = NULL; //TLS key apr_threadkey_t *TM_THREAD_KEY; @@ -56,7 +51,7 @@ hythread_group_t group_list; hythread_monitor_t *lock_table = NULL; int table_size = 8024; -IDATA groups_count; +IDATA groups_count; static IDATA init_group_list(); static IDATA destroy_group_list(); @@ -132,7 +127,7 @@ void VMCALL hythread_lib_destroy(hythread_library_t lib) { * * @see hythread_attach, hythread_shutdown */ -void VMCALL hythread_init(hythread_library_t lib){ +void VMCALL hythread_init(hythread_library_t lib) { apr_status_t apr_status; IDATA status; hythread_monitor_t *mon; @@ -160,32 +155,33 @@ void VMCALL hythread_init(hythread_library_t lib){ assert(apr_status == APR_SUCCESS); status = hymutex_create(&lib->TM_LOCK, TM_MUTEX_NESTED); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hymutex_create(&TM_START_LOCK, TM_MUTEX_NESTED); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hymutex_create(&FAT_MONITOR_TABLE_LOCK, TM_MUTEX_NESTED); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = init_group_list(); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); // Create default group - hosts any thread crated with NULL group status = hythread_group_create(&TM_DEFAULT_GROUP); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); //nondaemon thread barrier //// lib->nondaemon_thread_count = 0; status = hycond_create(&lib->nondaemon_thread_cond); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); lock_table = (hythread_monitor_t *)malloc(sizeof(hythread_monitor_t)*table_size); assert(lock_table); // init global monitor status=hythread_monitor_init_with_name(&p_global_monitor, 0, "Thread Global Monitor"); - assert (status == TM_ERROR_NONE); - mon = (hythread_monitor_t*)hythread_global(GLOBAL_MONITOR_NAME); + assert(status == TM_ERROR_NONE); + + mon = (hythread_monitor_t*)hythread_global(GLOBAL_MONITOR_NAME); *mon = p_global_monitor; assert(mon); } @@ -244,7 +240,7 @@ IDATA VMCALL hythread_global_unlock() { return hymutex_unlock(TM_LIBRARY->TM_LOCK);; } -hythread_group_t get_java_thread_group(void){ +hythread_group_t get_java_thread_group(void) { return TM_DEFAULT_GROUP; } @@ -257,7 +253,8 @@ static IDATA init_group_list() { //the same pool for them //// dummy = (hythread_group_t)apr_pcalloc(TM_POOL, sizeof(HyThreadGroup)); - assert(dummy); + assert(dummy); + dummy->next = dummy->prev = dummy; group_list = dummy; groups_count = 0; @@ -272,7 +269,8 @@ static IDATA destroy_group_list() { // This method works only if there are no running threads. // there is no good way to kill running threads status=hythread_global_lock(); - if (status != TM_ERROR_NONE) return status; + if (status != TM_ERROR_NONE) return status; + cur = group_list->next; status = TM_ERROR_NONE; @@ -302,9 +300,9 @@ IDATA release_start_lock() { // current scenario use only one global so it works well // need to be hashtable in the future */ -#define TABLE_SIZE 256 -char *names [TABLE_SIZE]; -UDATA data [TABLE_SIZE]; +#define TABLE_SIZE 256 +char *names[TABLE_SIZE]; +UDATA data[TABLE_SIZE]; int size = 0; /* @@ -330,7 +328,7 @@ int find_entry (char* name) { // return new entry index, -1 if failed. int add_entry(char* name) { int index = size++; - if(index >= TABLE_SIZE-1) { + if (index >= TABLE_SIZE-1) { return -1; } names[index] = name; @@ -352,7 +350,7 @@ int add_entry(char* name) { UDATA* VMCALL hythread_global (char* name) { //hythread_monitor_enter(*p_global_monitor); int index = find_entry(name); - if(index == -1) { + if (index == -1) { index = add_entry(name); assert(index >=0); if (index < 0) { @@ -393,7 +391,7 @@ IDATA array_destroy(array_t array) { UDATA array_add(array_t array, void *value) { UDATA index; - if (!array) return 0; + if (!array) return 0; if (array->next_index) { index = array->next_index; } else { @@ -409,7 +407,7 @@ UDATA array_add(array_t array, void *value) { array->next_index = array->entries[index].next_free; array->entries[index].entry = value; - array->size++; + array->size++; return index; } diff --git vm/thread/src/thread_java_attrs.c vm/thread/src/thread_java_attrs.c index 8831979..0f4761c 100644 --- vm/thread/src/thread_java_attrs.c +++ vm/thread/src/thread_java_attrs.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.5 $ - */ - /** * @file thread_java_attrs.c * @brief Java thread priority related functions @@ -37,7 +32,7 @@ */ int jthread_get_priority(jthread java_thread) { hythread_t tm_native_thread = jthread_get_native_thread(java_thread); - return hythread_get_priority(tm_native_thread); + return hythread_get_priority(tm_native_thread); } /** @@ -47,7 +42,7 @@ int jthread_get_priority(jthread java_thread) { * @param[in] priority thread priority * @sa java.lang.Thread.setPriority() */ -IDATA VMCALL jthread_set_priority(jthread java_thread, int priority){ +IDATA VMCALL jthread_set_priority(jthread java_thread, int priority) { hythread_t tm_native_thread = jthread_get_native_thread(java_thread); return hythread_set_priority(tm_native_thread, priority); } diff --git vm/thread/src/thread_java_basic.c vm/thread/src/thread_java_basic.c index e070461..0d580d7 100644 --- vm/thread/src/thread_java_basic.c +++ vm/thread/src/thread_java_basic.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.21 $ - */ - /** * @file thread_java_basic.c * @brief Key threading operations like thread creation and pointer conversion. @@ -91,12 +86,9 @@ int wrapper_proc(void *arg) { // Send Thread Start event. jvmti_send_thread_start_end_event(1); - if(data->tiProc != NULL) - { + if (data->tiProc != NULL) { data->tiProc(data->tiEnv, jni_env, data->tiProcArgs); - } - else - { + } else { // for jthread_create(); (*jni_env) -> CallVoidMethodA(jni_env, java_thread, getRunMethod(jni_env), NULL); } @@ -139,7 +131,7 @@ IDATA jthread_create_with_function(JNIEnv * jni_env, jthread java_thread, jthrea // This is for irregular use. In ordinary live valid jthread instance // contains weak reference associated with it and native thread to reuse. if (tm_native_thread == NULL) { - if( !jthread_thread_init(NULL, jni_env, java_thread, NULL, 0)) { + if ( !jthread_thread_init(NULL, jni_env, java_thread, NULL, 0)) { return TM_ERROR_OUT_OF_MEMORY; } tm_native_thread = vm_jthread_get_tm_data(java_thread); @@ -229,7 +221,7 @@ IDATA jthread_attach(JNIEnv * jni_env, jthread java_thread, jboolean daemon) { * @return the native thread */ jlong jthread_thread_init(jvmti_thread_t *ret_thread, JNIEnv* env, jthread java_thread, jobject weak_ref, jlong old_thread) { - hythread_t tm_native_thread = NULL; + hythread_t tm_native_thread = NULL; jvmti_thread_t tmj_thread; IDATA status; @@ -275,7 +267,7 @@ IDATA jthread_detach(jthread java_thread) { tm_jvmti_thread = hythread_get_private_data(tm_native_thread); jni_env = tm_jvmti_thread->jenv; - if (!tm_jvmti_thread->daemon){ + if (!tm_jvmti_thread->daemon) { countdown_nondaemon_threads(tm_native_thread); } @@ -371,15 +363,15 @@ IDATA jthread_join(jthread java_thread) { IDATA jthread_timed_join(jthread java_thread, jlong millis, jint nanos) { hythread_t tm_native_thread; - IDATA status; + IDATA status; - if (java_thread == NULL){ - return TM_ERROR_NULL_POINTER; - } + if (java_thread == NULL) { + return TM_ERROR_NULL_POINTER; + } tm_native_thread = jthread_get_native_thread(java_thread); - if(!tm_native_thread) { - return TM_ERROR_NONE; - } + if (!tm_native_thread) { + return TM_ERROR_NONE; + } status = hythread_join_interruptable(tm_native_thread, millis, nanos); TRACE(("TM: jthread %d joined %d", hythread_self()->thread_id, tm_native_thread->thread_id)); @@ -390,7 +382,7 @@ IDATA jthread_timed_join(jthread java_thread, jlong millis, jint nanos) { * Lets an another thread to pass. * @sa java.lang.Thread.yield() */ -IDATA jthread_yield(){ +IDATA jthread_yield() { hythread_yield(); return TM_ERROR_NONE; } @@ -477,7 +469,7 @@ IDATA jthread_exception_stop(jthread java_thread, jobject excn) { IDATA jthread_sleep(jlong millis, jint nanos) { hythread_t tm_native_thread = hythread_self(); - IDATA status; + IDATA status; tm_native_thread->state &= ~TM_THREAD_STATE_RUNNABLE; tm_native_thread->state |= TM_THREAD_STATE_WAITING | TM_THREAD_STATE_SLEEPING | @@ -641,7 +633,7 @@ IDATA VMCALL jthread_wait_for_all_nondaemon_threads() { status = hycond_wait(lib->nondaemon_thread_cond, lib->TM_LOCK); //check interruption and other problems TRACE(("TM wait for nondaemons notified, count: %d", lib->nondaemon_thread_count)); - if(status != TM_ERROR_NONE) { + if (status != TM_ERROR_NONE) { hymutex_unlock(lib->TM_LOCK); return status; } @@ -655,7 +647,7 @@ IDATA VMCALL jthread_wait_for_all_nondaemon_threads() { * Auxiliary function to throw java.lang.InterruptedException */ -void throw_interrupted_exception(void){ +void throw_interrupted_exception(void) { jvmti_thread_t tm_java_thread; hythread_t tm_native_thread; @@ -676,7 +668,7 @@ jmethodID getRunMethod(JNIEnv *env) { IDATA status; status=acquire_start_lock(); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); //printf("run method find enter\n"); if (!run_method) { clazz = (*env) -> FindClass(env, "java/lang/Thread"); @@ -684,7 +676,7 @@ jmethodID getRunMethod(JNIEnv *env) { } status=release_start_lock(); //printf("run method find exit\n"); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); return run_method; } @@ -711,7 +703,7 @@ IDATA countdown_nondaemon_threads(hythread_t self) { status = hymutex_lock(lib->TM_LOCK); if (status != TM_ERROR_NONE) return status; - if(lib->nondaemon_thread_count <= 0) { + if (lib->nondaemon_thread_count <= 0) { status = hymutex_unlock(lib->TM_LOCK); if (status != TM_ERROR_NONE) return status; return TM_ERROR_ILLEGAL_STATE; @@ -719,10 +711,10 @@ IDATA countdown_nondaemon_threads(hythread_t self) { TRACE(("TM: nondaemons decreased, thread: %p count: %d\n", self, lib->nondaemon_thread_count)); lib->nondaemon_thread_count--; - if(lib->nondaemon_thread_count <= 1) { + if (lib->nondaemon_thread_count <= 1) { status = hycond_notify_all(lib->nondaemon_thread_cond); TRACE(("TM: nondaemons all dead, thread: %p count: %d\n", self, lib->nondaemon_thread_count)); - if (status != TM_ERROR_NONE){ + if (status != TM_ERROR_NONE) { hymutex_unlock(lib->TM_LOCK); return status; } diff --git vm/thread/src/thread_java_interrupt.c vm/thread/src/thread_java_interrupt.c index da46de1..65bb8a7 100644 --- vm/thread/src/thread_java_interrupt.c +++ vm/thread/src/thread_java_interrupt.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.5 $ - */ - /** * @file thread_java_interrupt.c * @brief Java thread interruption related functions @@ -56,7 +51,7 @@ IDATA VMCALL jthread_interrupt(jthread java_thread) { * @sa java.lang.Thread.isInterrupted() */ jboolean jthread_is_interrupted(jthread java_thread) { - hythread_t tm_native_thread = jthread_get_native_thread(java_thread); + hythread_t tm_native_thread = jthread_get_native_thread(java_thread); return hythread_interrupted(tm_native_thread) > 0; } diff --git vm/thread/src/thread_java_iterator.c vm/thread/src/thread_java_iterator.c index a271684..1bd619d 100644 --- vm/thread/src/thread_java_iterator.c +++ vm/thread/src/thread_java_iterator.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Dmitry Demin - * @version $Revision: 1.1.2.8 $ - */ - /** * @file thread_java_iterator.c * @brief Java thread iterator related functions @@ -66,11 +61,11 @@ jthread VMCALL jthread_iterator_next(jthread_iterator_t *it) { hythread_t tm_native_thread; jvmti_thread_t tm_java_thread; tm_native_thread = hythread_iterator_next((hythread_iterator_t *)it); - while(tm_native_thread!=NULL) + while (tm_native_thread!=NULL) { if (hythread_is_alive(tm_native_thread)) { tm_java_thread = hythread_get_private_data(tm_native_thread); - if (tm_java_thread){ + if (tm_java_thread) { return (jthread)tm_java_thread->thread_object; } } @@ -86,19 +81,17 @@ jthread VMCALL jthread_iterator_next(jthread_iterator_t *it) { * @param[in] iterator */ IDATA VMCALL jthread_iterator_size(jthread_iterator_t iterator) { - jthread res; - IDATA status; - int count=0; - status=jthread_iterator_reset(&iterator); - assert (status == TM_ERROR_NONE); + jthread res; + IDATA status; + int count=0; + status=jthread_iterator_reset(&iterator); + assert(status == TM_ERROR_NONE); + res = jthread_iterator_next(&iterator); + while (res!=NULL) { + count++; res = jthread_iterator_next(&iterator); - while(res!=NULL){ - count++; - res = jthread_iterator_next(&iterator); - } - status=jthread_iterator_reset(&iterator); - assert (status == TM_ERROR_NONE); - return count; + } + status=jthread_iterator_reset(&iterator); + assert(status == TM_ERROR_NONE); + return count; } - - diff --git vm/thread/src/thread_java_monitors.c vm/thread/src/thread_java_monitors.c index 9821de7..1875d0e 100644 --- vm/thread/src/thread_java_monitors.c +++ vm/thread/src/thread_java_monitors.c @@ -14,10 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.16 $ - */ /** * @file thread_java_monitors.c @@ -73,7 +69,7 @@ IDATA VMCALL jthread_monitor_enter(jobject monitor) { hythread_thin_monitor_t *lockword; IDATA status; // should be moved to event handler - apr_time_t enter_begin; + apr_time_t enter_begin; jvmti_thread_t tm_java_thread; hythread_t tm_native_thread; int disable_count; @@ -82,20 +78,20 @@ IDATA VMCALL jthread_monitor_enter(jobject monitor) { hythread_suspend_disable(); lockword = vm_object_get_lockword_addr(monitor); status = hythread_thin_monitor_try_enter(lockword); - if(status != TM_ERROR_EBUSY) { + if (status != TM_ERROR_EBUSY) { goto entered; } ///////// #ifdef LOCK_RESERVATION -// busy unreserve lock before blocking and inflating + // busy unreserve lock before blocking and inflating while (TM_ERROR_NONE !=unreserve_lock(lockword)) { hythread_yield(); hythread_safe_point(); - lockword = vm_object_get_lockword_addr(monitor); + lockword = vm_object_get_lockword_addr(monitor); } status = hythread_thin_monitor_try_enter(lockword); - if(status != TM_ERROR_EBUSY) { + if (status != TM_ERROR_EBUSY) { goto entered; } #endif //LOCK_RESERVATION @@ -104,7 +100,7 @@ IDATA VMCALL jthread_monitor_enter(jobject monitor) { tm_native_thread->state |= TM_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER; // should be moved to event handler - if (ti_is_enabled()){ + if (ti_is_enabled()) { enter_begin = apr_time_now(); disable_count = reset_suspend_disable(); set_contended_monitor(monitor); @@ -133,12 +129,12 @@ IDATA VMCALL jthread_monitor_enter(jobject monitor) { hythread_yield(); } assert(status == TM_ERROR_NONE); - if(!is_fat_lock(*lockword)) { + if (!is_fat_lock(*lockword)) { inflate_lock(lockword); } // do all ti staff here contended_entered: - if (ti_is_enabled()){ + if (ti_is_enabled()) { disable_count = reset_suspend_disable(); jvmti_send_contended_enter_or_entered_monitor_event(monitor, 0); set_suspend_disable(disable_count); @@ -173,7 +169,7 @@ IDATA VMCALL jthread_monitor_try_enter(jobject monitor) { status = hythread_thin_monitor_try_enter(lockword); hythread_suspend_enable(); - if (status == TM_ERROR_NONE && ti_is_enabled()){ + if (status == TM_ERROR_NONE && ti_is_enabled()) { add_owned_monitor(monitor); } return status; @@ -195,7 +191,7 @@ IDATA VMCALL jthread_monitor_exit(jobject monitor) { lockword = vm_object_get_lockword_addr(monitor); status = hythread_thin_monitor_exit(lockword); hythread_suspend_enable(); - if (status == TM_ERROR_NONE && ti_is_enabled()){ + if (status == TM_ERROR_NONE && ti_is_enabled()) { remove_owned_monitor(monitor); } if (status == TM_ERROR_ILLEGAL_STATE) { @@ -303,9 +299,9 @@ IDATA VMCALL jthread_monitor_timed_wait(jobject monitor, jlong millis, jint nano lockword = vm_object_get_lockword_addr(monitor); if (!is_fat_lock(*lockword)) { if (!owns_thin_lock(hythread_self(), *lockword)) { - TRACE(("ILLEGAL_STATE wait %x\n", lockword)); - hythread_suspend_enable(); - return TM_ERROR_ILLEGAL_STATE; + TRACE(("ILLEGAL_STATE wait %x\n", lockword)); + hythread_suspend_enable(); + return TM_ERROR_ILLEGAL_STATE; } inflate_lock(lockword); } @@ -328,7 +324,8 @@ IDATA VMCALL jthread_monitor_timed_wait(jobject monitor, jlong millis, jint nano tm_native_thread->state &= ~TM_THREAD_STATE_RUNNABLE; tm_native_thread->state |= TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT; - if((millis > 0) || (nanos > 0)) { + + if ((millis > 0) || (nanos > 0)) { tm_native_thread->state |= TM_THREAD_STATE_WAITING_WITH_TIMEOUT; } else { tm_native_thread->state |= TM_THREAD_STATE_WAITING_INDEFINITELY; @@ -338,7 +335,7 @@ IDATA VMCALL jthread_monitor_timed_wait(jobject monitor, jlong millis, jint nano tm_native_thread->state &= ~(TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT); - if((millis > 0) || (nanos > 0)) { + if ((millis > 0) || (nanos > 0)) { tm_native_thread->state &= ~TM_THREAD_STATE_WAITING_WITH_TIMEOUT; } else { tm_native_thread->state &= ~TM_THREAD_STATE_WAITING_INDEFINITELY; @@ -346,7 +343,7 @@ IDATA VMCALL jthread_monitor_timed_wait(jobject monitor, jlong millis, jint nano tm_native_thread->state |= TM_THREAD_STATE_RUNNABLE; hythread_suspend_enable(); - if (ti_is_enabled()){ + if (ti_is_enabled()) { add_owned_monitor(monitor); disable_count = reset_suspend_disable(); jvmti_send_contended_enter_or_entered_monitor_event(monitor, 0); @@ -360,7 +357,7 @@ IDATA VMCALL jthread_monitor_timed_wait(jobject monitor, jlong millis, jint nano return status; } -void add_owned_monitor(jobject monitor){ +void add_owned_monitor(jobject monitor) { hythread_t tm_native_thread = hythread_self(); jvmti_thread_t tm_java_thread = hythread_get_private_data(tm_native_thread); int disable_status; @@ -379,7 +376,7 @@ void add_owned_monitor(jobject monitor){ } - if (!tm_java_thread->owned_monitors){ + if (!tm_java_thread->owned_monitors) { tm_java_thread->owned_monitors = apr_pcalloc(tm_java_thread->pool, MAX_OWNED_MONITOR_NUMBER * sizeof(jobject)); assert(tm_java_thread->owned_monitors); @@ -393,7 +390,7 @@ void add_owned_monitor(jobject monitor){ tm_java_thread->owned_monitors_nmb++; } -void remove_owned_monitor(jobject monitor){ +void remove_owned_monitor(jobject monitor) { int i,j, disable_status; hythread_t tm_native_thread = hythread_self(); jvmti_thread_t tm_java_thread = hythread_get_private_data(tm_native_thread); @@ -401,12 +398,12 @@ void remove_owned_monitor(jobject monitor){ TRACE(("TM: remove owned monitor: %x", monitor)); if (!tm_java_thread) return; - for (i = tm_java_thread->owned_monitors_nmb - 1; i >= 0; i--){ - if (vm_objects_are_equal(tm_java_thread->owned_monitors[i], monitor)){ + for (i = tm_java_thread->owned_monitors_nmb - 1; i >= 0; i--) { + if (vm_objects_are_equal(tm_java_thread->owned_monitors[i], monitor)) { disable_status = reset_suspend_disable(); (*(tm_java_thread->jenv))->DeleteGlobalRef(tm_java_thread->jenv, tm_java_thread->owned_monitors[i]); set_suspend_disable(disable_status); - for (j = i; j < tm_java_thread->owned_monitors_nmb - 1; j++){ + for (j = i; j < tm_java_thread->owned_monitors_nmb - 1; j++) { tm_java_thread->owned_monitors[j] = tm_java_thread->owned_monitors[j + 1]; } tm_java_thread->owned_monitors_nmb--; @@ -416,7 +413,7 @@ void remove_owned_monitor(jobject monitor){ //assert(0); monitor - it is no valid monitor } -void set_contended_monitor(jobject monitor){ +void set_contended_monitor(jobject monitor) { hythread_t tm_native_thread = hythread_self(); IDATA suspend_status; @@ -430,7 +427,7 @@ void set_contended_monitor(jobject monitor){ set_suspend_disable(suspend_status); } -void set_wait_monitor(jobject monitor){ +void set_wait_monitor(jobject monitor) { hythread_t tm_native_thread = hythread_self(); IDATA suspend_status; @@ -439,7 +436,7 @@ void set_wait_monitor(jobject monitor){ if (!tm_java_thread) return; suspend_status = reset_suspend_disable(); - assert (suspend_status == TM_ERROR_NONE); + assert(suspend_status == TM_ERROR_NONE); tm_java_thread->wait_monitor = (*(tm_java_thread->jenv))->NewGlobalRef(tm_java_thread->jenv, monitor); set_suspend_disable(suspend_status); } diff --git vm/thread/src/thread_java_park.c vm/thread/src/thread_java_park.c index 19aaad1..59865c7 100644 --- vm/thread/src/thread_java_park.c +++ vm/thread/src/thread_java_park.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.6 $ - */ - /** * @file thread_java_park.c * @brief Java thread park/unpark functions @@ -39,7 +34,7 @@ * @sa java.util.concurrent.locks.LockSupport.park() */ IDATA VMCALL jthread_park() { - return hythread_park(0,0); + return hythread_park(0, 0); } /** @@ -71,12 +66,10 @@ IDATA VMCALL jthread_timed_park(jlong millis, jint nanos) { * @sa java.util.concurrent.locks.LockSupport.unpark() */ IDATA VMCALL jthread_unpark(jthread java_thread) { + hythread_t tm_native_thread; - hythread_t tm_native_thread; - - assert(java_thread); + assert(java_thread); tm_native_thread = jthread_get_native_thread(java_thread); - hythread_unpark(tm_native_thread); return TM_ERROR_NONE; diff --git vm/thread/src/thread_java_suspend.c vm/thread/src/thread_java_suspend.c index 87c8949..eadbab6 100644 --- vm/thread/src/thread_java_suspend.c +++ vm/thread/src/thread_java_suspend.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.5 $ - */ - /** * @file thread_java_suspend.c * @brief Java thread suspend/resume functions @@ -41,7 +36,7 @@ */ IDATA VMCALL jthread_resume(jthread java_thread) { hythread_t tm_native_thread = vm_jthread_get_tm_data(java_thread); - hythread_resume(tm_native_thread); + hythread_resume(tm_native_thread); return TM_ERROR_NONE; } @@ -54,13 +49,12 @@ IDATA VMCALL jthread_resume(jthread java_thread) { * @sa JVMTI::ResumeThreadList() */ IDATA VMCALL jthread_resume_all(jvmtiError* results, jint count, const jthread* thread_list) { - - int i; + int i; - for (i = 0; i < count; i++){ - results[i] = (jvmtiError)jthread_resume(thread_list[i]); - } - return TM_ERROR_NONE; + for (i = 0; i < count; i++) { + results[i] = (jvmtiError)jthread_resume(thread_list[i]); + } + return TM_ERROR_NONE; } /** @@ -82,9 +76,8 @@ IDATA VMCALL jthread_resume_all(jvmtiError* results, jint count, const jthread* * @sa java.lang.Thread.suspend(), JVMTI::SuspendThread() */ IDATA VMCALL jthread_suspend(jthread java_thread) { - hythread_t tm_native_thread = vm_jthread_get_tm_data(java_thread); - return hythread_suspend_other(tm_native_thread); - + hythread_t tm_native_thread = vm_jthread_get_tm_data(java_thread); + return hythread_suspend_other(tm_native_thread); } /** @@ -108,10 +101,10 @@ IDATA VMCALL jthread_suspend(jthread java_thread) { * @sa JVMTI::SuspendThreadList() */ IDATA VMCALL jthread_suspend_all(jvmtiError* results, jint count, const jthread* thread_list) { - int i; - for (i = 0; i < count; i++){ - results[i] = (jvmtiError)jthread_suspend(thread_list[i]); - } + int i; + for (i = 0; i < count; i++) { + results[i] = (jvmtiError)jthread_suspend(thread_list[i]); + } return TM_ERROR_NONE; } diff --git vm/thread/src/thread_native_attrs.c vm/thread/src/thread_native_attrs.c index 42b2f63..556aa3b 100644 --- vm/thread/src/thread_native_attrs.c +++ vm/thread/src/thread_native_attrs.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_native_attrs.c * @brief Hythread priority related functions @@ -44,7 +39,7 @@ * * */ -IDATA VMCALL hythread_set_priority(hythread_t thread, UDATA priority){ +IDATA VMCALL hythread_set_priority(hythread_t thread, UDATA priority) { apr_status_t apr_status = apr_thread_set_priority(thread->os_handle, priority); if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); thread->priority = priority; diff --git vm/thread/src/thread_native_basic.c vm/thread/src/thread_native_basic.c index ab5b6a5..d629dd1 100644 --- vm/thread/src/thread_native_basic.c +++ vm/thread/src/thread_native_basic.c @@ -46,14 +46,13 @@ static void reset_thread(hythread_t thread); static IDATA register_to_group(hythread_t thread, hythread_group_t group); //#define APR_TLS_USE 1 -#define NAKED __declspec( naked ) +#define NAKED __declspec(naked) -#if !defined (APR_TLS_USE ) && !defined (FS14_TLS_USE) +#if !defined (APR_TLS_USE) && !defined (FS14_TLS_USE) #ifdef PLATFORM_POSIX __thread hythread_t tm_self_tls = NULL; #else __declspec(thread) hythread_t tm_self_tls = NULL; - #endif #endif @@ -279,7 +278,7 @@ void VMCALL hythread_detach(hythread_t thread) { // Acquire global TM lock to prevent concurrent access to thread list status = hythread_global_lock(NULL); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); // No actions required in case the specified thread is detached already. if (thread->group != NULL) { @@ -428,7 +427,7 @@ IDATA thread_sleep_impl(I_64 millis, IDATA nanos, IDATA interruptable) { hythread_t thread = tm_self_tls; - if(nanos == 0 && millis == 0) { + if (nanos == 0 && millis == 0) { hythread_yield(); return TM_ERROR_NONE; } @@ -503,7 +502,7 @@ hythread_t VMCALL hythread_get_thread(IDATA id) { * @param[in] t thread those private data to get * @return pointer to thread private data */ -void* VMCALL hythread_get_private_data(hythread_t t){ +void* VMCALL hythread_get_private_data(hythread_t t) { assert(t); return t->private_data; } @@ -513,7 +512,7 @@ void* VMCALL hythread_get_private_data(hythread_t t){ * @param t thread * @param data pointer to private data */ -IDATA VMCALL hythread_set_private_data(hythread_t t, void* data) { +IDATA VMCALL hythread_set_private_data(hythread_t t, void* data) { assert(t); t->private_data = data; return TM_ERROR_NONE; @@ -561,8 +560,8 @@ IDATA VMCALL hythread_cancel_all(hythread_group_t group) { } iter = hythread_iterator_create(group); - while((next = hythread_iterator_next (&iter)) != NULL) { - if(next != self) { + while ((next = hythread_iterator_next (&iter)) != NULL) { + if (next != self) { hythread_cancel(next); //since this method being used at shutdown it does not //make any sense to exit on error, but continue terminating threads @@ -638,7 +637,7 @@ static hythread_t allocate_thread() { IDATA status; apr_status = apr_pool_create(&pool, TM_POOL); - if((apr_status != APR_SUCCESS) || (pool == NULL)) return NULL; + if ((apr_status != APR_SUCCESS) || (pool == NULL)) return NULL; ptr = (hythread_t )apr_pcalloc(pool, sizeof(HyThread)); if (ptr == NULL) return NULL; @@ -653,15 +652,15 @@ static hythread_t allocate_thread() { ptr->suspend_request = 0; ptr->suspend_disable_count = 0; status = hylatch_create(&ptr->join_event, 1); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hylatch_create(&ptr->safe_region_event, 1); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hysem_create(&ptr->resume_event, 0, 1); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hymutex_create(&ptr->mutex, TM_MUTEX_NESTED); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hycond_create(&ptr->condition); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); ptr->state = TM_THREAD_STATE_ALLOCATED; return ptr; @@ -685,11 +684,11 @@ static void reset_thread(hythread_t thread) { thread->suspend_disable_count = 0; thread->safepoint_callback = NULL; status = hylatch_set(thread->join_event, 1); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hylatch_set(thread->safe_region_event, 1); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); status = hysem_set(thread->resume_event, 0); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); thread->state = TM_THREAD_STATE_ALLOCATED; } @@ -716,7 +715,7 @@ static void* APR_THREAD_FUNC thread_start_proc(apr_thread_t* thd, void *p_args) // Also, should it be executed under TM global lock? thread->os_handle = thd; // DELETE? status = hythread_set_priority(thread, thread->priority); - //assert (status == TM_ERROR_NONE);//now we down - fixme + //assert(status == TM_ERROR_NONE);//now we down - fixme thread->state |= TM_THREAD_STATE_RUNNABLE; // Do actual call of the thread body supplied by the user. @@ -724,7 +723,7 @@ static void* APR_THREAD_FUNC thread_start_proc(apr_thread_t* thd, void *p_args) // Shutdown sequence. status = hythread_global_lock(NULL); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); assert(hythread_is_suspend_enabled()); thread->state = TM_THREAD_STATE_TERMINATED | (TM_THREAD_STATE_INTERRUPTED & thread->state); thread->exit_value = 0; @@ -734,7 +733,7 @@ static void* APR_THREAD_FUNC thread_start_proc(apr_thread_t* thd, void *p_args) hylatch_count_down(thread->join_event); status = hythread_global_unlock(NULL); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); // TODO: It seems it is there is no need to call apr_thread_exit. // Current thread should automatically exit upon returning from this function. diff --git vm/thread/src/thread_native_condvar.c vm/thread/src/thread_native_condvar.c index 6106086..81b3d04 100644 --- vm/thread/src/thread_native_condvar.c +++ vm/thread/src/thread_native_condvar.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.8 $ - */ - /** * @file thread_native_condvar.c * @brief Hythread condvar related functions @@ -48,41 +43,40 @@ IDATA VMCALL hycond_create (hycond_t *cond) { } IDATA condvar_wait_impl(hycond_t cond, hymutex_t mutex, I_64 ms, IDATA nano, IDATA interruptable) { - apr_status_t apr_status; - int disable_count; - hythread_t this_thread; + apr_status_t apr_status; + int disable_count; + hythread_t this_thread; this_thread = tm_self_tls; // Store provided cond into current thread cond this_thread->current_condition = interruptable ? cond : NULL; - // check interrupted flag + // check interrupted flag if (interruptable && (this_thread->state & TM_THREAD_STATE_INTERRUPTED)) { // clean interrupted flag this_thread->state &= (~TM_THREAD_STATE_INTERRUPTED); return TM_ERROR_INTERRUPT; } - disable_count = reset_suspend_disable(); - // Delegate to OS wait + disable_count = reset_suspend_disable(); + // Delegate to OS wait apr_status = (!ms && !nano)? apr_thread_cond_wait((apr_thread_cond_t*)cond, (apr_thread_mutex_t*)mutex): apr_thread_cond_timedwait ((apr_thread_cond_t*)cond, (apr_thread_mutex_t*)mutex, ms*1000 + ((nano < 1000) ? 1 : (nano / 1000))); set_suspend_disable(disable_count); - this_thread->current_condition = NULL; + this_thread->current_condition = NULL; // check interrupted flag if (interruptable && (this_thread->state & TM_THREAD_STATE_INTERRUPTED)) { // clean interrupted flag this_thread->state &= (~TM_THREAD_STATE_INTERRUPTED); - return TM_ERROR_INTERRUPT; + return TM_ERROR_INTERRUPT; } - return CONVERT_ERROR(apr_status); - + return CONVERT_ERROR(apr_status); } /** @@ -150,8 +144,8 @@ IDATA VMCALL hycond_notify (hycond_t cond) { * @sa apr_thread_cond_broadcast() */ IDATA VMCALL hycond_notify_all (hycond_t cond) { - apr_status_t apr_status = apr_thread_cond_broadcast((apr_thread_cond_t*)cond); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + apr_status_t apr_status = apr_thread_cond_broadcast((apr_thread_cond_t*)cond); + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); return TM_ERROR_NONE; } @@ -162,14 +156,13 @@ IDATA VMCALL hycond_notify_all (hycond_t cond) { * @sa apr_thread_cond_destroy() */ IDATA VMCALL hycond_destroy (hycond_t cond) { - apr_status_t apr_status; + apr_status_t apr_status; apr_pool_t *pool = apr_thread_cond_pool_get ((apr_thread_cond_t*)cond); - if(pool != get_local_pool()) { + if (pool != get_local_pool()) { return local_pool_cleanup_register(hycond_destroy, cond); } apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)cond); return CONVERT_ERROR(apr_status); - } //@} diff --git vm/thread/src/thread_native_fat_monitor.c vm/thread/src/thread_native_fat_monitor.c diff --git vm/thread/src/thread_native_groups.c vm/thread/src/thread_native_groups.c index cda40a3..e716658 100644 --- vm/thread/src/thread_native_groups.c +++ vm/thread/src/thread_native_groups.c @@ -45,16 +45,16 @@ IDATA VMCALL hythread_group_create(hythread_group_t *group) { hythread_t dummy; apr_pool_t *group_pool; apr_status_t apr_status; - IDATA status; + IDATA status; apr_status = apr_pool_create(&(group_pool), TM_POOL); if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); status=hythread_global_lock(); - if (status != TM_ERROR_NONE) return status; + if (status != TM_ERROR_NONE) return status; (*group) = (hythread_group_t )apr_palloc(group_pool, sizeof(HyThreadGroup)); - if (! *group){ + if (!*group) { hythread_global_unlock(); return TM_ERROR_OUT_OF_MEMORY; } @@ -69,7 +69,7 @@ IDATA VMCALL hythread_group_create(hythread_group_t *group) { //dummy thread as the head of the group //// dummy = (hythread_t)apr_pcalloc(group_pool, sizeof(HyThread)); - if (! dummy){ + if (!dummy) { hythread_global_unlock(); return TM_ERROR_OUT_OF_MEMORY; } @@ -125,7 +125,7 @@ IDATA VMCALL hythread_group_release(hythread_group_t group) { return status; (*size) = groups_count; array_for_list=(hythread_group_t*)malloc(sizeof(hythread_group_t)*groups_count); - if(array_for_list==NULL) + if (array_for_list==NULL) { status=hythread_global_unlock(); return TM_ERROR_OUT_OF_MEMORY; diff --git vm/thread/src/thread_native_interrupt.c vm/thread/src/thread_native_interrupt.c index 91a3008..9c6a066 100644 --- vm/thread/src/thread_native_interrupt.c +++ vm/thread/src/thread_native_interrupt.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_native_interrupt.c * @brief Hythread interruption related functions @@ -82,7 +77,7 @@ UDATA VMCALL hythread_clear_interrupted_other(hythread_t thread) { * @return previous value of interrupted flag: non-zero if the thread had been interrupted. */ UDATA VMCALL hythread_clear_interrupted() { - return hythread_clear_interrupted_other(tm_self_tls); + return hythread_clear_interrupted_other(tm_self_tls); } /** @@ -92,7 +87,7 @@ UDATA VMCALL hythread_clear_interrupted() { * @return 0 if not interrupted, non-zero if interrupted */ UDATA VMCALL hythread_interrupted(hythread_t thread) { - int interrupted = thread->state & TM_THREAD_STATE_INTERRUPTED; - return interrupted?TM_ERROR_INTERRUPT:TM_ERROR_NONE; + int interrupted = thread->state & TM_THREAD_STATE_INTERRUPTED; + return interrupted?TM_ERROR_INTERRUPT:TM_ERROR_NONE; } diff --git vm/thread/src/thread_native_iterator.c vm/thread/src/thread_native_iterator.c index b934eda..38d2660 100644 --- vm/thread/src/thread_native_iterator.c +++ vm/thread/src/thread_native_iterator.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.6 $ - */ - /** * @file thread_native_iterator.c * @brief Hythread iterator related functions @@ -38,9 +33,9 @@ * @param[in] group thread group number */ hythread_iterator_t VMCALL hythread_iterator_create(hythread_group_t group) { - IDATA status; - status=hythread_global_lock(); - assert (status == TM_ERROR_NONE); + IDATA status; + status = hythread_global_lock(); + assert(status == TM_ERROR_NONE); group = (group)?group:TM_DEFAULT_GROUP; TRACE(("TM iterator created: %p head: %p", group->thread_list, group->thread_list->next)); return (hythread_iterator_t)group->thread_list->next; diff --git vm/thread/src/thread_native_latch.c vm/thread/src/thread_native_latch.c index 1998b5c..5468c88 100644 --- vm/thread/src/thread_native_latch.c +++ vm/thread/src/thread_native_latch.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_native_latch.c * @brief Hythread latch related functions @@ -48,22 +43,22 @@ IDATA VMCALL hylatch_create(hylatch_t *latch, IDATA count) { hylatch_t l; apr_pool_t *pool = get_local_pool(); - apr_status_t apr_status; - - l = apr_palloc(pool, sizeof(HyLatch)); - if(l == NULL) { - return TM_ERROR_OUT_OF_MEMORY; - } + apr_status_t apr_status; + + l = apr_palloc(pool, sizeof(HyLatch)); + if (l == NULL) { + return TM_ERROR_OUT_OF_MEMORY; + } apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(l->mutex), TM_MUTEX_DEFAULT, pool); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(l->condition), pool); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); - l->count = count; - l->pool = pool; - *latch = l; + l->count = count; + l->pool = pool; + *latch = l; return TM_ERROR_NONE; } @@ -72,20 +67,20 @@ IDATA VMCALL hylatch_create(hylatch_t *latch, IDATA count) { static IDATA latch_wait_impl(hylatch_t latch, I_64 ms, IDATA nano, IDATA interruptable) { IDATA status; - status = hymutex_lock(latch->mutex); - if (status != TM_ERROR_NONE) return status; - while (latch->count) { - status = condvar_wait_impl(latch->condition, latch->mutex, ms, nano, interruptable); - //check interruption and other problems - if (status != TM_ERROR_NONE) { - hymutex_unlock(latch->mutex); - return status; - } + status = hymutex_lock(latch->mutex); + if (status != TM_ERROR_NONE) return status; + while (latch->count) { + status = condvar_wait_impl(latch->condition, latch->mutex, ms, nano, interruptable); + //check interruption and other problems + if (status != TM_ERROR_NONE) { + hymutex_unlock(latch->mutex); + return status; + } if (ms || nano) break; - } - status = hymutex_unlock(latch->mutex); - if (status != TM_ERROR_NONE) return status; + } + status = hymutex_unlock(latch->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -112,7 +107,7 @@ IDATA VMCALL hylatch_wait(hylatch_t latch) { * @return * TM_NO_ERROR on success */ -IDATA VMCALL hylatch_wait_timed(hylatch_t latch, I_64 ms, IDATA nano){ +IDATA VMCALL hylatch_wait_timed(hylatch_t latch, I_64 ms, IDATA nano) { return latch_wait_impl(latch, ms, nano, WAIT_NONINTERRUPTABLE); } @@ -128,7 +123,7 @@ IDATA VMCALL hylatch_wait_timed(hylatch_t latch, I_64 ms, IDATA nano){ * TM_NO_ERROR on success * TM_THREAD_INTERRUPTED in case thread was interrupted during wait. */ -IDATA VMCALL hylatch_wait_interruptable(hylatch_t latch, I_64 ms, IDATA nano){ +IDATA VMCALL hylatch_wait_interruptable(hylatch_t latch, I_64 ms, IDATA nano) { return latch_wait_impl(latch, ms, nano, WAIT_INTERRUPTABLE); } @@ -139,13 +134,13 @@ IDATA VMCALL hylatch_wait_interruptable(hylatch_t latch, I_64 ms, IDATA nano){ * @param[in] count new count value */ IDATA VMCALL hylatch_set(hylatch_t latch, IDATA count) { - IDATA status; - - status = hymutex_lock(latch->mutex); - if (status != TM_ERROR_NONE) return status; - latch->count = count; - status = hymutex_unlock(latch->mutex); - if (status != TM_ERROR_NONE) return status; + IDATA status; + + status = hymutex_lock(latch->mutex); + if (status != TM_ERROR_NONE) return status; + latch->count = count; + status = hymutex_unlock(latch->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -157,27 +152,27 @@ IDATA VMCALL hylatch_set(hylatch_t latch, IDATA count) { * @param[in] latch the latch * @sa java.util.concurrent.CountDownLatch.countDown() */ -IDATA VMCALL hylatch_count_down(hylatch_t latch){ - IDATA status; - - status = hymutex_lock(latch->mutex); - if (status != TM_ERROR_NONE) return status; - if(latch->count <= 0) { - status = hymutex_unlock(latch->mutex); - if (status != TM_ERROR_NONE) return status; - return TM_ERROR_ILLEGAL_STATE; - } - latch->count--; - if(latch->count == 0) { - status = hycond_notify_all(latch->condition); - if (status != TM_ERROR_NONE){ - hymutex_unlock(latch->mutex); - return status; - } - } - +IDATA VMCALL hylatch_count_down(hylatch_t latch) { + IDATA status; + + status = hymutex_lock(latch->mutex); + if (status != TM_ERROR_NONE) return status; + if (latch->count <= 0) { status = hymutex_unlock(latch->mutex); if (status != TM_ERROR_NONE) return status; + return TM_ERROR_ILLEGAL_STATE; + } + latch->count--; + if (latch->count == 0) { + status = hycond_notify_all(latch->condition); + if (status != TM_ERROR_NONE) { + hymutex_unlock(latch->mutex); + return status; + } + } + + status = hymutex_unlock(latch->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -190,14 +185,14 @@ IDATA VMCALL hylatch_count_down(hylatch_t latch){ * @param[out] count count value * @param[in] latch the latch */ -IDATA VMCALL hylatch_get_count(IDATA *count, hylatch_t latch){ - IDATA status; - - status = hymutex_lock(latch->mutex); - if (status != TM_ERROR_NONE) return status; - *count = latch->count; - status = hymutex_unlock(latch->mutex); - if (status != TM_ERROR_NONE) return status; +IDATA VMCALL hylatch_get_count(IDATA *count, hylatch_t latch) { + IDATA status; + + status = hymutex_lock(latch->mutex); + if (status != TM_ERROR_NONE) return status; + *count = latch->count; + status = hymutex_unlock(latch->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -206,9 +201,9 @@ IDATA VMCALL hylatch_get_count(IDATA *count, hylatch_t latch){ * * @param[in] latch the latch */ -IDATA VMCALL hylatch_destroy(hylatch_t latch){ +IDATA VMCALL hylatch_destroy(hylatch_t latch) { apr_pool_t *pool = latch->pool; - if(pool != get_local_pool()) { + if (pool != get_local_pool()) { return local_pool_cleanup_register(hylatch_destroy, latch); } apr_thread_mutex_destroy((apr_thread_mutex_t*)latch->mutex); diff --git vm/thread/src/thread_native_mutex.c vm/thread/src/thread_native_mutex.c index 7a98b2d..c271fdd 100644 --- vm/thread/src/thread_native_mutex.c +++ vm/thread/src/thread_native_mutex.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.8 $ - */ - /** * @file thread_native_mutex.c * @brief Hythread mutex related functions @@ -53,11 +48,10 @@ */ IDATA VMCALL hymutex_create (hymutex_t *mutex, UDATA flags) { apr_pool_t *pool = get_local_pool(); - apr_status_t apr_status; + apr_status_t apr_status; apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)mutex, flags, pool); - - return CONVERT_ERROR(apr_status); + return CONVERT_ERROR(apr_status); } /** @@ -68,8 +62,8 @@ IDATA VMCALL hymutex_create (hymutex_t *mutex, UDATA flags) { * @sa apr_thread_mutex_lock() */ IDATA VMCALL hymutex_lock(hymutex_t mutex) { - apr_status_t apr_status; - apr_status = apr_thread_mutex_lock((apr_thread_mutex_t*)mutex); + apr_status_t apr_status; + apr_status = apr_thread_mutex_lock((apr_thread_mutex_t*)mutex); return CONVERT_ERROR(apr_status); } @@ -91,8 +85,8 @@ IDATA VMCALL hymutex_trylock (hymutex_t mutex) { * @sa apr_thread_mutex_unlock() */ IDATA VMCALL hymutex_unlock (hymutex_t mutex) { - apr_status_t apr_status = apr_thread_mutex_unlock((apr_thread_mutex_t*)mutex); - assert(apr_status == APR_SUCCESS); + apr_status_t apr_status = apr_thread_mutex_unlock((apr_thread_mutex_t*)mutex); + assert(apr_status == APR_SUCCESS); return CONVERT_ERROR(apr_status); } @@ -103,9 +97,9 @@ IDATA VMCALL hymutex_unlock (hymutex_t mutex) { * @sa apr_thread_mutex_destroy() */ IDATA VMCALL hymutex_destroy (hymutex_t mutex) { - apr_pool_t *pool = apr_thread_mutex_pool_get ((apr_thread_mutex_t*)mutex); - apr_status_t apr_status; - if(pool != get_local_pool()) { + apr_pool_t *pool = apr_thread_mutex_pool_get ((apr_thread_mutex_t*)mutex); + apr_status_t apr_status; + if (pool != get_local_pool()) { return local_pool_cleanup_register(hymutex_destroy, mutex); } apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)mutex); diff --git vm/thread/src/thread_native_park.c vm/thread/src/thread_native_park.c index b3654a1..40fc9af 100644 --- vm/thread/src/thread_native_park.c +++ vm/thread/src/thread_native_park.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_native_park.c * @brief Hythread park/unpark related functions @@ -84,7 +79,7 @@ IDATA VMCALL hythread_park(I_64 millis, IDATA nanos) { * @see hythread_park */ void VMCALL hythread_unpark(hythread_t thread) { - if(thread == NULL) { + if (thread == NULL) { return; } diff --git vm/thread/src/thread_native_semaphore.c vm/thread/src/thread_native_semaphore.c index 6b8d103..14533c4 100644 --- vm/thread/src/thread_native_semaphore.c +++ vm/thread/src/thread_native_semaphore.c @@ -38,22 +38,22 @@ IDATA VMCALL hysem_create(hysem_t *sem, UDATA initial_count, UDATA max_count) { hysem_t l; apr_pool_t *pool = get_local_pool(); - apr_status_t apr_status; - - l = apr_palloc(pool, sizeof(HySemaphore)); - if(l == NULL) { - return TM_ERROR_OUT_OF_MEMORY; - } + apr_status_t apr_status; + + l = apr_palloc(pool, sizeof(HySemaphore)); + if (l == NULL) { + return TM_ERROR_OUT_OF_MEMORY; + } apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(l->mutex), TM_MUTEX_DEFAULT, pool); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(l->condition), pool); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); - l->count = initial_count; - l->max_count = max_count; - l->pool = pool; - *sem = l; + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + l->count = initial_count; + l->max_count = max_count; + l->pool = pool; + *sem = l; return TM_ERROR_NONE; } @@ -61,33 +61,32 @@ IDATA VMCALL hysem_create(hysem_t *sem, UDATA initial_count, UDATA max_count) { IDATA sem_wait_impl(hysem_t sem, I_64 ms, IDATA nano, IDATA interruptable) { IDATA status; - status = hymutex_lock(sem->mutex); - if (status != TM_ERROR_NONE) return status; + status = hymutex_lock(sem->mutex); + if (status != TM_ERROR_NONE) return status; //printf("wait %x %d\n", sem, sem->count); - //fflush(NULL); - while (sem->count<=0) { - status = condvar_wait_impl(sem->condition, sem->mutex, ms, nano, interruptable); - //check interruption and timeout - if(status != TM_ERROR_NONE) { - hymutex_unlock(sem->mutex); - return status; - } + //fflush(NULL); + while (sem->count <= 0) { + status = condvar_wait_impl(sem->condition, sem->mutex, ms, nano, interruptable); + //check interruption and timeout + if (status != TM_ERROR_NONE) { + hymutex_unlock(sem->mutex); + return status; + } if (nano || ms) break; - } + } //should we check here if timeout is not supposed to happen - if(sem->count==0 /*&& (ms || nano)*/) - { - if (ms || nano) { - hymutex_unlock(sem->mutex); - return TM_ERROR_TIMEOUT; - } else { - assert(0); - } + if (sem->count == 0 /*&& (ms || nano)*/) { + if (ms || nano) { + hymutex_unlock(sem->mutex); + return TM_ERROR_TIMEOUT; + } else { + assert(0); } - sem->count--; - status = hymutex_unlock(sem->mutex); - if (status != TM_ERROR_NONE) return status; + } + sem->count--; + status = hymutex_unlock(sem->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -147,24 +146,24 @@ IDATA VMCALL hysem_wait_interruptable(hysem_t sem, I_64 ms, IDATA nano) { * @see hysem_init, hysem_destroy, hysem_wait */ IDATA VMCALL hysem_post(hysem_t sem) { - IDATA status; + IDATA status; //printf("post %x %d\n", sem, sem->count); -// fflush(NULL); - status = hymutex_lock(sem->mutex); - if (status != TM_ERROR_NONE) return status; - if(sem->count >= sem->max_count) { - hymutex_unlock(sem->mutex); + //fflush(NULL); + status = hymutex_lock(sem->mutex); + if (status != TM_ERROR_NONE) return status; + if (sem->count >= sem->max_count) { + hymutex_unlock(sem->mutex); //printf("illegal state %d : %d \n", sem->count, sem->max_count); //fflush(NULL); - return TM_ERROR_ILLEGAL_STATE; - } - sem->count++; - if(sem->count > 0) { - hycond_notify(sem->condition); - } - - status = hymutex_unlock(sem->mutex); - if (status != TM_ERROR_NONE) return status; + return TM_ERROR_ILLEGAL_STATE; + } + sem->count++; + if (sem->count > 0) { + hycond_notify(sem->condition); + } + + status = hymutex_unlock(sem->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -175,25 +174,25 @@ IDATA VMCALL hysem_post(hysem_t sem) { * @param[in] sem semaphore */ IDATA VMCALL hysem_set(hysem_t sem, IDATA count) { - IDATA status; - - status = hymutex_lock(sem->mutex); + IDATA status; + + status = hymutex_lock(sem->mutex); + if (status != TM_ERROR_NONE) return status; + if (count > sem->max_count) { + hymutex_unlock(sem->mutex); if (status != TM_ERROR_NONE) return status; - if(count > sem->max_count) { - hymutex_unlock(sem->mutex); - if (status != TM_ERROR_NONE) return status; - return TM_ERROR_ILLEGAL_STATE; - } - sem->count = count; - if(count > 0) { - status = hycond_notify_all(sem->condition); - if (status != TM_ERROR_NONE){ - hymutex_unlock(sem->mutex); - return status; - } + return TM_ERROR_ILLEGAL_STATE; + } + sem->count = count; + if (count > 0) { + status = hycond_notify_all(sem->condition); + if (status != TM_ERROR_NONE) { + hymutex_unlock(sem->mutex); + return status; } - status = hymutex_unlock(sem->mutex); - if (status != TM_ERROR_NONE) return status; + } + status = hymutex_unlock(sem->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -205,13 +204,13 @@ IDATA VMCALL hysem_set(hysem_t sem, IDATA count) { * @param[in] sem semaphore */ IDATA VMCALL hysem_getvalue(IDATA *count, hysem_t sem) { - IDATA status; - - status = hymutex_lock(sem->mutex); - if (status != TM_ERROR_NONE) return status; - *count = sem->count; - status = hymutex_unlock(sem->mutex); - if (status != TM_ERROR_NONE) return status; + IDATA status; + + status = hymutex_lock(sem->mutex); + if (status != TM_ERROR_NONE) return status; + *count = sem->count; + status = hymutex_unlock(sem->mutex); + if (status != TM_ERROR_NONE) return status; return TM_ERROR_NONE; } @@ -229,13 +228,13 @@ IDATA VMCALL hysem_getvalue(IDATA *count, hysem_t sem) { * @see hysem_init, hysem_wait, hysem_post */ IDATA VMCALL hysem_destroy(hysem_t sem) { - apr_status_t apr_status; + apr_status_t apr_status; apr_pool_t *pool = sem->pool; - if(pool != get_local_pool()) { + if (pool != get_local_pool()) { return local_pool_cleanup_register(hysem_destroy, sem); } apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)sem->mutex); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)sem->condition); // apr_pool_free(pool, sem); return CONVERT_ERROR(apr_status);; diff --git vm/thread/src/thread_native_state.c vm/thread/src/thread_native_state.c index f3a272f..2e53e9c 100644 --- vm/thread/src/thread_native_state.c +++ vm/thread/src/thread_native_state.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Andrey Chernyshev - * @version $Revision: 1.1.2.4 $ - */ - /** * @file thread_native_state.c * @brief Hythread state related functions diff --git vm/thread/src/thread_native_suspend.c vm/thread/src/thread_native_suspend.c index 9256d9f..56750b0 100644 --- vm/thread/src/thread_native_suspend.c +++ vm/thread/src/thread_native_suspend.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.11 $ - */ - /** * @file thread_native_suspend.c * @brief Hythread suspend/resume related functions @@ -42,8 +37,8 @@ static void thread_safe_point_impl(hythread_t thread); /** * Returns non-zero if thread is suspended. */ -IDATA VMCALL hythread_is_suspend_enabled(){ - return tm_self_tls->suspend_disable_count == 0; +IDATA VMCALL hythread_is_suspend_enabled() { + return tm_self_tls->suspend_disable_count == 0; } @@ -81,7 +76,7 @@ suspended: thread->suspend_disable_count--; #endif - // if(!thread->suspend_request || thread->suspend_disable_count!=0) { + // if (!thread->suspend_request || thread->suspend_disable_count!=0) { // return; // } @@ -126,7 +121,7 @@ suspended: thread->suspend_disable_count++; #endif - if(!thread->suspend_request || thread->suspend_disable_count!=1) { + if (!thread->suspend_request || thread->suspend_disable_count!=1) { return; } thread_safe_point_impl(thread); @@ -151,7 +146,7 @@ void VMCALL hythread_safe_point() { static void thread_safe_point_impl(hythread_t thread) { hythread_event_callback_proc callback_func; - if(thread->suspend_request >0) { + if (thread->suspend_request >0) { int old_status = thread->suspend_disable_count; do { @@ -195,20 +190,20 @@ static void send_suspend_request(hythread_t thread) { assert(thread->suspend_request >=0); // already suspended? - if(thread->suspend_request > 0) { + if (thread->suspend_request > 0) { apr_atomic_inc32((apr_uint32_t *)&(thread->suspend_request)); return; } - //we really need to suspend thread. + //we really need to suspend thread. - hysem_set(thread->resume_event, 0); + hysem_set(thread->resume_event, 0); - apr_atomic_inc32((apr_uint32_t *)&(thread->suspend_request)); + apr_atomic_inc32((apr_uint32_t *)&(thread->suspend_request)); - apr_thread_yield_other(thread->os_handle); + apr_thread_yield_other(thread->os_handle); - TRACE(("TM: suspend request sent: %p request count: %d",thread , thread->suspend_request)); + TRACE(("TM: suspend request sent: %p request count: %d",thread , thread->suspend_request)); } @@ -216,14 +211,14 @@ static void send_suspend_request(hythread_t thread) { // blocked in case was selfsuspended. static IDATA wait_safe_region_event(hythread_t thread) { assert(thread->suspend_request >= 1); - if(thread->suspend_request > 1 || thread == tm_self_tls) { + if (thread->suspend_request > 1 || thread == tm_self_tls) { TRACE(("TM: suspend wait self exit thread: %p request count: %d",thread , thread->suspend_request)); return TM_ERROR_NONE; } // we need to wait for notification only in case the thread is in the unsafe/disable region while (thread->suspend_disable_count) { // HIT cyclic suspend - if(tm_self_tls->suspend_request > 0) { + if (tm_self_tls->suspend_request > 0) { return TM_ERROR_EBUSY; } hythread_yield(); @@ -281,18 +276,18 @@ IDATA VMCALL hythread_suspend_other(hythread_t thread) { hythread_t self; self = tm_self_tls; TRACE(("TM: suspend one enter thread: %p self: %p request count: %d",thread , tm_self_tls, thread->suspend_request)); - if(self == thread) { + if (self == thread) { hythread_suspend(); return TM_ERROR_NONE; } - send_suspend_request(thread); - while(wait_safe_region_event(thread)!=TM_ERROR_NONE) { - if(self->suspend_request>0) - { - hythread_resume(thread); - return TM_ERROR_EBUSY; - } + + send_suspend_request(thread); + while (wait_safe_region_event(thread)!=TM_ERROR_NONE) { + if (self->suspend_request>0) { + hythread_resume(thread); + return TM_ERROR_EBUSY; } + } TRACE(("TM: suspend one exit thread: %p request count: %d",thread , thread->suspend_request)); return TM_ERROR_NONE; @@ -311,20 +306,20 @@ IDATA VMCALL hythread_suspend_other(hythread_t thread) { * @see hythread_create, hythread_suspend */ void VMCALL hythread_resume(hythread_t thread) { - TRACE(("TM: start resuming: %p request count: %d",thread , thread->suspend_request)); + TRACE(("TM: start resuming: %p request count: %d",thread , thread->suspend_request)); // If there was request for suspension, decrease the request counter - // printf("resume other now lock %d %d %d %d\n",tm_self_tls->thread_id,tm_self_tls->suspend_disable_count,thread->thread_id,thread->suspend_disable_count); - if(thread->suspend_request > 0) { + //printf("resume other now lock %d %d %d %d\n",tm_self_tls->thread_id,tm_self_tls->suspend_disable_count,thread->thread_id,thread->suspend_disable_count); + if (thread->suspend_request > 0) { if (thread->safepoint_callback && thread->suspend_request < 2) return; apr_atomic_dec32((apr_uint32_t *)&(thread->suspend_request)); - if(thread->suspend_request == 0) { + if (thread->suspend_request == 0) { // Notify the thread that it may wake up now hysem_post(thread->resume_event); TRACE(("TM: resume one thread: %p request count: %d",thread , thread->suspend_request)); thread->state &= ~TM_THREAD_STATE_SUSPENDED; } } - // printf("resume other now lock-compl %d %d %d %d\n",tm_self_tls->thread_id,tm_self_tls->suspend_disable_count,thread->thread_id,thread->suspend_disable_count); + //printf("resume other now lock-compl %d %d %d %d\n",tm_self_tls->thread_id,tm_self_tls->suspend_disable_count,thread->thread_id,thread->suspend_disable_count); } /** @@ -338,7 +333,7 @@ void VMCALL hythread_resume(hythread_t thread) { IDATA hythread_set_safepoint_callback(hythread_t thread, tm_thread_event_callback_proc callback) { IDATA status; while (apr_atomic_casptr((volatile void **)&thread->safepoint_callback, (void *)callback, (void *)NULL) != NULL); - if(tm_self_tls == thread) { + if (tm_self_tls == thread) { int old_status = thread->suspend_disable_count; thread->suspend_disable_count = 1; hythread_suspend(); @@ -356,7 +351,7 @@ IDATA hythread_set_safepoint_callback(hythread_t thread, tm_thread_event_callbac if (thread->current_condition) { status=hycond_notify_all(thread->current_condition); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); } return TM_ERROR_NONE; @@ -391,37 +386,35 @@ IDATA VMCALL hythread_suspend_all(hythread_iterator_t *t, hythread_group_t group self = tm_self_tls; // try to prevent cyclic suspend dead-lock - while(self->suspend_request > 0) { + while (self->suspend_request > 0) { thread_safe_point_impl(self); } iter = hythread_iterator_create(group); - // send suspend requests to all threads + // send suspend requests to all threads TRACE(("TM: send suspend requests")); - while((next = hythread_iterator_next(&iter)) != NULL) { - if(next != self) { - send_suspend_request(next); - } - } - hythread_iterator_reset(&iter); - // all threads should be stopped in safepoints or be in safe region. - TRACE(("TM: wait suspend responses")); - while((next = hythread_iterator_next(&iter)) != NULL) { - if(next != self) { - while (wait_safe_region_event(next)!=TM_ERROR_NONE) - { - thread_safe_point_impl(tm_self_tls); - hythread_yield(); - } - } - } - - hythread_iterator_reset(&iter); - hythread_iterator_release(&iter); - if(t) - { - *t=iter; - } + while ((next = hythread_iterator_next(&iter)) != NULL) { + if (next != self) { + send_suspend_request(next); + } + } + hythread_iterator_reset(&iter); + // all threads should be stopped in safepoints or be in safe region. + TRACE(("TM: wait suspend responses")); + while ((next = hythread_iterator_next(&iter)) != NULL) { + if (next != self) { + while (wait_safe_region_event(next)!=TM_ERROR_NONE) { + thread_safe_point_impl(tm_self_tls); + hythread_yield(); + } + } + } + + hythread_iterator_reset(&iter); + hythread_iterator_release(&iter); + if (t) { + *t=iter; + } return TM_ERROR_NONE; } @@ -439,11 +432,11 @@ IDATA VMCALL hythread_resume_all(hythread_group_t group) { hythread_iterator_t iter; iter = hythread_iterator_create(group); TRACE(("TM: resume all")); - // send suspend requests to all threads - while((next = hythread_iterator_next(&iter)) != NULL) { - if(next != self) { - hythread_resume(next); - } + // send suspend requests to all threads + while ((next = hythread_iterator_next(&iter)) != NULL) { + if (next != self) { + hythread_resume(next); + } } hythread_iterator_release(&iter); @@ -454,22 +447,22 @@ IDATA VMCALL hythread_resume_all(hythread_group_t group) { // Private functionality int reset_suspend_disable() { - hythread_t self = tm_self_tls; - int dis = self->suspend_disable_count; - self->suspend_disable_count = 0; - if(self->suspend_request >0) { - // notify suspender - hylatch_count_down(self->safe_region_event); - } - return dis; + hythread_t self = tm_self_tls; + int dis = self->suspend_disable_count; + self->suspend_disable_count = 0; + if (self->suspend_request >0) { + // notify suspender + hylatch_count_down(self->safe_region_event); + } + return dis; } void set_suspend_disable(int count) { hythread_t self = tm_self_tls; assert(count>=0); self->suspend_disable_count = count; - if(count) { - thread_safe_point_impl(self); + if (count) { + thread_safe_point_impl(self); } } diff --git vm/thread/src/thread_native_thin_monitor.c vm/thread/src/thread_native_thin_monitor.c index ef0e7be..67c2ef2 100644 --- vm/thread/src/thread_native_thin_monitor.c +++ vm/thread/src/thread_native_thin_monitor.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.20 $ - */ - /** * @file thread_native_thin_monitor.c * @brief Hythread thin monitors related functions @@ -63,26 +58,25 @@ #define MAX_RECURSION 31 IDATA owns_thin_lock(hythread_t thread, I_32 lockword) { - IDATA this_id = thread->thread_id; - assert(!IS_FAT_LOCK(lockword)); + IDATA this_id = thread->thread_id; + assert(!IS_FAT_LOCK(lockword)); #ifdef LOCK_RESERVATION - return THREAD_ID(lockword) == this_id - && (!IS_RESERVED(lockword) || RECURSION(lockword) !=0); + return THREAD_ID(lockword) == this_id + && (!IS_RESERVED(lockword) || RECURSION(lockword) !=0); #else - return THREAD_ID(lockword) == this_id; + return THREAD_ID(lockword) == this_id; #endif } void set_fat_lock_id(hythread_thin_monitor_t *lockword_ptr, IDATA monitor_id) { - I_32 lockword = *lockword_ptr; + I_32 lockword = *lockword_ptr; #ifdef LOCK_RESERVATION - assert(!IS_RESERVED(lockword)); + assert(!IS_RESERVED(lockword)); #endif - lockword&=0x7FF; - lockword|=(monitor_id << 11) | 0x80000000; - *lockword_ptr=lockword; - apr_memory_rw_barrier(); - + lockword&=0x7FF; + lockword|=(monitor_id << 11) | 0x80000000; + *lockword_ptr=lockword; + apr_memory_rw_barrier(); } IDATA is_fat_lock(hythread_thin_monitor_t lockword) { @@ -118,8 +112,8 @@ void unreserve_self_lock(hythread_thin_monitor_t *lockword_ptr) { I_32 lockword_new; TRACE(("unreserve self_id %d lock owner %d", hythread_get_id(hythread_self()), THREAD_ID(lockword))); assert(hythread_get_id(hythread_self()) == THREAD_ID(lockword)); - assert (!IS_FAT_LOCK(*lockword_ptr)); - assert (IS_RESERVED(lockword)); + assert(!IS_FAT_LOCK(*lockword_ptr)); + assert(IS_RESERVED(lockword)); TRACE(("Unreserved self %d \n", ++unreserve_count_self/*, vm_get_object_class_name(lockword_ptr-1)*/)); // Set reservation bit to 1 and reduce recursion count @@ -145,35 +139,34 @@ IDATA unreserve_lock(hythread_thin_monitor_t *lockword_ptr) { IDATA status; // trylock used to prevent cyclic suspend deadlock // the java_monitor_enter calls safe_point between attempts. - /* status = hymutex_trylock(TM_LOCK); - if(status !=TM_ERROR_NONE) { + /*status = hymutex_trylock(TM_LOCK); + if (status !=TM_ERROR_NONE) { return status; }*/ - if(IS_FAT_LOCK(lockword)) - { + if (IS_FAT_LOCK(lockword)) { return TM_ERROR_NONE; } lock_id = THREAD_ID(lockword); owner = hythread_get_thread(lock_id); TRACE(("Unreserved other %d \n", ++unreserve_count/*, vm_get_object_class_name(lockword_ptr-1)*/)); - if(!IS_RESERVED(lockword) || IS_FAT_LOCK(lockword)) { - // hymutex_unlock(TM_LOCK); + if (!IS_RESERVED(lockword) || IS_FAT_LOCK(lockword)) { + // hymutex_unlock(TM_LOCK); return TM_ERROR_NONE; } // suspend owner - if(owner) { + if (owner) { assert(owner); assert(hythread_get_id(owner) == lock_id); assert(owner != hythread_self()); status=hythread_suspend_other(owner); - if(status !=TM_ERROR_NONE) { + if (status !=TM_ERROR_NONE) { return status; } } // prepare new unreserved lockword and try to CAS it with old one. while (IS_RESERVED(lockword)) { - assert (!IS_FAT_LOCK(lockword)); + assert(!IS_FAT_LOCK(lockword)); TRACE(("unreserving lock")); lockword_new = (lockword | RESERVED_BITMASK); if (RECURSION(lockword) != 0) { @@ -183,7 +176,7 @@ IDATA unreserve_lock(hythread_thin_monitor_t *lockword_ptr) { } else { lockword_new = lockword_new & 0x0000ffff; } - if(lockword == apr_atomic_cas32 (((volatile apr_uint32_t*) lockword_ptr), + if (lockword == apr_atomic_cas32 (((volatile apr_uint32_t*) lockword_ptr), (apr_uint32_t) lockword_new, lockword)) { TRACE(("unreserved lock")); break; @@ -192,9 +185,9 @@ IDATA unreserve_lock(hythread_thin_monitor_t *lockword_ptr) { } // resume owner - if(owner) { - apr_thread_yield_other(owner->os_handle); - hythread_resume(owner); + if (owner) { + apr_thread_yield_other(owner->os_handle); + hythread_resume(owner); } /* status = hymutex_unlock(TM_LOCK);*/ @@ -248,7 +241,7 @@ IDATA hythread_thin_monitor_try_enter(hythread_thin_monitor_t *lockword_ptr) { IDATA status; hythread_monitor_t fat_monitor; int UNUSED i; - assert (!hythread_is_suspend_enabled()); + assert(!hythread_is_suspend_enabled()); assert((UDATA)lockword_ptr > 4); assert(tm_self_tls); lockword = *lockword_ptr; @@ -305,7 +298,7 @@ IDATA hythread_thin_monitor_try_enter(hythread_thin_monitor_t *lockword_ptr) { } else // Fat monitor - if(IS_FAT_LOCK(lockword)) { + if (IS_FAT_LOCK(lockword)) { TRACE(("FAT MONITOR %d \n", ++fat_lock2_count/*, vm_get_object_class_name(lockword_ptr-1)*/)); fat_monitor = locktable_get_fat_monitor(FAT_LOCK_ID(lockword)); // find fat_monitor in lock table @@ -322,9 +315,9 @@ IDATA hythread_thin_monitor_try_enter(hythread_thin_monitor_t *lockword_ptr) { // unreserved busy lock else if (IS_RESERVED(lockword)) { status = unreserve_lock(lockword_ptr); - if(status != TM_ERROR_NONE) { + if (status != TM_ERROR_NONE) { #ifdef SPIN_COUNT - if(status == TM_ERROR_EBUSY) { + if (status == TM_ERROR_EBUSY) { continue; } #endif //SPIN_COUNT @@ -359,7 +352,7 @@ IDATA hythread_thin_monitor_enter(hythread_thin_monitor_t *lockword_ptr) { } while (hythread_thin_monitor_try_enter(lockword_ptr) == TM_ERROR_EBUSY) { - if(IS_FAT_LOCK(*lockword_ptr)) { + if (IS_FAT_LOCK(*lockword_ptr)) { fat_monitor = locktable_get_fat_monitor(FAT_LOCK_ID(*lockword_ptr)); // find fat_monitor in lock table TRACE((" lock %d\n", FAT_LOCK_ID(*lockword_ptr))); saved_disable_count=reset_suspend_disable(); @@ -370,7 +363,7 @@ IDATA hythread_thin_monitor_enter(hythread_thin_monitor_t *lockword_ptr) { //hythread_safe_point(); hythread_yield(); } - if(IS_FAT_LOCK(*lockword_ptr)) { + if (IS_FAT_LOCK(*lockword_ptr)) { // lock already inflated return TM_ERROR_NONE; } @@ -389,12 +382,12 @@ IDATA VMCALL hythread_thin_monitor_exit(hythread_thin_monitor_t *lockword_ptr) { hythread_monitor_t fat_monitor; IDATA this_id = tm_self_tls->thread_id; // obtain current thread id assert(this_id > 0 && this_id < 0xffff); - assert (!hythread_is_suspend_enabled()); + assert(!hythread_is_suspend_enabled()); - if(THREAD_ID(lockword) == this_id) { + if (THREAD_ID(lockword) == this_id) { if (RECURSION(lockword)==0) { #ifdef LOCK_RESERVATION - if(IS_RESERVED(lockword)) { + if (IS_RESERVED(lockword)) { TRACE(("ILLEGAL_STATE %x\n", lockword)); return TM_ERROR_ILLEGAL_STATE; } @@ -563,31 +556,31 @@ hythread_monitor_t VMCALL inflate_lock(hythread_thin_monitor_t *lockword_ptr) { I_32 lockword; int i; status=hymutex_lock(FAT_MONITOR_TABLE_LOCK); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); TRACE(("inflate tmj%d\n", ++inflate_count)); lockword = *lockword_ptr; - if(IS_FAT_LOCK (lockword)) { - status=hymutex_unlock(FAT_MONITOR_TABLE_LOCK); - assert (status == TM_ERROR_NONE); - return locktable_get_fat_monitor(FAT_LOCK_ID(lockword)); + if (IS_FAT_LOCK (lockword)) { + status = hymutex_unlock(FAT_MONITOR_TABLE_LOCK); + assert(status == TM_ERROR_NONE); + return locktable_get_fat_monitor(FAT_LOCK_ID(lockword)); } #ifdef LOCK_RESERVATION // unreserve lock first if (IS_RESERVED(lockword)) { - unreserve_self_lock(lockword_ptr); - lockword = *lockword_ptr; + unreserve_self_lock(lockword_ptr); + lockword = *lockword_ptr; } assert(!IS_RESERVED(lockword)); #endif assert(owns_thin_lock(tm_self_tls, lockword)); - assert (!hythread_is_suspend_enabled()); + assert(!hythread_is_suspend_enabled()); TRACE (("inflation begin for %x thread: %d", lockword, tm_self_tls->thread_id)); status = hythread_monitor_init(&fat_monitor, 0); // allocate fat fat_monitor assert(status == TM_ERROR_NONE); status = hythread_monitor_enter(fat_monitor); - if(status != TM_ERROR_NONE) { + if (status != TM_ERROR_NONE) { hymutex_unlock(FAT_MONITOR_TABLE_LOCK); return NULL; } @@ -605,7 +598,7 @@ hythread_monitor_t VMCALL inflate_lock(hythread_thin_monitor_t *lockword_ptr) { fat_monitor->inflate_count++; fat_monitor->inflate_owner=tm_self_tls; status=hymutex_unlock(FAT_MONITOR_TABLE_LOCK); - assert (status == TM_ERROR_NONE); + assert(status == TM_ERROR_NONE); #ifdef LOCK_RESERVATION assert(!IS_RESERVED(*lockword_ptr)); #endif @@ -661,21 +654,21 @@ hythread_monitor_t locktable_get_fat_monitor(IDATA lock_id) { * Sets the value of the specific entry in the lock table */ IDATA locktable_put_fat_monitor(hythread_monitor_t fat_monitor) { - int id; - //hythread_global_lock(); - id = fat_monitor_count++; - if (id >= table_size) { + int id; + //hythread_global_lock(); + id = fat_monitor_count++; + if (id >= table_size) { hythread_suspend_all(NULL, NULL); table_size = table_size*2; lock_table = (hythread_monitor_t *)realloc(lock_table, sizeof(hythread_monitor_t)*table_size); assert(lock_table); apr_memory_rw_barrier(); hythread_resume_all(NULL); - } - - lock_table[id] = fat_monitor; - //hythread_global_unlock(); - return id; + } + + lock_table[id] = fat_monitor; + //hythread_global_unlock(); + return id; } /* @@ -687,7 +680,6 @@ hythread_monitor_t locktable_delete_entry(int lock_id) { m = lock_table[lock_id]; lock_table[lock_id] = NULL; return m; - } /** @@ -701,7 +693,7 @@ hythread_t VMCALL hythread_thin_monitor_get_owner(hythread_thin_monitor_t *lockw assert(lockword_ptr); lockword = *lockword_ptr; - if(IS_FAT_LOCK(lockword)) { + if (IS_FAT_LOCK(lockword)) { fat_monitor = locktable_get_fat_monitor(FAT_LOCK_ID(lockword)); // find fat_monitor in lock table return fat_monitor->owner; } @@ -729,11 +721,11 @@ IDATA VMCALL hythread_thin_monitor_get_recursion(hythread_thin_monitor_t *lockwo assert(lockword_ptr); lockword = *lockword_ptr; - if(IS_FAT_LOCK(lockword)) { + if (IS_FAT_LOCK(lockword)) { fat_monitor = locktable_get_fat_monitor(FAT_LOCK_ID(lockword)); // find fat_monitor in lock table return fat_monitor->recursion_count+1; } - if(THREAD_ID(lockword) == 0) { + if (THREAD_ID(lockword) == 0) { return 0; } #ifdef LOCK_RESERVATION diff --git vm/thread/src/thread_native_tls.c vm/thread/src/thread_native_tls.c index 830d6c6..cf0b5ee 100644 --- vm/thread/src/thread_native_tls.c +++ vm/thread/src/thread_native_tls.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Nikolay Kuznetsov - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_native_tls.c * @brief Hythread TLS related functions diff --git vm/thread/src/thread_private.h vm/thread/src/thread_private.h index f0f68a5..51b094c 100644 --- vm/thread/src/thread_private.h +++ vm/thread/src/thread_private.h @@ -14,12 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Andrey Chernyshev - * @version $Revision: 1.1.2.14 $ - */ - - #ifndef THREAD_PRIVATE_H #define THREAD_PRIVATE_H @@ -44,7 +38,7 @@ //#include "clog.h" // FIXME move to the global header, add error converter -#define RET_ON_ERROR(stat) if(stat) { return -1; } +#define RET_ON_ERROR(stat) if (stat) { return -1; } #define CONVERT_ERROR(stat) (stat) #define MAX_OWNED_MONITOR_NUMBER 200 //FIXME: switch to dynamic resize @@ -108,27 +102,27 @@ __forceinline hythread_t tmn_self_macro() { #endif /** - * get_local_pool() function return apr pool associated with the current thread. - * the memory could be allocated without lock using this pool - * deallocation should be done in the same thread, otherwise - * local_pool_cleanup_register() should be called - */ - apr_pool_t* get_local_pool(); + * get_local_pool() function return apr pool associated with the current thread. + * the memory could be allocated without lock using this pool + * deallocation should be done in the same thread, otherwise + * local_pool_cleanup_register() should be called + */ +apr_pool_t* get_local_pool(); /** - * local_pool_cleanup_register() synchronously register the cleanup function. - * It should be called to request cleanup in thread local pool, from other thread - * Usage scenario: - * IDATA hymutex_destroy (tm_mutex_t *mutex) { - * apr_pool_t *pool = apr_thread_mutex_pool_get ((apr_thread_mutex_t*)mutex); - * if(pool != get_local_pool()) { - * return local_pool_cleanup_register(hymutex_destroy, mutex); - * } - * apr_thread_mutex_destroy(mutex); - * return TM_ERROR_NONE; - * } - * - */ + * local_pool_cleanup_register() synchronously register the cleanup function. + * It should be called to request cleanup in thread local pool, from other thread + * Usage scenario: + * IDATA hymutex_destroy (tm_mutex_t *mutex) { + * apr_pool_t *pool = apr_thread_mutex_pool_get ((apr_thread_mutex_t*)mutex); + * if (pool != get_local_pool()) { + * return local_pool_cleanup_register(hymutex_destroy, mutex); + * } + * apr_thread_mutex_destroy(mutex); + * return TM_ERROR_NONE; + * } + * + */ IDATA local_pool_cleanup_register(void* func, void* data); @@ -208,23 +202,22 @@ typedef struct HyThread { // Basic manipulation fields - /** - * Group for this thread. Different groups are needed in order - * to be able to quickly iterate over the specific group. - * Examples are: Java threads, GC private threads. - * Equal to the address of the head of the list of threads for this group. - */ + /** + * Group for this thread. Different groups are needed in order + * to be able to quickly iterate over the specific group. + * Examples are: Java threads, GC private threads. + * Equal to the address of the head of the list of threads for this group. + */ hythread_group_t group; - /** - * Points to the next thread within the group. - */ + /** + * Points to the next thread within the group. + */ hythread_t next; - /** + /** * Points to the last thread within the group. */ - hythread_t prev; /** @@ -457,39 +450,41 @@ typedef struct HyThreadGroup { */ typedef struct HyThreadMonitor { - /** - * Mutex - */ - hymutex_t mutex; - - /** - * Condition variable - */ - hycond_t condition; - - /** - * Recursion count - */ - IDATA recursion_count; - hythread_t owner; - hythread_t inflate_owner; - hythread_t last_wait; - int inflate_count; - int wait_count; - int notify_flag; - /** - * monitor sub pool - * will be destroyed by monitor_destroy() - */ - apr_pool_t *pool; - /** - * Owner thread ID. - */ - IDATA thread_id; - - UDATA flags; - - char *name; + /** + * Mutex + */ + hymutex_t mutex; + + /** + * Condition variable + */ + hycond_t condition; + + /** + * Recursion count + */ + IDATA recursion_count; + hythread_t owner; + hythread_t inflate_owner; + hythread_t last_wait; + int inflate_count; + int wait_count; + int notify_flag; + + /** + * monitor sub pool + * will be destroyed by monitor_destroy() + */ + apr_pool_t *pool; + + /** + * Owner thread ID. + */ + IDATA thread_id; + + UDATA flags; + + char *name; } HyThreadMonitor; @@ -498,25 +493,25 @@ typedef struct HyThreadMonitor { */ typedef struct HyLatch { - /** - * Latch count - */ - int count; + /** + * Latch count + */ + int count; + + /** + * Condition event used to signal threads which are waiting on the latch. + */ + hycond_t condition; - /** - * Condition event used to signal threads which are waiting on the latch. - */ - hycond_t condition; - - /** - * Mutex associated with the latch data. - */ - hymutex_t mutex; - /** - * latch sub pool - * will be destroyed by latch_destroy() - */ - apr_pool_t *pool; + /** + * Mutex associated with the latch data. + */ + hymutex_t mutex; + /** + * latch sub pool + * will be destroyed by latch_destroy() + */ + apr_pool_t *pool; } HyLatch; @@ -526,30 +521,31 @@ typedef struct HyLatch { */ typedef struct HySemaphore { - /** - * Semaphore count - */ - int count; - - /** - * Semaphore max count - */ - int max_count; + /** + * Semaphore count + */ + int count; + + /** + * Semaphore max count + */ + int max_count; + + /** + * Condition event used to signal threads which are waiting on the semaphore. + */ + hycond_t condition; - /** - * Condition event used to signal threads which are waiting on the semaphore. - */ - hycond_t condition; - - /** - * Mutex associated with the semaphore data. - */ - hymutex_t mutex; - /** - * semaphore sub pool - * will be destroyed by sem_destroy() - */ - apr_pool_t *pool; + /** + * Mutex associated with the semaphore data. + */ + hymutex_t mutex; + + /** + * semaphore sub pool + * will be destroyed by sem_destroy() + */ + apr_pool_t *pool; } HySemaphore; // Global variables diff --git vm/thread/src/thread_ti_instr.c vm/thread/src/thread_ti_instr.c index d10b5d7..7fa09fd 100644 --- vm/thread/src/thread_ti_instr.c +++ vm/thread/src/thread_ti_instr.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.10 $ - */ - /** * @file thread_ti_instr.c * @brief JVMTI basic related functions @@ -39,81 +34,80 @@ IDATA VMCALL jthread_get_all_threads(jthread** threads, jint *count_ptr) { hythread_group_t java_thread_group = get_java_thread_group(); - hythread_iterator_t iterator; - hythread_t tm_native_thread; - jvmti_thread_t tm_java_thread; - jthread* java_threads; - int i; - int count = 0; - int java_thread_count = 0; - IDATA status; + hythread_iterator_t iterator; + hythread_t tm_native_thread; + jvmti_thread_t tm_java_thread; + jthread* java_threads; + int i; + int count = 0; + int java_thread_count = 0; + IDATA status; //apr_status_t apr_status; //apr_pool_t *pool; assert(java_thread_group); - iterator = hythread_iterator_create(java_thread_group); - count = hythread_iterator_size (iterator); - for (i = 0; i < count; i++){ + iterator = hythread_iterator_create(java_thread_group); + count = hythread_iterator_size (iterator); + for (i = 0; i < count; i++) { tm_native_thread = hythread_iterator_next(&iterator); - tm_java_thread = hythread_get_private_data(tm_native_thread); - if (tm_java_thread){ - java_thread_count++; - } + tm_java_thread = hythread_get_private_data(tm_native_thread); + if (tm_java_thread) { + java_thread_count++; } + } /*apr_status = apr_pool_create(&pool, 0); - if (apr_status != APR_SUCCESS){ + if (apr_status != APR_SUCCESS) { hythread_iterator_release(&iterator); return CONVERT_ERROR(apr_status); } java_threads = apr_palloc(pool, sizeof(jthread)* java_thread_count);*/ java_threads = (jthread*)malloc(sizeof(jthread)* java_thread_count); - if (!java_threads){ - hythread_iterator_release(&iterator); - return TM_ERROR_OUT_OF_MEMORY; - } - hythread_iterator_reset(&iterator); - java_thread_count = 0; - for (i = 0; i < count; i++){ + if (!java_threads) { + hythread_iterator_release(&iterator); + return TM_ERROR_OUT_OF_MEMORY; + } + hythread_iterator_reset(&iterator); + java_thread_count = 0; + for (i = 0; i < count; i++) { tm_native_thread = hythread_iterator_next(&iterator); - tm_java_thread = hythread_get_private_data(tm_native_thread); - if (tm_java_thread){ - java_threads[java_thread_count] = tm_java_thread->thread_object; - java_thread_count++; - } + tm_java_thread = hythread_get_private_data(tm_native_thread); + if (tm_java_thread) { + java_threads[java_thread_count] = tm_java_thread->thread_object; + java_thread_count++; } + } *threads = java_threads; - *count_ptr = java_thread_count; + *count_ptr = java_thread_count; status = hythread_iterator_release(&iterator); return status; } /* */ -IDATA deads_expand(jthread **deads, int deads_size){ +IDATA deads_expand(jthread **deads, int deads_size) { jthread *new_deads; int i; new_deads = (jthread *)malloc(sizeof(jthread) * deads_size * 2); - if (!new_deads) return TM_ERROR_OUT_OF_MEMORY; + if (!new_deads) return TM_ERROR_OUT_OF_MEMORY; - for (i = 0; i < deads_size; i++){ + for (i = 0; i < deads_size; i++) { new_deads[i] = (*deads)[i]; - } + } *deads = new_deads; - return TM_ERROR_NONE; + return TM_ERROR_NONE; } /* */ -int deads_find(jobject thread, jobject *deads, int base, int top, int deads_size){ - - int i; +int deads_find(jobject thread, jobject *deads, int base, int top, int deads_size) { + int i; - for (i = 0; i < top; i++){ - if (vm_objects_are_equal(thread, deads[i])){ - return 1; - } + for (i = 0; i < top; i++) { + if (vm_objects_are_equal(thread, deads[i])) { + return 1; } - return 0; + } + return 0; } // FIXME: synchronization and maybe thread suspension needed /** @@ -125,74 +119,73 @@ int deads_find(jobject thread, jobject *deads, int base, int top, int deads_size * @param[out] dead_count number of deadlocked threads */ IDATA VMCALL jthread_get_deadlocked_threads(jthread *thread_list, jint thread_count, jthread **dead_list, jint *dead_count) { - - jthread *deads; - int deads_size = 1; - int deads_base = 0; - int deads_top = 0; + jthread *deads; + int deads_size = 1; + int deads_base = 0; + int deads_top = 0; jthread *output; - int output_top = 0; - jobject monitor; - jthread thread; + int output_top = 0; + jobject monitor; + jthread thread; //apr_pool_t *pool; /*apr_pool_t *pool_out; apr_status_t apr_status;*/ - IDATA status; - int i; + IDATA status; + int i; /*apr_status = apr_pool_create(&pool, NULL); - if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); + if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status); - deads = apr_palloc(pool, sizeof(jthread) * deads_size); + deads = apr_palloc(pool, sizeof(jthread) * deads_size); output = apr_palloc(pool, sizeof(jthread) * thread_count); if (!deads || !output) return TM_ERROR_OUT_OF_MEMORY;*/ deads = (jthread *)malloc(sizeof(jthread) * deads_size); output = (jthread *)malloc(sizeof(jthread) * thread_count); - if ((deads==NULL)||(output==NULL)) - { + if ((deads==NULL)||(output==NULL)) { return TM_ERROR_OUT_OF_MEMORY; } - for (i = 0; i < thread_count; i++){ - thread = thread_list[i]; - while (1){ - status=jthread_get_contended_monitor(thread, &monitor); - if (status != TM_ERROR_NONE) return status; - if (! monitor){ - deads_top = deads_base; // remove frame - break; - } - if (deads_find(thread, deads, deads_base, deads_top, deads_size)){ - output[output_top] = thread; + for (i = 0; i < thread_count; i++) { + thread = thread_list[i]; + while (1) { + status=jthread_get_contended_monitor(thread, &monitor); + if (status != TM_ERROR_NONE) return status; + if (! monitor) { + deads_top = deads_base; // remove frame + break; + } + if (deads_find(thread, deads, deads_base, deads_top, deads_size)) { + output[output_top] = thread; output_top++; - deads_base = deads_top; // add frame - break; - } - if (deads_top == deads_size){ - status = deads_expand(&deads, deads_size); - if (status != TM_ERROR_NONE) return status; - } - deads[deads_top] = thread; - deads_top++; - status = jthread_get_lock_owner(monitor, &thread); + deads_base = deads_top; // add frame + break; + } + if (deads_top == deads_size) { + status = deads_expand(&deads, deads_size); if (status != TM_ERROR_NONE) return status; - } + } + deads[deads_top] = thread; + deads_top++; + status = jthread_get_lock_owner(monitor, &thread); + if (status != TM_ERROR_NONE) return status; } - if (output_top > 0){ + } + + if (output_top > 0) { /* apr_status = apr_pool_create(&pool_out, NULL); if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);*/ *dead_list = (jthread *)malloc(sizeof(jthread) * output_top); - if (! *dead_list) return TM_ERROR_OUT_OF_MEMORY; + if (! *dead_list) return TM_ERROR_OUT_OF_MEMORY; - for (i = 0; i < output_top; i++){ + for (i = 0; i < output_top; i++) { (*dead_list)[i] = output[i]; - } - } else { - *dead_list = NULL; } + } else { + *dead_list = NULL; + } *dead_count = output_top; - return TM_ERROR_NONE; + return TM_ERROR_NONE; } /** @@ -203,25 +196,25 @@ IDATA VMCALL jthread_get_deadlocked_threads(jthread *thread_list, jint thread_co IDATA VMCALL jthread_get_thread_count(jint *count_ptr) { hythread_group_t java_thread_group = get_java_thread_group(); - hythread_iterator_t iterator; - hythread_t tm_native_thread; - jvmti_thread_t tm_java_thread; - int i; - int count = 0; - int java_thread_count = 0; - IDATA status; + hythread_iterator_t iterator; + hythread_t tm_native_thread; + jvmti_thread_t tm_java_thread; + int i; + int count = 0; + int java_thread_count = 0; + IDATA status; assert(java_thread_group); - iterator = hythread_iterator_create(java_thread_group); - count = hythread_iterator_size (iterator); - for (i = 0; i < count; i++){ + iterator = hythread_iterator_create(java_thread_group); + count = hythread_iterator_size (iterator); + for (i = 0; i < count; i++) { tm_native_thread = hythread_iterator_next(&iterator); - tm_java_thread = hythread_get_private_data(tm_native_thread); - if (tm_java_thread){ - java_thread_count++; - } + tm_java_thread = hythread_get_private_data(tm_native_thread); + if (tm_java_thread) { + java_thread_count++; } - *count_ptr = java_thread_count; + } + *count_ptr = java_thread_count; status = hythread_iterator_release(&iterator); return status; @@ -235,23 +228,23 @@ IDATA VMCALL jthread_get_thread_count(jint *count_ptr) { IDATA VMCALL jthread_get_blocked_count(jint* count_ptr) { hythread_group_t java_thread_group = get_java_thread_group(); - hythread_iterator_t iterator; - hythread_t tm_native_thread; - int nmb = 0; - int count; - IDATA status; + hythread_iterator_t iterator; + hythread_t tm_native_thread; + int nmb = 0; + int count; + IDATA status; assert(java_thread_group); - iterator = hythread_iterator_create(java_thread_group); - count = hythread_iterator_size (iterator); - - while(hythread_iterator_has_next(iterator)){ - tm_native_thread = hythread_iterator_next(&iterator); - if (tm_native_thread && hythread_is_blocked_on_monitor_enter(tm_native_thread)){ - nmb++; - } + iterator = hythread_iterator_create(java_thread_group); + count = hythread_iterator_size (iterator); + + while (hythread_iterator_has_next(iterator)) { + tm_native_thread = hythread_iterator_next(&iterator); + if (tm_native_thread && hythread_is_blocked_on_monitor_enter(tm_native_thread)) { + nmb++; } - *count_ptr = nmb; + } + *count_ptr = nmb; status = hythread_iterator_release(&iterator); return status; @@ -265,22 +258,22 @@ IDATA VMCALL jthread_get_blocked_count(jint* count_ptr) { IDATA VMCALL jthread_get_waited_count(jint* count) { hythread_group_t java_thread_group = get_java_thread_group(); - hythread_iterator_t iterator; - hythread_t tm_native_thread; - int nmb = 0; - IDATA status; + hythread_iterator_t iterator; + hythread_t tm_native_thread; + int nmb = 0; + IDATA status; assert(java_thread_group); - iterator = hythread_iterator_create(java_thread_group); - - while(hythread_iterator_has_next(iterator)){ - tm_native_thread = hythread_iterator_next(&iterator); - //if (hythread_is_in_monitor_wait(tm_native_thread)){ ??????????????????????? - if (hythread_is_waiting(tm_native_thread)){ - nmb++; - } + iterator = hythread_iterator_create(java_thread_group); + + while (hythread_iterator_has_next(iterator)) { + tm_native_thread = hythread_iterator_next(&iterator); + //if (hythread_is_in_monitor_wait(tm_native_thread)) { ??????????????????????? + if (hythread_is_waiting(tm_native_thread)) { + nmb++; } - *count = nmb; + } + *count = nmb; status = hythread_iterator_release(&iterator); return status; @@ -296,29 +289,28 @@ IDATA VMCALL jthread_get_waited_count(jint* count) { * */ IDATA VMCALL jthread_get_state(jthread java_thread, jint *state) { - - hythread_t tm_native_thread; + hythread_t tm_native_thread; assert(java_thread); assert(state); - tm_native_thread = vm_jthread_get_tm_data(java_thread); - - *state = 0; - if (! tm_native_thread) return TM_ERROR_NONE; // Not started yet - - if (hythread_is_alive(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_ALIVE;} - if (hythread_is_runnable(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_RUNNABLE;} - if (hythread_is_blocked_on_monitor_enter(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER;} - if (hythread_is_waiting(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_WAITING;} - if (hythread_is_waiting_indefinitely(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_WAITING_INDEFINITELY;} - if (hythread_is_waiting_with_timeout(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT;} - if (hythread_is_sleeping(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_SLEEPING;} - if (hythread_is_in_monitor_wait(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_IN_OBJECT_WAIT;} - if (hythread_is_parked(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_PARKED;} - if (hythread_is_suspended(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_SUSPENDED;} - if (hythread_interrupted(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_INTERRUPTED;} - if (hythread_is_in_native(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_IN_NATIVE;} - if (hythread_is_terminated(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_TERMINATED;} + tm_native_thread = vm_jthread_get_tm_data(java_thread); + + *state = 0; + if (! tm_native_thread) return TM_ERROR_NONE; // Not started yet + + if (hythread_is_alive(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_ALIVE;} + if (hythread_is_runnable(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_RUNNABLE;} + if (hythread_is_blocked_on_monitor_enter(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER;} + if (hythread_is_waiting(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_WAITING;} + if (hythread_is_waiting_indefinitely(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_WAITING_INDEFINITELY;} + if (hythread_is_waiting_with_timeout(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT;} + if (hythread_is_sleeping(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_SLEEPING;} + if (hythread_is_in_monitor_wait(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_IN_OBJECT_WAIT;} + if (hythread_is_parked(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_PARKED;} + if (hythread_is_suspended(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_SUSPENDED;} + if (hythread_interrupted(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_INTERRUPTED;} + if (hythread_is_in_native(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_IN_NATIVE;} + if (hythread_is_terminated(tm_native_thread)) {*state |= JVMTI_THREAD_STATE_TERMINATED;} return TM_ERROR_NONE; } @@ -330,14 +322,13 @@ IDATA VMCALL jthread_get_state(jthread java_thread, jint *state) { * @param[in] data data to be put */ IDATA VMCALL jthread_set_local_storage(jthread java_thread, const void* data) { - - hythread_t tm_native_thread; + hythread_t tm_native_thread; assert(java_thread); - tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_native_thread = vm_jthread_get_tm_data(java_thread); assert(tm_native_thread); - return hythread_set_private_data(tm_native_thread, (void *)data); + return hythread_set_private_data(tm_native_thread, (void *)data); } /** @@ -347,14 +338,13 @@ IDATA VMCALL jthread_set_local_storage(jthread java_thread, const void* data) { * @param[out] data_ptr pointer to the data */ IDATA VMCALL jthread_get_local_storage(jthread java_thread, void** data_ptr) { - - hythread_t tm_native_thread; + hythread_t tm_native_thread; assert(java_thread); assert(data_ptr); - tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_native_thread = vm_jthread_get_tm_data(java_thread); assert(tm_native_thread); - *data_ptr = hythread_get_private_data (tm_native_thread); + *data_ptr = hythread_get_private_data (tm_native_thread); return TM_ERROR_NONE; } @@ -391,14 +381,14 @@ jboolean VMCALL jthread_holds_lock(jthread thread, jobject monitor) { */ IDATA VMCALL jthread_get_contended_monitor(jthread java_thread, jobject* monitor) { - hythread_t tm_native_thread; - jvmti_thread_t tm_java_thread; + hythread_t tm_native_thread; + jvmti_thread_t tm_java_thread; assert(java_thread); - tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_native_thread = vm_jthread_get_tm_data(java_thread); tm_java_thread = hythread_get_private_data(tm_native_thread); - assert(tm_java_thread); - *monitor = tm_java_thread->contended_monitor; + assert(tm_java_thread); + *monitor = tm_java_thread->contended_monitor; return TM_ERROR_NONE; } @@ -411,14 +401,14 @@ IDATA VMCALL jthread_get_contended_monitor(jthread java_thread, jobject* monitor */ IDATA VMCALL jthread_get_wait_monitor(jthread java_thread, jobject* monitor) { - hythread_t tm_native_thread; - jvmti_thread_t tm_java_thread; + hythread_t tm_native_thread; + jvmti_thread_t tm_java_thread; assert(java_thread); - tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_native_thread = vm_jthread_get_tm_data(java_thread); tm_java_thread = hythread_get_private_data(tm_native_thread); - assert(tm_java_thread); - *monitor = tm_java_thread->wait_monitor; + assert(tm_java_thread); + *monitor = tm_java_thread->wait_monitor; return TM_ERROR_NONE; } @@ -440,7 +430,7 @@ IDATA VMCALL jthread_get_lock_owner(jobject monitor, jthread* lock_owner) { hythread_suspend_disable(); lockword = vm_object_get_lockword_addr(monitor); tm_native_thread = hythread_thin_monitor_get_owner(lockword); - if (!tm_native_thread){ + if (!tm_native_thread) { *lock_owner = NULL; } else { tm_java_thread = hythread_get_private_data(tm_native_thread); @@ -466,19 +456,19 @@ IDATA VMCALL jthread_get_lock_recursion(jobject monitor, jthread owner) { hythread_thin_monitor_t *lockword; IDATA recursion = 0; - assert(monitor); + assert(monitor); given_thread = owner?vm_jthread_get_tm_data(owner):NULL; - hythread_suspend_disable(); + hythread_suspend_disable(); - lockword = vm_object_get_lockword_addr(monitor); + lockword = vm_object_get_lockword_addr(monitor); lock_owner = hythread_thin_monitor_get_owner(lockword); if (lock_owner && (!given_thread || lock_owner->thread_id == given_thread->thread_id)) - recursion = hythread_thin_monitor_get_recursion(lockword); + recursion = hythread_thin_monitor_get_recursion(lockword); - hythread_suspend_enable(); + hythread_suspend_enable(); - return recursion; + return recursion; } /** @@ -489,22 +479,22 @@ IDATA VMCALL jthread_get_lock_recursion(jobject monitor, jthread owner) { * @param[out] monitors_ptr array of owned monitors */ IDATA VMCALL jthread_get_owned_monitors(jthread java_thread, - jint* monitor_count_ptr, jobject** monitors_ptr) { + jint* monitor_count_ptr, jobject** monitors_ptr) { - hythread_t tm_native_thread; - jvmti_thread_t tm_java_thread; + hythread_t tm_native_thread; + jvmti_thread_t tm_java_thread; // apr_pool_t* pool; // apr_status_t apr_status; jobject* monitors; - int i; - IDATA status; - - status =hythread_global_lock(); - if (status != TM_ERROR_NONE) return status; + int i; + IDATA status; + + status =hythread_global_lock(); + if (status != TM_ERROR_NONE) return status; assert(java_thread); - tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_native_thread = vm_jthread_get_tm_data(java_thread); tm_java_thread = hythread_get_private_data(tm_native_thread); - assert(tm_java_thread); + assert(tm_java_thread); /* apr_status = apr_pool_create(&pool, 0); if (apr_status != APR_SUCCESS) { hythread_global_unlock(); @@ -516,12 +506,12 @@ IDATA VMCALL jthread_get_owned_monitors(jthread java_thread, hythread_global_unlock(); return TM_ERROR_OUT_OF_MEMORY; } - for (i = 0; i < tm_java_thread->owned_monitors_nmb; i++){ - monitors[i] = tm_java_thread->owned_monitors[i]; - } + for (i = 0; i < tm_java_thread->owned_monitors_nmb; i++) { + monitors[i] = tm_java_thread->owned_monitors[i]; + } *monitors_ptr = monitors; - *monitor_count_ptr = tm_java_thread->owned_monitors_nmb; + *monitor_count_ptr = tm_java_thread->owned_monitors_nmb; status = hythread_global_unlock(); - return status; + return status; } diff --git vm/thread/src/thread_ti_monitors.c vm/thread/src/thread_ti_monitors.c index 6df4a47..9ab79c3 100644 --- vm/thread/src/thread_ti_monitors.c +++ vm/thread/src/thread_ti_monitors.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Artem Aliev - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_ti_monitors.c * @brief JVMTI raw monitors related functions @@ -51,28 +46,29 @@ IDATA VMCALL jthread_raw_monitor_create(jrawMonitorID* mon_ptr) { //// if (!jvmti_monitor_table) { status =hythread_global_lock(); - if (status != TM_ERROR_NONE) return status; + if (status != TM_ERROR_NONE) return status; if (!jvmti_monitor_table) { if (array_create(&jvmti_monitor_table)) { - hythread_global_unlock(); - return TM_ERROR_OUT_OF_MEMORY; + hythread_global_unlock(); + return TM_ERROR_OUT_OF_MEMORY; + } + status = hymutex_create(&jvmti_monitor_table_lock, TM_MUTEX_NESTED); + if (status != TM_ERROR_NONE) { + hythread_global_unlock(); + return status; } - status =hymutex_create(&jvmti_monitor_table_lock, TM_MUTEX_NESTED); - if (status != TM_ERROR_NONE){ - hythread_global_unlock(); - return status; - } } status =hythread_global_unlock(); - if (status != TM_ERROR_NONE) return status; + if (status != TM_ERROR_NONE) return status; } status =hymutex_lock(jvmti_monitor_table_lock); - if (status != TM_ERROR_NONE) return status; + if (status != TM_ERROR_NONE) return status; *mon_ptr = array_add(jvmti_monitor_table, monitor); + status =hymutex_unlock(jvmti_monitor_table_lock); - if (status != TM_ERROR_NONE) return status; + if (status != TM_ERROR_NONE) return status; if (!(*mon_ptr)) return TM_ERROR_OUT_OF_MEMORY; return TM_ERROR_NONE; @@ -92,14 +88,14 @@ IDATA VMCALL jthread_raw_monitor_destroy(jrawMonitorID mon_ptr) { return TM_ERROR_INVALID_MONITOR; } - while(hythread_monitor_destroy((hythread_monitor_t)monitor) != TM_ERROR_NONE) { + while (hythread_monitor_destroy((hythread_monitor_t)monitor) != TM_ERROR_NONE) { if ((status = hythread_monitor_exit((hythread_monitor_t)monitor)) != TM_ERROR_NONE) - return status; + return status; } status =hymutex_lock(jvmti_monitor_table_lock); - if (status != TM_ERROR_NONE) return status; - array_delete(jvmti_monitor_table, (UDATA)mon_ptr); + if (status != TM_ERROR_NONE) return status; + array_delete(jvmti_monitor_table, (UDATA)mon_ptr); status =hymutex_unlock(jvmti_monitor_table_lock); return status; } @@ -129,7 +125,7 @@ IDATA VMCALL jthread_raw_monitor_enter(jrawMonitorID mon_ptr) { * @return 0 in case of successful attempt. */ IDATA VMCALL jthread_raw_monitor_try_enter(jrawMonitorID mon_ptr) { - hythread_monitor_t monitor; + hythread_monitor_t monitor; if (!(monitor = (hythread_monitor_t)array_get(jvmti_monitor_table, (UDATA)mon_ptr))) { return TM_ERROR_INVALID_MONITOR; } @@ -197,7 +193,7 @@ IDATA VMCALL jthread_raw_monitor_notify(jrawMonitorID mon_ptr) { if (!(monitor = (hythread_monitor_t)array_get(jvmti_monitor_table, (UDATA)mon_ptr))) { return TM_ERROR_INVALID_MONITOR; } - return hythread_monitor_notify(monitor); + return hythread_monitor_notify(monitor); } /** @@ -213,5 +209,5 @@ IDATA VMCALL jthread_raw_monitor_notify_all(jrawMonitorID mon_ptr) { if (!(monitor = (hythread_monitor_t)array_get(jvmti_monitor_table, (UDATA)mon_ptr))) { return TM_ERROR_INVALID_MONITOR; } - return hythread_monitor_notify_all(monitor); + return hythread_monitor_notify_all(monitor); } diff --git vm/thread/src/thread_ti_others.c vm/thread/src/thread_ti_others.c index 406e6a9..972d0c1 100644 --- vm/thread/src/thread_ti_others.c +++ vm/thread/src/thread_ti_others.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.4 $ - */ - /** * @file thread_ti_others.c * @brief JVMTI peak related functions @@ -53,14 +48,14 @@ IDATA jthread_get_peak_thread_count (jint *threads_count_ptr) { * * @param[in] java_thread */ -JVMTILocalStorage* jthread_get_jvmti_local_storage(jthread java_thread){ +JVMTILocalStorage* jthread_get_jvmti_local_storage(jthread java_thread) { jvmti_thread_t tm_java_thread; hythread_t tm_native_thread; - tm_native_thread = vm_jthread_get_tm_data(java_thread); - tm_java_thread = hythread_get_private_data(tm_native_thread); + tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_java_thread = hythread_get_private_data(tm_native_thread); - return &tm_java_thread->jvmti_local_storage; + return &tm_java_thread->jvmti_local_storage; } diff --git vm/thread/src/thread_ti_timing.c vm/thread/src/thread_ti_timing.c index eee5e47..8fe3c2d 100644 --- vm/thread/src/thread_ti_timing.c +++ vm/thread/src/thread_ti_timing.c @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @author Sergey Petrovsky - * @version $Revision: 1.1.2.7 $ - */ - /** * @file thread_ti_timing.c * @brief JVMTI timing related functions @@ -39,13 +34,13 @@ */ IDATA VMCALL jthread_get_thread_blocked_time(jthread java_thread, jlong *nanos_ptr) { - jvmti_thread_t tm_java_thread; + jvmti_thread_t tm_java_thread; hythread_t tm_native_thread; - assert(java_thread); - assert(nanos_ptr); - tm_native_thread = vm_jthread_get_tm_data(java_thread); - tm_java_thread = hythread_get_private_data(tm_native_thread); + assert(java_thread); + assert(nanos_ptr); + tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_java_thread = hythread_get_private_data(tm_native_thread); *nanos_ptr = tm_java_thread->blocked_time; return TM_ERROR_NONE; @@ -90,13 +85,13 @@ IDATA VMCALL jthread_get_thread_cpu_timer_info(jvmtiTimerInfo* info_ptr) { IDATA VMCALL jthread_get_thread_user_cpu_time(jthread java_thread, jlong *nanos_ptr) { hythread_t tm_native_thread; - apr_time_t kernel_time; - apr_time_t user_time; + apr_time_t kernel_time; + apr_time_t user_time; - assert(java_thread); - assert(nanos_ptr); - tm_native_thread = vm_jthread_get_tm_data(java_thread); - apr_thread_times(tm_native_thread->os_handle, &user_time, &kernel_time); + assert(java_thread); + assert(nanos_ptr); + tm_native_thread = vm_jthread_get_tm_data(java_thread); + apr_thread_times(tm_native_thread->os_handle, &user_time, &kernel_time); *nanos_ptr = user_time; return TM_ERROR_NONE; @@ -110,13 +105,13 @@ IDATA VMCALL jthread_get_thread_user_cpu_time(jthread java_thread, jlong *nanos_ */ IDATA VMCALL jthread_get_thread_waited_time(jthread java_thread, jlong *nanos_ptr) { - jvmti_thread_t tm_java_thread; + jvmti_thread_t tm_java_thread; hythread_t tm_native_thread; - assert(java_thread); - assert(nanos_ptr); - tm_native_thread = vm_jthread_get_tm_data(java_thread); - tm_java_thread = hythread_get_private_data(tm_native_thread); + assert(java_thread); + assert(nanos_ptr); + tm_native_thread = vm_jthread_get_tm_data(java_thread); + tm_java_thread = hythread_get_private_data(tm_native_thread); *nanos_ptr = tm_java_thread->waited_time; return TM_ERROR_NONE;