X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fexceptions-x86.c;h=14e8f6111c15ce90bac97f37ab15c38b85ec27ae;hb=3e69ff3ae72acec33c471236da49ed6c78b26dc4;hp=2a4aae744e1fce2678c83e74d4c3d1f47d89c76d;hpb=799643a6f7cf882d88fd7275bd40e7787b10ef1d;p=mono.git diff --git a/mono/mini/exceptions-x86.c b/mono/mini/exceptions-x86.c index 2a4aae744e1..14e8f6111c1 100644 --- a/mono/mini/exceptions-x86.c +++ b/mono/mini/exceptions-x86.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -163,7 +163,7 @@ win32_handle_stack_overflow (EXCEPTION_POINTERS* ep, struct sigcontext *sctx) do { MonoContext new_ctx; - mono_arch_find_jit_info (domain, jit_tls, &rji, &ctx, &new_ctx, &lmf, NULL, &frame); + mono_arch_unwind_frame (domain, jit_tls, &rji, &ctx, &new_ctx, &lmf, NULL, &frame); if (!frame.ji) { g_warning ("Exception inside function without unwind info"); g_assert_not_reached (); @@ -456,6 +456,7 @@ void mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc, mgreg_t eip, gboolean rethrow) { + MonoError error; MonoContext ctx; ctx.esp = regs [X86_ESP]; @@ -473,13 +474,14 @@ mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc, g_assert ((ctx.esp % MONO_ARCH_FRAME_ALIGNMENT) == 0); #endif - if (mono_object_isinst (exc, mono_defaults.exception_class)) { + if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) { MonoException *mono_ex = (MonoException*)exc; if (!rethrow) { mono_ex->stack_trace = NULL; mono_ex->trace_ips = NULL; } } + mono_error_assert_ok (&error); /* adjust eip so that it point into the call instruction */ ctx.eip -= 1; @@ -564,8 +566,7 @@ get_throw_trampoline (const char *name, gboolean rethrow, gboolean llvm, gboolea * <- esp (unaligned on apple) */ - mono_add_unwind_op_def_cfa (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_ESP, 4); - mono_add_unwind_op_offset (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_NREG, -4); + unwind_ops = mono_arch_get_cie_program (); /* Alloc frame */ x86_alu_reg_imm (code, X86_SUB, X86_ESP, stack_size); @@ -717,6 +718,7 @@ void mono_arch_exceptions_init (void) { guint8 *tramp; + MonoTrampInfo *tinfo; /* * If we're running WoW64, we need to set the usermode exception policy @@ -745,31 +747,37 @@ mono_arch_exceptions_init (void) } /* LLVM needs different throw trampolines */ - tramp = get_throw_trampoline ("llvm_throw_exception_trampoline", FALSE, TRUE, FALSE, FALSE, FALSE, NULL, FALSE); + tramp = get_throw_trampoline ("llvm_throw_exception_trampoline", FALSE, TRUE, FALSE, FALSE, FALSE, &tinfo, FALSE); mono_register_jit_icall (tramp, "llvm_throw_exception_trampoline", NULL, TRUE); + mono_tramp_info_register (tinfo, NULL); - tramp = get_throw_trampoline ("llvm_rethrow_exception_trampoline", TRUE, TRUE, FALSE, FALSE, FALSE, NULL, FALSE); + tramp = get_throw_trampoline ("llvm_rethrow_exception_trampoline", TRUE, TRUE, FALSE, FALSE, FALSE, &tinfo, FALSE); mono_register_jit_icall (tramp, "llvm_rethrow_exception_trampoline", NULL, TRUE); + mono_tramp_info_register (tinfo, NULL); - tramp = get_throw_trampoline ("llvm_throw_corlib_exception_trampoline", FALSE, TRUE, TRUE, FALSE, FALSE, NULL, FALSE); + tramp = get_throw_trampoline ("llvm_throw_corlib_exception_trampoline", FALSE, TRUE, TRUE, FALSE, FALSE, &tinfo, FALSE); mono_register_jit_icall (tramp, "llvm_throw_corlib_exception_trampoline", NULL, TRUE); + mono_tramp_info_register (tinfo, NULL); - tramp = get_throw_trampoline ("llvm_throw_corlib_exception_abs_trampoline", FALSE, TRUE, TRUE, TRUE, FALSE, NULL, FALSE); + tramp = get_throw_trampoline ("llvm_throw_corlib_exception_abs_trampoline", FALSE, TRUE, TRUE, TRUE, FALSE, &tinfo, FALSE); mono_register_jit_icall (tramp, "llvm_throw_corlib_exception_abs_trampoline", NULL, TRUE); + mono_tramp_info_register (tinfo, NULL); - tramp = get_throw_trampoline ("llvm_resume_unwind_trampoline", FALSE, FALSE, FALSE, FALSE, TRUE, NULL, FALSE); + tramp = get_throw_trampoline ("llvm_resume_unwind_trampoline", FALSE, FALSE, FALSE, FALSE, TRUE, &tinfo, FALSE); mono_register_jit_icall (tramp, "llvm_resume_unwind_trampoline", NULL, TRUE); + mono_tramp_info_register (tinfo, NULL); - signal_exception_trampoline = mono_x86_get_signal_exception_trampoline (NULL, FALSE); + signal_exception_trampoline = mono_x86_get_signal_exception_trampoline (&tinfo, FALSE); + mono_tramp_info_register (tinfo, NULL); } /* - * mono_arch_find_jit_info: + * mono_arch_unwind_frame: * * See exceptions-amd64.c for docs. */ gboolean -mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, +mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInfo *ji, MonoContext *ctx, MonoContext *new_ctx, MonoLMF **lmf, mgreg_t **save_locations, @@ -788,7 +796,10 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, guint32 unwind_info_len; guint8 *unwind_info; - frame->type = FRAME_TYPE_MANAGED; + if (ji->is_trampoline) + frame->type = FRAME_TYPE_TRAMPOLINE; + else + frame->type = FRAME_TYPE_MANAGED; unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len); @@ -884,7 +895,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, gpointer mono_arch_ip_from_context (void *sigctx) { -#if defined(__native_client__) +#if defined(__native_client__) || defined(HOST_WATCHOS) printf("WARNING: mono_arch_ip_from_context() called!\n"); return (NULL); #elif defined(MONO_ARCH_USE_SIGACTION) @@ -931,11 +942,12 @@ mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot) start = code = mono_global_codeman_reserve (128); + /* FIXME no unwind before we push ip */ /* Caller ip */ x86_push_reg (code, X86_ECX); - mono_add_unwind_op_def_cfa (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_ESP, 4); - mono_add_unwind_op_offset (unwind_ops, (guint8*)NULL, (guint8*)NULL, X86_NREG, -4); + mono_add_unwind_op_def_cfa (unwind_ops, code, start, X86_ESP, 4); + mono_add_unwind_op_offset (unwind_ops, code, start, X86_NREG, -4); /* Fix the alignment to be what apple expects */ stack_size = 12;