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 */
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);
-
- *info = mono_tramp_info_create ("nullified_class_init_trampoline", buf, code - buf, NULL, NULL);
-
- return buf;
-}
-
#define TRAMPOLINE_SIZE 10
gpointer