Skip to content

Commit

Permalink
[interp] Use frame_addr as base pointer in more places (mono#7128)
Browse files Browse the repository at this point in the history
When unwinding with the interpreter, we don't make use at all of the MonoContext's SP pointer.
  • Loading branch information
BrzVlad authored and luhenry committed Feb 21, 2018
1 parent 5b0503a commit 705223f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ interp_throw (ThreadContext *context, MonoException *ex, InterpFrame *frame, gco

MonoContext ctx;
memset (&ctx, 0, sizeof (MonoContext));
MONO_CONTEXT_SET_SP (&ctx, frame);

/*
* Call the JIT EH code. The EH code will call back to us using:
Expand Down
18 changes: 8 additions & 10 deletions mono/mini/mini-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ first_managed (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer addr)
return TRUE;
}

*data = MONO_CONTEXT_GET_SP (ctx);
*data = frame->frame_addr;
g_assert (*data);
return TRUE;
}
Expand All @@ -152,9 +152,9 @@ mini_clear_abort_threshold (void)
}

static inline void
mini_set_abort_threshold (MonoContext *ctx)
mini_set_abort_threshold (StackFrameInfo *frame)
{
gpointer sp = MONO_CONTEXT_GET_SP (ctx);
gpointer sp = frame->frame_addr;
MonoJitTlsData *jit_tls = mono_get_jit_tls ();
// Only move it up, to avoid thrown/caught
// exceptions lower in the stack from triggering
Expand Down Expand Up @@ -726,8 +726,6 @@ unwinder_unwind_frame (Unwinder *unwinder,
if (frame->type == FRAME_TYPE_INTERP_TO_MANAGED) {
unwinder->in_interp = TRUE;
mini_get_interp_callbacks ()->frame_iter_init (&unwinder->interp_iter, frame->interp_exit_data);
parent = mini_get_interp_callbacks ()->frame_get_parent (frame->interp_exit_data);
MONO_CONTEXT_SET_SP (new_ctx, parent);
}
unwinder->last_frame_addr = frame->frame_addr;
return TRUE;
Expand Down Expand Up @@ -1811,7 +1809,7 @@ handle_exception_first_pass (MonoContext *ctx, MonoObject *obj, gint32 *out_filt
setup_stack_trace (mono_ex, dynamic_methods, &trace_ips);
g_slist_free (dynamic_methods);
/* mono_debugger_agent_handle_exception () needs this */
mini_set_abort_threshold (ctx);
mini_set_abort_threshold (&frame);
MONO_CONTEXT_SET_IP (ctx, ei->handler_start);
frame.native_offset = (char*)ei->handler_start - (char*)ji->code_start;
*catch_frame = frame;
Expand Down Expand Up @@ -2015,7 +2013,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu

// FIXME: This runs managed code so it might cause another stack overflow when
// we are handling a stack overflow
mini_set_abort_threshold (ctx);
mini_set_abort_threshold (&catch_frame);
mono_unhandled_exception (obj);
} else {
gboolean unhandled = FALSE;
Expand Down Expand Up @@ -2198,7 +2196,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
jit_tls->orig_ex_ctx_set = TRUE;
MONO_PROFILER_RAISE (exception_clause, (method, i, ei->flags, ex_obj));
jit_tls->orig_ex_ctx_set = FALSE;
mini_set_abort_threshold (ctx);
mini_set_abort_threshold (&frame);

if (in_interp) {
/*
Expand Down Expand Up @@ -2262,11 +2260,11 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
jit_tls->resume_state.lmf = lmf;
jit_tls->resume_state.first_filter_idx = first_filter_idx;
jit_tls->resume_state.filter_idx = filter_idx;
mini_set_abort_threshold (ctx);
mini_set_abort_threshold (&frame);
MONO_CONTEXT_SET_IP (ctx, ei->handler_start);
return 0;
} else {
mini_set_abort_threshold (ctx);
mini_set_abort_threshold (&frame);
if (in_interp) {
gboolean has_ex = mini_get_interp_callbacks ()->run_finally (&frame, i, ei->handler_start);
if (has_ex)
Expand Down
1 change: 0 additions & 1 deletion mono/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ INTERP_DISABLED_TESTS = \
safehandle.2.exe \
stackframes-async.2.exe \
static-constructor.exe \
thread6.exe \
threadpool-exceptions2.exe \
threadpool-exceptions4.exe \
threadpool-exceptions5.exe \
Expand Down

0 comments on commit 705223f

Please sign in to comment.