// function can be cold from suspen enabled and disabled mode 
void exn_rethrow()
{
    // exception is throwing, so suspend can be disabeled without following enabling
    if (hythread_is_suspend_enabled()) {
        tmn_suspend_disable();
    }

    assert(!hythread_is_suspend_enabled());

    BEGIN_RAISE_AREA;

#ifndef VM_LAZY_EXCEPTION
    ManagedObject *exn = get_exception_object_internal();
    assert(exn);
    clear_exception_internal();

    check_pop_frame(exn);

    exn_throw_for_JIT(exn, NULL, NULL, NULL, NULL);
#else
    vm_thread_t vm_thread = p_TLS_vmthread;
    if (NULL != vm_thread->thread_exception.exc_object) {
        ManagedObject* exn_mng_object = vm_thread->thread_exception.exc_object;
        clear_exception_internal();

        check_pop_frame(exn_mng_object);

        exn_throw_for_JIT(exn_mng_object, NULL, NULL, NULL, NULL);
    } else if (NULL != vm_thread->thread_exception.exc_class) {
        Class * exc_class = vm_thread->thread_exception.exc_class;
        const char* exc_message = vm_thread->thread_exception.exc_message;
        jthrowable exc_cause = NULL;

        if (vm_thread->thread_exception.exc_cause){
            exc_cause = oh_allocate_local_handle();
            exc_cause->object = vm_thread->thread_exception.exc_cause;
        }
        clear_exception_internal();

        exn_throw_by_class_internal(exc_class, exc_message, exc_cause);
    } else {
        LDIE(60, "There is no exception.");
    }
#endif
    DIE(("It's Unreachable place."));

    END_RAISE_AREA;
}   //exn_rethrow
示例#2
0
// function can be safe point & should be called with disable reqursion = 1
void exn_athrow(ManagedObject* exn_obj, Class_Handle exn_class,
    Method_Handle exn_constr, U_8* exn_constr_args)
{
    assert(!hythread_is_suspend_enabled());
    BEGIN_RAISE_AREA;
    exn_throw_for_JIT(exn_obj, exn_class, exn_constr, exn_constr_args, NULL);
    END_RAISE_AREA;
}
void exn_throw_object_internal(jthrowable exc_object)
{
    BEGIN_RAISE_AREA;
    // functions can be invoked in suspend disabled and enabled state
    if (hythread_is_suspend_enabled()) {
        tmn_suspend_disable();
    }
    assert(!hythread_is_suspend_enabled());
    CTRACE(("%s", "exn_throw_object(), delegating to exn_throw_for_JIT()"));
    exn_throw_for_JIT(exc_object->object, NULL, NULL, NULL, NULL);
    END_RAISE_AREA;
}
void exn_throw_by_class_internal(Class* exc_class, const char* exc_message,
    jthrowable exc_cause)
{
    BEGIN_RAISE_AREA;
    // functions can be invoked in suspend disabled and enabled state
    if (!hythread_is_suspend_enabled()) {
        // exception is throwing, so suspend can be enabled safely
        tmn_suspend_enable();
    }
    assert(hythread_is_suspend_enabled());
#ifdef VM_LAZY_EXCEPTION
    //set_unwindable(false);

    jvalue args[3];
    Method* exc_init = prepare_exc_creating(
            exc_class, args, exc_message, exc_cause);

    if (NULL == exc_init) {
        CTRACE(("%s",
            "exn_throw_by_class(),create exception and delegating to exn_throw_for_JIT()"));
        jthrowable exc_object = exn_create(exc_class, exc_message, exc_cause);
        exn_rethrow_if_pending();
        //set_unwindable(true);
        exn_throw_object_internal(exc_object);
    } else {
        CTRACE(("%s", "exn_throw_by_class(), lazy delegating to exn_throw_for_JIT()"));
        //set_unwindable(true);

        // no return, so enable isn't required
        tmn_suspend_disable();
        exn_throw_for_JIT(NULL, exc_class, exc_init, NULL, args);
        //tmn_suspend_enable();
    }
#else
    jthrowable exc_object = exn_create(exc_class, exc_message, exc_cause);
    exn_rethrow_if_pending();
    exn_throw_object_internal(exc_object);
#endif
    END_RAISE_AREA;
}