Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[mono][wasm] Disable AOTing methods which contain catch clauses insid…
…e finally/filter clauses.

When the ENDFINALLY opcode of the outer clause is encountered
while executing the inner catch clause from run_with_il_state (),
it will assert since it doesn't know where to continue execution.
  • Loading branch information
vargaz committed Nov 21, 2022
commit 90b324f31f866b0cb7b87355d6c2bec59264e9c4
2 changes: 0 additions & 2 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6667,8 +6667,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b

if (cfg->llvm_only && cfg->interp && cfg->method == method && !cfg->deopt && !cfg->interp_entry_only) {
if (header->num_clauses) {
/* deopt is only disabled for gsharedvt */
g_assert (cfg->gsharedvt);
for (guint i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = &header->clauses [i];
/* Finally clauses are checked after the remove_finally pass */
Expand Down
28 changes: 25 additions & 3 deletions src/mono/mono/mini/mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -3303,9 +3303,31 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts
}

if (cfg->llvm_only && cfg->interp && !cfg->interp_entry_only && header->num_clauses) {
cfg->deopt = TRUE;
/* Can't reconstruct inlined state */
cfg->disable_inline = TRUE;
gboolean can_deopt = TRUE;
/*
* Can't handle catch clauses inside finally clauses right now.
* When the ENDFINALLY opcode of the outer clause is encountered
* while executing the inner catch clause from run_with_il_state (),
* it will assert since it doesn't know where to continue execution.
*/
for (guint i = 0; i < cfg->header->num_clauses; ++i) {
for (guint j = 0; j < cfg->header->num_clauses; ++j) {
MonoExceptionClause *clause1 = &cfg->header->clauses [i];
MonoExceptionClause *clause2 = &cfg->header->clauses [j];

if (i != j && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset) {
if (clause1->flags == MONO_EXCEPTION_CLAUSE_NONE && clause2->flags != MONO_EXCEPTION_CLAUSE_NONE) {
can_deopt = FALSE;
break;
}
}
}
}
if (can_deopt) {
cfg->deopt = TRUE;
/* Can't reconstruct inlined state */
cfg->disable_inline = TRUE;
}
}

#ifdef ENABLE_LLVM
Expand Down