mono_arch_flush_icache (start, code - start);
mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
+ mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, NULL));
+
return start;
}
start = code = mono_domain_code_reserve (domain, buf_len);
- this_offset = mono_x86_get_this_arg_offset (NULL, mono_method_signature (m));
+ this_offset = mono_x86_get_this_arg_offset (mono_method_signature (m));
/* Set imt arg */
x86_mov_reg_imm (code, MONO_ARCH_IMT_REG, m);
return (gpointer*)((char*)vt + displacement);
}
-void
-mono_arch_nullify_class_init_trampoline (guint8 *code, mgreg_t *regs)
-{
- guint8 buf [16];
- gboolean can_write = mono_breakpoint_clean_code (NULL, code, 6, buf, sizeof (buf));
- gpointer tramp = mini_get_nullified_class_init_trampoline ();
-
- if (!can_write)
- return;
-
- code -= 5;
- if (code [0] == 0xe8) {
-#if defined(__default_codegen__)
- if (!mono_running_on_valgrind ()) {
- guint32 ops;
- /*
- * Thread safe code patching using the algorithm from the paper
- * 'Practicing JUDO: Java Under Dynamic Optimizations'
- */
- /*
- * First atomically change the the first 2 bytes of the call to a
- * spinning jump.
- */
- ops = 0xfeeb;
- InterlockedExchange ((gint32*)code, ops);
-
- /* Then change the other bytes to a nop */
- code [2] = 0x90;
- code [3] = 0x90;
- code [4] = 0x90;
-
- /* Then atomically change the first 4 bytes to a nop as well */
- ops = 0x90909090;
- InterlockedExchange ((gint32*)code, ops);
- /* FIXME: the calltree skin trips on the self modifying code above */
-
- /* Tell valgrind to recompile the patched code */
- //VALGRIND_DISCARD_TRANSLATIONS (code, 8);
- }
-#elif defined(__native_client_codegen__)
- mono_arch_patch_callsite (code, code + 5, tramp);
-#endif
- } else if (code [0] == 0x90 || code [0] == 0xeb) {
- /* Already changed by another thread */
- ;
- } else if ((code [-1] == 0xff) && (x86_modrm_reg (code [0]) == 0x2)) {
- /* call *<OFFSET>(<REG>) -> Call made from AOT code */
- gpointer *vtable_slot;
-
- vtable_slot = get_vcall_slot_addr (code + 5, regs);
- g_assert (vtable_slot);
-
- *vtable_slot = tramp;
- } else {
- printf ("Invalid trampoline sequence: %x %x %x %x %x %x %x\n", code [0], code [1], code [2], code [3],
- code [4], code [5], code [6]);
- g_assert_not_reached ();
- }
-}
-
guchar*
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
{
x86_mov_membase_reg (code, X86_EBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, lmf_addr), X86_EAX, sizeof (mgreg_t));
/* lmf->previous_lmf = *(lmf_addr) */
x86_mov_reg_membase (code, X86_ECX, X86_EAX, 0, sizeof (mgreg_t));
- /* Signal to mono_arch_find_jit_info () that this is a trampoline frame */
+ /* Signal to mono_arch_unwind_frame () that this is a trampoline frame */
x86_alu_reg_imm (code, X86_ADD, X86_ECX, 1);
x86_mov_membase_reg (code, X86_EBP, lmf_offset + G_STRUCT_OFFSET (MonoLMF, previous_lmf), X86_ECX, sizeof (mgreg_t));
/* *lmf_addr = lmf */
g_assert ((code - buf) <= 256);
mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
- if (info) {
- tramp_name = mono_get_generic_trampoline_name (tramp_type);
- *info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);
- g_free (tramp_name);
- }
-
- return buf;
-}
-
-gpointer
-mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info)
-{
- guint8 *code, *buf;
- int tramp_size = NACL_SIZE (16, kNaClAlignment);
-
- code = buf = mono_global_codeman_reserve (tramp_size);
- x86_ret (code);
-
- nacl_global_codeman_validate (&buf, tramp_size, &code);
-
- mono_arch_flush_icache (buf, code - buf);
- mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
-
- if (info)
- *info = mono_tramp_info_create ("nullified_class_init_trampoline", buf, code - buf, NULL, NULL);
+ tramp_name = mono_get_generic_trampoline_name (tramp_type);
+ *info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);
+ g_free (tramp_name);
return buf;
}
g_assert (code - buf <= tramp_size);
- if (info) {
- char *name = mono_get_rgctx_fetch_trampoline_name (slot);
- *info = mono_tramp_info_create (name, buf, code - buf, ji, unwind_ops);
- g_free (name);
- }
+ char *name = mono_get_rgctx_fetch_trampoline_name (slot);
+ *info = mono_tramp_info_create (name, buf, code - buf, ji, unwind_ops);
+ g_free (name);
return 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)
-{
- guint8 *tramp;
- guint8 *code, *buf;
- static int byte_offset = -1;
- static guint8 bitmask;
- guint8 *jump;
- int tramp_size;
- GSList *unwind_ops = NULL;
- MonoJumpInfo *ji = NULL;
-
- tramp_size = 64;
-
- code = buf = mono_global_codeman_reserve (tramp_size);
-
- unwind_ops = mono_arch_get_cie_program ();
-
- if (byte_offset < 0)
- mono_marshal_find_bitfield_offset (MonoVTable, initialized, &byte_offset, &bitmask);
-
- x86_test_membase_imm (code, MONO_ARCH_VTABLE_REG, byte_offset, bitmask);
- jump = code;
- x86_branch8 (code, X86_CC_Z, -1, 1);
-
- x86_ret (code);
-
- x86_patch (jump, code);
-
- /* Push the vtable so the stack is the same as in a specific trampoline */
- x86_push_reg (code, MONO_ARCH_VTABLE_REG);
-
- if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "generic_trampoline_generic_class_init");
- x86_jump_reg (code, X86_EAX);
- } else {
- tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_GENERIC_CLASS_INIT);
-
- /* jump to the actual trampoline */
- x86_jump_code (code, tramp);
- }
-
- mono_arch_flush_icache (code, code - buf);
-
- g_assert (code - buf <= tramp_size);
-#ifdef __native_client_codegen__
- g_assert (code - buf <= kNaClAlignment);
-#endif
-
- nacl_global_codeman_validate (&buf, tramp_size, &code);
- mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
-
- if (info)
- *info = mono_tramp_info_create ("generic_class_init_trampoline", buf, code - buf, ji, unwind_ops);
+ *info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, ji, unwind_ops);
return buf;
}
status_offset = MONO_THREADS_SYNC_MEMBER_OFFSET (status_offset);
nest_offset = MONO_THREADS_SYNC_MEMBER_OFFSET (nest_offset);
- tramp_size = NACL_SIZE (96, 128);
+ tramp_size = NACL_SIZE (128, 192);
code = buf = mono_global_codeman_reserve (tramp_size);
nacl_global_codeman_validate (&buf, tramp_size, &code);
mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_MONITOR, NULL);
- if (info) {
- if (is_v4)
- *info = mono_tramp_info_create ("monitor_enter_v4_trampoline", buf, code - buf, ji, unwind_ops);
- else
- *info = mono_tramp_info_create ("monitor_enter_trampoline", buf, code - buf, ji, unwind_ops);
- }
+ if (is_v4)
+ *info = mono_tramp_info_create ("monitor_enter_v4_trampoline", buf, code - buf, ji, unwind_ops);
+ else
+ *info = mono_tramp_info_create ("monitor_enter_trampoline", buf, code - buf, ji, unwind_ops);
return buf;
}
status_offset = MONO_THREADS_SYNC_MEMBER_OFFSET (status_offset);
nest_offset = MONO_THREADS_SYNC_MEMBER_OFFSET (nest_offset);
- tramp_size = NACL_SIZE (96, 128);
+ tramp_size = NACL_SIZE (128, 192);
code = buf = mono_global_codeman_reserve (tramp_size);
g_assert (code - buf <= tramp_size);
mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_MONITOR, NULL);
- if (info)
- *info = mono_tramp_info_create ("monitor_exit_trampoline", buf, code - buf, ji, unwind_ops);
+ *info = mono_tramp_info_create ("monitor_exit_trampoline", buf, code - buf, ji, unwind_ops);
return buf;
}
mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
g_assert (code - buf <= tramp_size);
- if (info)
- *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
+ *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
return buf;
}
gpointer
mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
{
- if (info)
- *info = NULL;
+ *info = NULL;
return NULL;
}