[interp] Remove abort protection of finally blocks (#51309)
authorVlad Brezae <brezaevlad@gmail.com>
Mon, 3 May 2021 21:45:18 +0000 (00:45 +0300)
committerGitHub <noreply@github.com>
Mon, 3 May 2021 21:45:18 +0000 (00:45 +0300)
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/mintops.def
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/mini-exceptions.c

index 1dc34ae82d92b40439b8cb63411247953ae57212..81f6e052332483d3914fdc59da26da9b1ca812fd 100644 (file)
@@ -6171,12 +6171,7 @@ call:
                        ip += 4;
                        MINT_IN_BREAK;
                }
-               MINT_IN_CASE(MINT_START_ABORT_PROT)
-                       mono_threads_begin_abort_protected_block ();
-                       ip ++;
-                       MINT_IN_BREAK;
                MINT_IN_CASE(MINT_ENDFINALLY) {
-                       mono_threads_end_abort_protected_block ();
                        guint16 clause_index = *(ip + 1);
 
                        guint16 *ret_ip = *(guint16**)(locals + frame->imethod->clause_data_offsets [clause_index]);
index b3076e7b426acb75d0342ad5af51c45c44eee3be..76c39f0da42d11b4ed978672defa883f9cf5a2e2 100644 (file)
@@ -689,8 +689,6 @@ OPDEF(MINT_SDB_SEQ_POINT, "sdb_seq_point", 1, 0, 0, MintOpNoArgs)
 OPDEF(MINT_SDB_BREAKPOINT, "sdb_breakpoint", 1, 0, 0, MintOpNoArgs)
 OPDEF(MINT_LD_DELEGATE_METHOD_PTR, "ld_delegate_method_ptr", 3, 1, 1, MintOpNoArgs)
 
-OPDEF(MINT_START_ABORT_PROT, "start_abort_protected", 1, 0, 0, MintOpNoArgs)
-
 // Math intrinsics
 // double
 OPDEF(MINT_ABS, "abs", 3, 1, 1, MintOpNoArgs)
index 5512ea8417387e6ddca5c21d28d0133ae43e32bc..c3fc2c14a1ef21faeb71dac4f17a7f41c48a1ad8 100644 (file)
@@ -4494,17 +4494,6 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
                                init_bb_stack_state (td, new_bb);
                        }
                        link_bblocks = TRUE;
-                       if (!inlining) {
-                               int index = td->clause_indexes [in_offset];
-                               if (index != -1) {
-                                       MonoExceptionClause *clause = &header->clauses [index];
-                                       if ((clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY ||
-                                               clause->flags == MONO_EXCEPTION_CLAUSE_FAULT) &&
-                                                       in_offset == clause->handler_offset)
-                                               interp_add_ins (td, MINT_START_ABORT_PROT);
-                               }
-                       }
-
                }
                td->offset_to_bb [in_offset] = td->cbb;
                td->in_start = td->ip;
index 5ad106b7c88214e222565b7446716ee0102a6c4c..7b7f7ad8799e15299e8f6be08b12a2b9dede7e07 100644 (file)
@@ -2468,32 +2468,6 @@ handle_exception_first_pass (MonoContext *ctx, MonoObject *obj, gint32 *out_filt
        g_assert_not_reached ();
 }
 
-/*
- * We implement delaying of aborts when in finally blocks by reusing the
- * abort protected block mechanism. The problem is that when throwing an
- * exception in a finally block we don't get to exit the protected block.
- * We exit it here when unwinding. Given that the order of the clauses
- * in the jit info is from inner clauses to the outer clauses, when we
- * want to exit the finally blocks inner to the clause that handles the
- * exception, we need to search up to its index.
- *
- * FIXME We should do this inside interp, but with mixed mode we can
- * resume directly, without giving control back to the interp.
- */
-static void
-interp_exit_finally_abort_blocks (MonoJitInfo *ji, int start_clause, int end_clause, gpointer ip)
-{
-       int i;
-       for (i = start_clause; i < end_clause; i++) {
-               MonoJitExceptionInfo *ei = &ji->clauses [i];
-               if (ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY &&
-                               ip >= ei->handler_start &&
-                               ip < ei->data.handler_end) {
-                       mono_threads_end_abort_protected_block ();
-               }
-       }
-}
-
 static MonoException *
 mono_get_exception_runtime_wrapped_checked (MonoObject *wrapped_exception_raw, MonoError *error)
 {
@@ -2891,7 +2865,6 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                                        mini_set_abort_threshold (&frame);
 
                                        if (in_interp) {
-                                               interp_exit_finally_abort_blocks (ji, clause_index_start, i, ip);
                                                /*
                                                 * ctx->pc points into the interpreter, after the call which transitioned to
                                                 * JITted code. Store the unwind state into the
@@ -2987,9 +2960,6 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                        }
                }
 
-               if (in_interp)
-                       interp_exit_finally_abort_blocks (ji, clause_index_start, ji->num_clauses, ip);
-
                if (MONO_PROFILER_ENABLED (method_exception_leave) &&
                    mono_profiler_get_call_instrumentation_flags (method) & MONO_PROFILER_CALL_INSTRUMENTATION_EXCEPTION_LEAVE) {
                        jit_tls->orig_ex_ctx_set = TRUE;