Skip to content

Commit

Permalink
[mono] Remove the llvmonly exception handling code, its not used any …
Browse files Browse the repository at this point in the history
…more. (#66875)
  • Loading branch information
vargaz authored Mar 22, 2022
1 parent f25b23e commit 894382d
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 320 deletions.
5 changes: 0 additions & 5 deletions src/mono/mono/metadata/jit-icall-reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,11 @@ MONO_JIT_ICALL (mini_llvmonly_resolve_vcall_gsharedvt) \
MONO_JIT_ICALL (mini_llvmonly_resolve_vcall_gsharedvt_fast) \
MONO_JIT_ICALL (mini_llvmonly_throw_nullref_exception) \
MONO_JIT_ICALL (mini_llvmonly_throw_aot_failed_exception) \
MONO_JIT_ICALL (mini_llvmonly_pop_lmf) \
MONO_JIT_ICALL (mini_llvmonly_interp_entry_gsharedvt) \
MONO_JIT_ICALL (mini_llvmonly_throw_exception) \
MONO_JIT_ICALL (mini_llvmonly_rethrow_exception) \
MONO_JIT_ICALL (mini_llvmonly_throw_corlib_exception) \
MONO_JIT_ICALL (mini_llvmonly_resume_exception) \
MONO_JIT_ICALL (mini_llvmonly_resume_exception_il_state) \
MONO_JIT_ICALL (mini_llvmonly_load_exception) \
MONO_JIT_ICALL (mini_llvmonly_clear_exception) \
MONO_JIT_ICALL (mini_llvmonly_match_exception) \
MONO_JIT_ICALL (mono_amd64_resume_unwind) \
MONO_JIT_ICALL (mono_amd64_start_gsharedvt_call) \
MONO_JIT_ICALL (mono_amd64_throw_corlib_exception) \
Expand Down
12 changes: 0 additions & 12 deletions src/mono/mono/mini/llvmonly-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,18 +975,6 @@ mini_llvmonly_throw_aot_failed_exception (const char *name)
mini_llvmonly_throw_exception ((MonoObject*)ex);
}

/*
* mini_llvmonly_pop_lmf:
*
* Pop LMF off the LMF stack.
*/
void
mini_llvmonly_pop_lmf (MonoLMF *lmf)
{
if (lmf->previous_lmf)
mono_set_lmf ((MonoLMF*)lmf->previous_lmf);
}

void
mini_llvmonly_interp_entry_gsharedvt (gpointer imethod, gpointer res, gpointer *args)
{
Expand Down
4 changes: 0 additions & 4 deletions src/mono/mono/mini/llvmonly-runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,14 @@ G_EXTERN_C void mini_llvmonly_throw_nullref_exception (void);

G_EXTERN_C void mini_llvmonly_throw_aot_failed_exception (const char *name);

G_EXTERN_C void mini_llvmonly_pop_lmf (MonoLMF *lmf);

G_EXTERN_C void mini_llvmonly_interp_entry_gsharedvt (gpointer imethod, gpointer res, gpointer *args);

/* These are implemented in mini-exceptions.c */
G_EXTERN_C void mini_llvmonly_throw_exception (MonoObject *ex);
G_EXTERN_C void mini_llvmonly_rethrow_exception (MonoObject *ex);
G_EXTERN_C void mini_llvmonly_throw_corlib_exception (guint32 ex_token_index);
G_EXTERN_C void mini_llvmonly_resume_exception (void);
G_EXTERN_C void mini_llvmonly_resume_exception_il_state (MonoLMF *lmf, gpointer info);
G_EXTERN_C MonoObject *mini_llvmonly_load_exception (void);
G_EXTERN_C void mini_llvmonly_clear_exception (void);
G_EXTERN_C gint32 mini_llvmonly_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end, gpointer rgctx, MonoObject *this_obj);

#endif
15 changes: 2 additions & 13 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6496,17 +6496,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
mono_emit_method_call (cfg, wrapper, args, NULL);
}

