guint32 final_got_size;
/* Number of GOT entries reserved for trampolines */
guint32 num_trampoline_got_entries;
+ guint32 tramp_page_size;
guint32 num_trampolines [MONO_AOT_TRAMP_NUM];
guint32 trampoline_got_offset_base [MONO_AOT_TRAMP_NUM];
guint32 trampoline_size [MONO_AOT_TRAMP_NUM];
+ guint32 tramp_page_code_offsets [MONO_AOT_TRAMP_NUM];
MonoAotOptions aot_opts;
guint32 nmethods;
* calling code.
*/
static void
-arch_emit_direct_call (MonoAotCompile *acfg, const char *target, gboolean external, int *call_size)
+arch_emit_direct_call (MonoAotCompile *acfg, const char *target, gboolean external, MonoJumpInfo *ji, int *call_size)
{
#if defined(TARGET_X86) || defined(TARGET_AMD64)
/* Need to make sure this is exactly 5 bytes long */
if (!acfg->aot_opts.use_trampolines_page)
return;
+ acfg->tramp_page_size = mono_pagesize ();
+
sprintf (symbol, "%sspecific_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, mono_pagesize ());
emit_global (acfg, symbol, TRUE);
if (direct_call) {
int call_size;
- arch_emit_direct_call (acfg, direct_call_target, external_call, &call_size);
+ arch_emit_direct_call (acfg, direct_call_target, external_call, patch_info, &call_size);
i += call_size - 1;
} else {
int code_size;
MonoJumpInfo *ji;
GSList *unwind_ops;
+ g_assert (info);
+
name = info->name;
code = info->code;
code_size = info->code_size;
}
emit_label (acfg, end_symbol);
+ emit_int32 (acfg, 0);
}
arch_emit_specific_trampoline_pages (acfg);
}
sprintf (symbol, "unbox_trampolines_end");
emit_label (acfg, symbol);
+ emit_int32 (acfg, 0);
}
static void
emit_int32 (acfg, __alignof__ (gint64));
#endif
emit_int32 (acfg, MONO_TRAMPOLINE_NUM);
+ emit_int32 (acfg, acfg->tramp_page_size);
+ for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
+ emit_int32 (acfg, acfg->tramp_page_code_offsets [i]);
if (acfg->aot_opts.static_link) {
char *p;
acfg->aot_opts.nrgctx_fetch_trampolines = 128;
acfg->aot_opts.ngsharedvt_arg_trampolines = 128;
acfg->aot_opts.llvm_path = g_strdup ("");
-#if MONOTOUCH
+#ifdef MONOTOUCH
acfg->aot_opts.use_trampolines_page = TRUE;
#endif
guint8 *plt_end;
guint8 *blob;
gint32 *code_offsets;
-#ifdef MONOTOUCH
gpointer *method_addresses;
-#endif
/* This contains <offset, index> pairs sorted by offset */
/* This is needed because LLVM emitted methods can be in any order */
gint32 *sorted_code_offsets;
}
amodule->code_offsets = info->code_offsets;
-#ifdef MONOTOUCH
amodule->method_addresses = info->method_addresses;
-#endif
amodule->code = info->methods;
#ifdef TARGET_ARM
/* Mask out thumb interop bit */
amodule->code_offsets = g_malloc0 (amodule->info.nmethods * sizeof (gint32));
for (i = 0; i < amodule->info.nmethods; ++i) {
/* method_addresses () contains a table of branches, since the ios linker can update those correctly */
- void *addr = get_arm_bl_target ((guint32*)(amodule->method_addresses + i));
+ void *addr = get_arm_bl_target ((guint32*)amodule->method_addresses + i);
if (addr == amodule->method_addresses)
amodule->code_offsets [i] = 0xffffffff;
vm_address_t addr, taddr;
kern_return_t ret;
vm_prot_t prot, max_prot;
- int psize;
+ int psize, specific_trampoline_size;
unsigned char *code;
+ specific_trampoline_size = 2 * sizeof (gpointer);
+
mono_aot_page_lock ();
page = trampoline_pages [tramp_type];
if (page && page->trampolines < page->trampolines_end) {
code = page->trampolines;
- page->trampolines += 8;
+ page->trampolines += specific_trampoline_size;
mono_aot_page_unlock ();
return code;
}
amodule = image->aot_module;
g_assert (amodule);
+ g_assert (amodule->info.tramp_page_size == psize);
+
if (tramp_type == MONO_AOT_TRAMP_SPECIFIC)
tpage = load_function (amodule, "specific_trampolines_page");
else if (tramp_type == MONO_AOT_TRAMP_STATIC_RGCTX)
/* some other thread already allocated, so use that to avoid wasting memory */
if (page && page->trampolines < page->trampolines_end) {
code = page->trampolines;
- page->trampolines += 8;
+ page->trampolines += specific_trampoline_size;
mono_aot_page_unlock ();
vm_deallocate (mach_task_self (), addr, psize);
vm_deallocate (mach_task_self (), taddr, psize);
*out_amodule = amodule;
#ifdef MONOTOUCH
-#define MONOTOUCH_TRAMPOLINES_ERROR ". See http://docs.xamarin.com/ios/troubleshooting for instruction on how to fix this condition"
+#define MONOTOUCH_TRAMPOLINES_ERROR ". See http://docs.xamarin.com/ios/troubleshooting for instructions on how to fix this condition."
#else
#define MONOTOUCH_TRAMPOLINES_ERROR ""
#endif
#endif
/* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 95
+#define MONO_AOT_FILE_VERSION 96
//TODO: This is x86/amd64 specific.
#define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))