/* Statistics */
static int unwind_info_size;
-#define unwind_lock() mono_mutex_lock (&unwind_mutex)
-#define unwind_unlock() mono_mutex_unlock (&unwind_mutex)
+#define unwind_lock() mono_os_mutex_lock (&unwind_mutex)
+#define unwind_unlock() mono_os_mutex_unlock (&unwind_mutex)
#ifdef TARGET_AMD64
static int map_hw_reg_to_dwarf_reg [] = { 0, 2, 1, 3, 7, 6, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
}
/*
- * mono_unwind_ops_encode:
+ * mono_unwind_ops_encode_full:
*
* Encode the unwind ops in UNWIND_OPS into the compact DWARF encoding.
* Return a pointer to malloc'ed memory.
+ * If ENABLE_EXTENSIONS is FALSE, avoid encoding the mono extension
+ * opcode (DW_CFA_mono_advance_loc).
*/
guint8*
-mono_unwind_ops_encode (GSList *unwind_ops, guint32 *out_len)
+mono_unwind_ops_encode_full (GSList *unwind_ops, guint32 *out_len, gboolean enable_extensions)
{
GSList *l;
MonoUnwindOp *op;
for (; l; l = l->next) {
int reg;
- op = l->data;
+ op = (MonoUnwindOp *)l->data;
/* Convert the register from the hw encoding to the dwarf encoding */
reg = mono_hw_reg_to_dwarf_reg (op->reg);
*p ++ = op->op;
break;
case DW_CFA_mono_advance_loc:
+ if (!enable_extensions)
+ break;
/* Only one location is supported */
g_assert (op->val == 0);
*p ++ = op->op;
g_assert (p - buf < 4096);
*out_len = p - buf;
- res = g_malloc (p - buf);
+ res = (guint8 *)g_malloc (p - buf);
memcpy (res, buf, p - buf);
return res;
}
+guint8*
+mono_unwind_ops_encode (GSList *unwind_ops, guint32 *out_len)
+{
+ return mono_unwind_ops_encode_full (unwind_ops, out_len, TRUE);
+}
+
#if 0
#define UNW_DEBUG(stmt) do { stmt; } while (0)
#else
void
mono_unwind_init (void)
{
- mono_mutex_init_recursive (&unwind_mutex);
+ mono_os_mutex_init_recursive (&unwind_mutex);
mono_counters_register ("Unwind info size", MONO_COUNTER_JIT | MONO_COUNTER_INT, &unwind_info_size);
}
{
int i;
- mono_mutex_destroy (&unwind_mutex);
+ mono_os_mutex_destroy (&unwind_mutex);
if (!cached_info)
return;
g_free (cached);
}
-
g_free (cached_info);
+
+ for (GSList *cursor = cached_info_list; cursor != NULL; cursor = cursor->next)
+ g_free (cursor->data);
+
+ g_slist_free (cached_info_list);
}
/*
}
}
- info = g_malloc (sizeof (MonoUnwindInfo) + unwind_info_len);
+ info = (MonoUnwindInfo *)g_malloc (sizeof (MonoUnwindInfo) + unwind_info_len);
info->len = unwind_info_len;
memcpy (&info->info, unwind_info, unwind_info_len);
mono_memory_barrier ();
- cached_info = new_table;
-
cached_info_list = g_slist_prepend (cached_info_list, cached_info);
+ cached_info = new_table;
+
cached_info_size *= 2;
}
p = (guint8*)ALIGN_TO ((mgreg_t)p, 4);
if (ex_info) {
- *ex_info = g_malloc0 (ncall_sites * sizeof (MonoJitExceptionInfo));
+ *ex_info = (MonoJitExceptionInfo *)g_malloc0 (ncall_sites * sizeof (MonoJitExceptionInfo));
*ex_info_len = ncall_sites;
}
if (type_info)
- *type_info = g_malloc0 (ncall_sites * sizeof (gpointer));
+ *type_info = (gpointer *)g_malloc0 (ncall_sites * sizeof (gpointer));
for (i = 0; i < ncall_sites; ++i) {
int block_start_offset, block_size, landing_pad;
g_assert (return_reg == DWARF_PC_REG);
buf_len = (cie + cie_len + 4 - cie_cfi) + (fde + fde_len + 4 - fde_cfi);
- buf = g_malloc0 (buf_len);
+ buf = (guint8 *)g_malloc0 (buf_len);
i = 0;
p = cie_cfi;
*out_len = i;
- return g_realloc (buf, i);
+ return (guint8 *)g_realloc (buf, i);
}
/*
cie_cfi_len = p - cie_cfi;
fde_cfi_len = (fde + fde_len - fde_cfi);
- buf = g_malloc0 (cie_cfi_len + fde_cfi_len);
+ buf = (guint8 *)g_malloc0 (cie_cfi_len + fde_cfi_len);
memcpy (buf, cie_cfi, cie_cfi_len);
memcpy (buf + cie_cfi_len, fde_cfi, fde_cfi_len);
GSList*
mono_unwind_get_cie_program (void)
{
-#if defined(TARGET_AMD64) || defined(TARGET_X86) || defined(TARGET_POWERPC)
+#if defined(TARGET_AMD64) || defined(TARGET_X86) || defined(TARGET_POWERPC) || defined(TARGET_ARM)
return mono_arch_get_cie_program ();
#else
return NULL;