void tested_threads_run_common(jvmtiStartFunction run_method_param){
    tested_thread_sturct_t *tts;
    JNIEnv * jni_env = jthread_get_JNI_env(jthread_self());

    reset_tested_thread_iterator(&tts);
    while(next_tested_thread(&tts)){
        tts->attrs.proc = run_method_param;
        tts->attrs.arg = tts;
        tf_assert_same_v(jthread_create_with_function(jni_env, tts->java_thread, &tts->attrs), TM_ERROR_NONE);
        tested_thread_wait_started(tts);
        tts->native_thread = jthread_get_native_thread(tts->java_thread);
    }
}
示例#2
0
static void ti_enumerate_thread(TIEnv *ti_env, VM_thread* thread)
{
    TIIterationState *state = ti_env->iteration_state;
    state->root_kind = JVMTI_HEAP_ROOT_THREAD;
    state->thread_tag = ti_env->tags->get(
            (Managed_Object_Handle)
            jthread_self()->object);

    if (interpreter_enabled()) {
        interpreter.interpreter_ti_enumerate_thread((jvmtiEnv*)ti_env, thread);
    } else {
        jitted_ti_enumerate_thread((jvmtiEnv*)ti_env, thread);
    }
}
void tested_threads_init(int mode){
        
    tested_thread_sturct_t *tts;
    jobject monitor;
    jrawMonitorID raw_monitor;
    JNIEnv * jni_env;
    IDATA status; 
    int i;
    
    jni_env = jthread_get_JNI_env(jthread_self());
        
    if (mode != TTS_INIT_DIFFERENT_MONITORS){
        monitor = new_jobject();
        status = jthread_monitor_init(monitor);
        tf_assert_same_v(status, TM_ERROR_NONE);
    }
    status = jthread_raw_monitor_create(&raw_monitor);
    tf_assert_same_v(status, TM_ERROR_NONE);

    reset_tested_thread_iterator(&tts);
    for (i = 0; i < MAX_TESTED_THREAD_NUMBER; i++){
        tts = &tested_threads[i];
        tts->my_index = i;
        tts->java_thread = new_jobject_thread(jni_env);
        tts->native_thread = NULL;
        tts->jvmti_start_proc_arg = &tts->jvmti_start_proc_arg;
        hysem_create(&tts->started, 0, 1);
        hysem_create(&tts->running, 0, 1);
        hysem_create(&tts->stop_request, 0, 1);
        hysem_create(&tts->ended, 0, 1);
        tts->phase = TT_PHASE_NONE;
        if (mode == TTS_INIT_DIFFERENT_MONITORS){
            monitor = new_jobject();
            status = jthread_monitor_init(monitor);
            tf_assert_same_v(status, TM_ERROR_NONE);
        }
        tts->monitor = monitor;
        tts->raw_monitor = raw_monitor;
        tts->excn = NULL;
    }
}