*/
code -= 6;
orig_code -= 6;
- if ((code [1] == 0xe8)) {
+ if (code [1] == 0xe8) {
if (can_write) {
InterlockedExchange ((gint32*)(orig_code + 2), (guint)addr - ((guint)orig_code + 1) - 5);
x86_jump_code (buf, tramp);
g_assert ((buf - code) <= TRAMPOLINE_SIZE);
- nacl_domain_code_validate (domain, &code, kNaClAlignment, &buf);
+ nacl_domain_code_validate (domain, &code, NACL_SIZE (4, kNaClAlignment), &buf);
mono_arch_flush_icache (code, buf - code);
return buf;
}
+/*
+ * mono_arch_create_general_rgctx_lazy_fetch_trampoline:
+ *
+ * This is a general variant of the rgctx fetch trampolines. It receives a pointer to gpointer[2] in the rgctx reg. The first entry contains the slot, the second
+ * the trampoline to call if the slot is not filled.
+ */
+gpointer
+mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+ guint8 *code, *buf;
+ int tramp_size;
+ MonoJumpInfo *ji = NULL;
+ GSList *unwind_ops = NULL;
+
+ g_assert (aot);
+
+ unwind_ops = mono_arch_get_cie_program ();
+
+ tramp_size = 64;
+
+ code = buf = mono_global_codeman_reserve (tramp_size);
+
+ // FIXME: Currently, we always go to the slow path.
+
+ /* Load trampoline addr */
+ x86_mov_reg_membase (code, X86_EAX, MONO_ARCH_RGCTX_REG, 4, 4);
+ /* Load mrgctx/vtable */
+ x86_mov_reg_membase (code, MONO_ARCH_VTABLE_REG, X86_ESP, 4, 4);
+
+ x86_jump_reg (code, X86_EAX);
+
+ nacl_global_codeman_validate (&buf, tramp_size, &code);
+ mono_arch_flush_icache (buf, code - buf);
+
+ g_assert (code - buf <= tramp_size);
+
+ if (info)
+ *info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, ji, unwind_ops);
+
+ return buf;
+}
+
gpointer
mono_arch_create_generic_class_init_trampoline (MonoTrampInfo **info, gboolean aot)
{
owner_offset = MONO_THREADS_SYNC_MEMBER_OFFSET (owner_offset);
nest_offset = MONO_THREADS_SYNC_MEMBER_OFFSET (nest_offset);
- tramp_size = NACL_SIZE (64, 128);
+ tramp_size = NACL_SIZE (96, 128);
code = buf = mono_global_codeman_reserve (tramp_size);
static void
handler_block_trampoline_helper (gpointer *ptr)
{
- MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
+ MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
*ptr = jit_tls->handler_block_return_address;
}
{
return *(guint32*)(plt_entry + NACL_SIZE (6, 12));
}
+
+/*
+ * mono_arch_get_gsharedvt_arg_trampoline:
+ *
+ * Return a trampoline which passes ARG to the gsharedvt in/out trampoline ADDR.
+ */
+gpointer
+mono_arch_get_gsharedvt_arg_trampoline (MonoDomain *domain, gpointer arg, gpointer addr)
+{
+ guint8 *code, *start;
+ int buf_len;
+
+ buf_len = 10;
+
+ start = code = mono_domain_code_reserve (domain, buf_len);
+
+ x86_mov_reg_imm (code, X86_EAX, arg);
+ x86_jump_code (code, addr);
+ g_assert ((code - start) <= buf_len);
+
+ nacl_domain_code_validate (domain, &start, buf_len, &code);
+ mono_arch_flush_icache (start, code - start);
+
+ return start;
+}
+
+#if defined(MONOTOUCH) || defined(MONO_EXTENSIONS)
+
+#include "../../../mono-extensions/mono/mini/tramp-x86-gsharedvt.c"
+
+#else
+
+gpointer
+mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+ if (info)
+ *info = NULL;
+ return NULL;
+}
+
+#endif /* !MONOTOUCH */