if (cfg->llvm_only && cfg->interp && cfg->method == method && !cfg->deopt) {
if (header->num_clauses) {
for (int i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = &header->clauses [i];
/* Finally clauses are checked after the remove_finally pass */

if (clause->flags != MONO_EXCEPTION_CLAUSE_FINALLY)
cfg->interp_entry_only = TRUE;
}
}
}
if (cfg->llvm_only)
g_assert (cfg->interp);

/* we use a separate basic block for the initialization code */
NEW_BBLOCK (cfg, init_localsbb);
Expand Down Expand Up @@ -8147,7 +8138,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b

#ifdef TARGET_WASM
if (common_call && needs_stack_walk && !cfg->deopt)
/* If an exception is thrown, the LMF is popped by a call to mini_llvmonly_pop_lmf () */
emit_pop_lmf (cfg);
#endif

Expand Down Expand Up @@ -11695,7 +11685,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b

#ifdef TARGET_WASM
if (cfg->lmf_var && !cfg->deopt) {
// mini_llvmonly_pop_lmf () might be called before emit_push_lmf () so initialize the LMF
cfg->cbb = init_localsbb;
EMIT_NEW_VARLOADA (cfg, ins, cfg->lmf_var, NULL);
int lmf_reg = ins->dreg;
Expand Down
72 changes: 0 additions & 72 deletions src/mono/mono/mini/mini-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3529,17 +3529,6 @@ llvmonly_reraise_exception (MonoException *e)
mini_llvmonly_rethrow_exception ((MonoObject*)e);
}

/*
* mini_llvmonly_resume_exception:
*
* Resume exception propagation.
*/
void
mini_llvmonly_resume_exception (void)
{
mono_llvm_cpp_throw_exception ();
}

static G_GNUC_UNUSED void
print_lmf_chain (MonoLMF *lmf)
{
Expand Down Expand Up @@ -3680,67 +3669,6 @@ mini_llvmonly_clear_exception (void)
mono_memory_barrier ();
}

/*
* mini_llvmonly_match_exception:
*
* Return the innermost clause containing REGION_START-REGION_END which can handle
* the current exception.
*/
gint32
mini_llvmonly_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end, gpointer rgctx, MonoObject *this_obj)
{
ERROR_DECL (error);
MonoJitTlsData *jit_tls = mono_get_jit_tls ();
MonoObject *exc;
gint32 index = -1;

g_assert (jit_tls->thrown_exc);
exc = mono_gchandle_get_target_internal (jit_tls->thrown_exc);
if (jit_tls->thrown_non_exc) {
/*
* Have to unwrap RuntimeWrappedExceptions if the
* method's assembly doesn't have a RuntimeCompatibilityAttribute.
*/
if (!wrap_non_exception_throws (jinfo_get_method (jinfo)))
exc = mono_gchandle_get_target_internal (jit_tls->thrown_non_exc);
}

for (int i = 0; i < jinfo->num_clauses; i++) {
MonoJitExceptionInfo *ei = &jinfo->clauses [i];
MonoClass *catch_class;

if (! (ei->try_offset == region_start && ei->try_offset + ei->try_len == region_end) )
continue;

catch_class = ei->data.catch_class;
if (mono_class_is_open_constructed_type (m_class_get_byval_arg (catch_class))) {
MonoGenericContext context;
MonoType *inflated_type;

g_assert (rgctx || this_obj);
context = mono_get_generic_context_from_stack_frame (jinfo, rgctx ? rgctx : this_obj->vtable);
inflated_type = mono_class_inflate_generic_type_checked (m_class_get_byval_arg (catch_class), &context, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */

catch_class = mono_class_from_mono_type_internal (inflated_type);
mono_metadata_free_type (inflated_type);
}

// FIXME: Handle edge cases handled in get_exception_catch_class
if (ei->flags == MONO_EXCEPTION_CLAUSE_NONE && mono_object_isinst_checked (exc, catch_class, error)) {
index = ei->clause_index;
break;
} else
mono_error_assert_ok (error);

if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
g_assert_not_reached ();
}
}

return index;
}

#if defined(ENABLE_LLVM) && defined(HAVE_UNWIND_H)
G_EXTERN_C _Unwind_Reason_Code mono_debug_personality (int a, _Unwind_Action b,
uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e)
Expand Down
Loading

0 comments on commit 894382d

Please sign in to comment.