Add support for precise unwind info in epilogs on amd64:
[mono.git] / mono / mini / aot-runtime.c
index af436f531a1d212a960242567f205d4c5f6efe57..3c9064b885d26a203dc19b01836b11e696780383 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/wait.h>  /* for WIFEXITED, WEXITSTATUS */
 #endif
 
+#include <mono/metadata/abi-details.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/metadata/class.h>
 #include <mono/metadata/object.h>
@@ -1677,8 +1678,8 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                align_int64 = align;
        }
 #else
-       align_double = __alignof__ (double);
-       align_int64 = __alignof__ (gint64);
+       align_double = MONO_ABI_ALIGNOF (double);
+       align_int64 = MONO_ABI_ALIGNOF (gint64);
 #endif
 
        /* Sanity check */
@@ -2505,10 +2506,21 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
                jinfo->from_aot = 1;
        }
 
+       /*
+        * Set all the 'has' flags, the mono_jit_info_get () functions depends on this to
+        * compute the addresses of data blocks.
+        */
+       if (has_generic_jit_info)
+               jinfo->has_generic_jit_info = 1;
+       if (has_arch_eh_jit_info)
+               jinfo->has_arch_eh_info = 1;
+       if (has_try_block_holes)
+               jinfo->has_try_block_holes = 1;
+
        if (has_try_block_holes) {
                MonoTryBlockHoleTableJitInfo *table;
 
-               jinfo->has_try_block_holes = 1;
+               g_assert (jinfo->has_try_block_holes);
 
                table = mono_jit_info_get_try_block_hole_table_info (jinfo);
                g_assert (table);
@@ -2525,7 +2537,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
        if (has_arch_eh_jit_info) {
                MonoArchEHJitInfo *eh_info;
 
-               jinfo->has_arch_eh_info = 1;
+               g_assert (jinfo->has_arch_eh_info);
 
                eh_info = mono_jit_info_get_arch_eh_info (jinfo);
                eh_info->stack_size = decode_value (p, &p);
@@ -2543,7 +2555,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
                MonoGenericJitInfo *gi;
                int len;
 
-               jinfo->has_generic_jit_info = 1;
+               g_assert (jinfo->has_generic_jit_info);
 
                gi = mono_jit_info_get_generic_jit_info (jinfo);
                g_assert (gi);
@@ -2688,7 +2700,8 @@ mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
                mono_aot_unlock ();
        }
 
-       p = amodule->unwind_info + ji->used_regs;
+       /* The upper 16 bits of ji->used_regs might contain the epilog offset */
+       p = amodule->unwind_info + (ji->used_regs & 0xffff);
        *unwind_info_len = decode_value (p, &p);
        return p;
 }