projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2713 from gregoryyoung/master
[mono.git]
/
mono
/
mini
/
exceptions-x86.c
diff --git
a/mono/mini/exceptions-x86.c
b/mono/mini/exceptions-x86.c
old mode 100755
(executable)
new mode 100644
(file)
index
9cc25ad
..
14e8f61
--- a/
mono/mini/exceptions-x86.c
+++ b/
mono/mini/exceptions-x86.c
@@
-12,6
+12,9
@@
#include <glib.h>
#include <signal.h>
#include <string.h>
#include <glib.h>
#include <signal.h>
#include <string.h>
+#ifdef HAVE_UCONTEXT_H
+#include <ucontext.h>
+#endif
#include <mono/metadata/abi-details.h>
#include <mono/arch/x86/x86-codegen.h>
#include <mono/metadata/abi-details.h>
#include <mono/arch/x86/x86-codegen.h>
@@
-20,7
+23,7
@@
#include <mono/metadata/threads.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internal
s
.h>
#include <mono/metadata/mono-debug.h>
#include <mono/utils/mono-mmap.h>
#include <mono/metadata/mono-debug.h>
#include <mono/utils/mono-mmap.h>
@@
-31,7
+34,7
@@
static gpointer signal_exception_trampoline;
gpointer
static gpointer signal_exception_trampoline;
gpointer
-mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot)
MONO_INTERNAL
;
+mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot);
#ifdef TARGET_WIN32
static void (*restore_stack) (void *);
#ifdef TARGET_WIN32
static void (*restore_stack) (void *);
@@
-96,7
+99,7
@@
mono_win32_get_handle_stackoverflow (void)
x86_call_code (code, mono_domain_get);
/* get stack overflow exception from domain object */
x86_call_code (code, mono_domain_get);
/* get stack overflow exception from domain object */
- x86_mov_reg_membase (code, X86_EAX, X86_EAX,
MONO
_STRUCT_OFFSET (MonoDomain, stack_overflow_ex), 4);
+ x86_mov_reg_membase (code, X86_EAX, X86_EAX,
G
_STRUCT_OFFSET (MonoDomain, stack_overflow_ex), 4);
/* call mono_arch_handle_exception (sctx, stack_overflow_exception_obj) */
x86_push_reg (code, X86_EAX);
/* call mono_arch_handle_exception (sctx, stack_overflow_exception_obj) */
x86_push_reg (code, X86_EAX);
@@
-109,6
+112,9
@@
mono_win32_get_handle_stackoverflow (void)
/* return */
x86_ret (code);
/* return */
x86_ret (code);
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
return start;
}
@@
-157,7
+163,7
@@
win32_handle_stack_overflow (EXCEPTION_POINTERS* ep, struct sigcontext *sctx)
do {
MonoContext new_ctx;
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 ();
if (!frame.ji) {
g_warning ("Exception inside function without unwind info");
g_assert_not_reached ();
@@
-354,6
+360,9
@@
mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
g_slist_free (unwind_ops);
}
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
return start;
}
@@
-431,6
+440,9
@@
mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
g_slist_free (unwind_ops);
}
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
g_assert ((code - start) < kMaxCodeSize);
return start;
}
g_assert ((code - start) < kMaxCodeSize);
return start;
}
@@
-444,6
+456,7
@@
void
mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc,
mgreg_t eip, gboolean rethrow)
{
mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc,
mgreg_t eip, gboolean rethrow)
{
+ MonoError error;
MonoContext ctx;
ctx.esp = regs [X86_ESP];
MonoContext ctx;
ctx.esp = regs [X86_ESP];
@@
-461,11
+474,14
@@
mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc,
g_assert ((ctx.esp % MONO_ARCH_FRAME_ALIGNMENT) == 0);
#endif
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;
MonoException *mono_ex = (MonoException*)exc;
- if (!rethrow)
+ if (!rethrow)
{
mono_ex->stack_trace = NULL;
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;
/* adjust eip so that it point into the call instruction */
ctx.eip -= 1;
@@
-550,8
+566,7
@@
get_throw_trampoline (const char *name, gboolean rethrow, gboolean llvm, gboolea
* <return addr> <- esp (unaligned on apple)
*/
* <return addr> <- 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);
/* Alloc frame */
x86_alu_reg_imm (code, X86_SUB, X86_ESP, stack_size);
@@
-653,6
+668,9
@@
get_throw_trampoline (const char *name, gboolean rethrow, gboolean llvm, gboolea
g_slist_free (unwind_ops);
}
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
return start;
}
@@
-700,13
+718,14
@@
void
mono_arch_exceptions_init (void)
{
guint8 *tramp;
mono_arch_exceptions_init (void)
{
guint8 *tramp;
+ MonoTrampInfo *tinfo;
/*
* If we're running WoW64, we need to set the usermode exception policy
* for SEHs to behave. This requires hotfix http://support.microsoft.com/kb/976038
* or (eventually) Windows 7 SP1.
*/
/*
* If we're running WoW64, we need to set the usermode exception policy
* for SEHs to behave. This requires hotfix http://support.microsoft.com/kb/976038
* or (eventually) Windows 7 SP1.
*/
-#ifdef
HOS
T_WIN32
+#ifdef
TARGE
T_WIN32
DWORD flags;
FARPROC getter;
FARPROC setter;
DWORD flags;
FARPROC getter;
FARPROC setter;
@@
-728,31
+747,37
@@
mono_arch_exceptions_init (void)
}
/* LLVM needs different throw trampolines */
}
/* 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_register_jit_icall (tramp, "llvm_throw_exception_trampoline", NULL, TRUE);
+ mono_tramp_info_register (tinfo, NULL);
- tramp = get_throw_trampoline ("llvm_rethrow_exception_trampoline",
FALSE, 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_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_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_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_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
*
* 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,
MonoJitInfo *ji, MonoContext *ctx,
MonoContext *new_ctx, MonoLMF **lmf,
mgreg_t **save_locations,
@@
-771,7
+796,10
@@
mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
guint32 unwind_info_len;
guint8 *unwind_info;
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);
unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len);
@@
-867,7
+895,7
@@
mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
gpointer
mono_arch_ip_from_context (void *sigctx)
{
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)
printf("WARNING: mono_arch_ip_from_context() called!\n");
return (NULL);
#elif defined(MONO_ARCH_USE_SIGACTION)
@@
-914,11
+942,12
@@
mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot)
start = code = mono_global_codeman_reserve (128);
start = code = mono_global_codeman_reserve (128);
+ /* FIXME no unwind before we push ip */
/* Caller ip */
x86_push_reg (code, X86_ECX);
/* 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;
/* Fix the alignment to be what apple expects */
stack_size = 12;
@@
-943,6
+972,9
@@
mono_x86_get_signal_exception_trampoline (MonoTrampInfo **info, gboolean aot)
g_slist_free (unwind_ops);
}
g_slist_free (unwind_ops);
}
+ mono_arch_flush_icache (start, code - start);
+ mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
return start;
}
return start;
}