Ejemplo n.º 1
0
static void jthread_remove_owned_monitor(jobject monitor)
{
    vm_thread_t vm_thread = jthread_self_vm_thread();
    assert(vm_thread);
    jvmti_thread_t jvmti_thread = &vm_thread->jvmti_thread;

    if (!jvmti_thread) {
        // nothing to do
        return;
    }
    CTRACE(("TM: remove owned monitor: %x", monitor));

    for (int i = jvmti_thread->owned_monitors_nmb - 1; i >= 0; i--) {
        if (vm_objects_are_equal(jvmti_thread->owned_monitors[i], monitor)) {
            int disable_status = hythread_reset_suspend_disable();
            vm_thread->jni_env->DeleteGlobalRef(jvmti_thread->owned_monitors[i]);
            hythread_set_suspend_disable(disable_status);
            int j;
            for (j = i; j < jvmti_thread->owned_monitors_nmb - 1; j++) {
                jvmti_thread->owned_monitors[j] =
                    jvmti_thread->owned_monitors[j + 1];
            }
            jvmti_thread->owned_monitors[j] = NULL;
            jvmti_thread->owned_monitors_nmb--;
            return;
        }
    }
} // jthread_remove_owned_monitor
Ejemplo n.º 2
0
int
jthread_find_deads(jobject thread, jobject *deads, int base, int top)
{
    for (int i = 0; i < top; i++) {
        if (vm_objects_are_equal(thread, deads[i])) {
            return 1;
        }
    }
    return 0;
}
Ejemplo n.º 3
0
/**
 * Returns true if specified thread holds the lock associated with the given monitor.
 *
 * @param[in] thread thread which may hold the lock
 * @param[in] monitor object those monitor is possibly locked
 * @return true if thread holds the lock, false otherwise;
 */
jboolean VMCALL jthread_holds_lock(jthread thread, jobject monitor)
{
    jthread lock_owner;
    IDATA status = jthread_get_lock_owner(monitor, &lock_owner);
    assert(status == TM_ERROR_NONE);

    hythread_suspend_disable();
    jboolean result = vm_objects_are_equal(thread, lock_owner);
    hythread_suspend_enable();

    return result;
} // jthread_holds_lock