2 * tramp-amd64.c: JIT trampoline code for amd64
5 * Dietmar Maurer (dietmar@ximian.com)
6 * Zoltan Varga (vargaz@gmail.com)
7 * Johan Lorensson (lateralusx.github@gmail.com)
9 * (C) 2001 Ximian, Inc.
10 * Copyright 2003-2011 Novell, Inc (http://www.novell.com)
11 * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
12 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
18 #include <mono/metadata/abi-details.h>
19 #include <mono/metadata/appdomain.h>
20 #include <mono/metadata/marshal.h>
21 #include <mono/metadata/tabledefs.h>
22 #include <mono/metadata/mono-debug-debugger.h>
23 #include <mono/metadata/profiler-private.h>
24 #include <mono/metadata/gc-internals.h>
25 #include <mono/arch/amd64/amd64-codegen.h>
27 #include <mono/utils/memcheck.h>
30 #include "mini-amd64.h"
31 #include "debugger-agent.h"
33 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
35 #define IS_REX(inst) (((inst) >= 0x40) && ((inst) <= 0x4f))
39 * mono_arch_get_unbox_trampoline:
41 * @addr: pointer to native code for @m
43 * when value type methods are called through the vtable we need to unbox the
44 * this argument. This method returns a pointer to a trampoline which does
45 * unboxing before calling the method
48 mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
52 int this_reg, size = 20;
54 MonoDomain *domain = mono_domain_get ();
56 this_reg = mono_arch_get_this_arg_reg (NULL);
58 start = code = (guint8 *)mono_domain_code_reserve (domain, size + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
60 unwind_ops = mono_arch_get_cie_program ();
62 amd64_alu_reg_imm (code, X86_ADD, this_reg, sizeof (MonoObject));
63 /* FIXME: Optimize this */
64 amd64_mov_reg_imm (code, AMD64_RAX, addr);
65 amd64_jump_reg (code, AMD64_RAX);
66 g_assert ((code - start) < size);
67 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_TRAMPOLINE_UNWINDINFO_SIZE(0)));
69 mono_arch_flush_icache (start, code - start);
70 mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_UNBOX_TRAMPOLINE, m);
72 mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, unwind_ops), domain);
78 * mono_arch_get_static_rgctx_trampoline:
80 * Create a trampoline which sets RGCTX_REG to MRGCTX, then jumps to ADDR.
83 mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericContext *mrgctx, gpointer addr)
89 MonoDomain *domain = mono_domain_get ();
91 #ifdef MONO_ARCH_NOMAP32BIT
94 /* AOTed code could still have a non-32 bit address */
95 if ((((guint64)addr) >> 32) == 0)
101 start = code = (guint8 *)mono_domain_code_reserve (domain, buf_len + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
103 unwind_ops = mono_arch_get_cie_program ();
105 amd64_mov_reg_imm (code, MONO_ARCH_RGCTX_REG, mrgctx);
106 amd64_jump_code (code, addr);
107 g_assert ((code - start) < buf_len);
108 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_TRAMPOLINE_UNWINDINFO_SIZE(0)));
110 mono_arch_flush_icache (start, code - start);
111 mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
113 mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, unwind_ops), domain);
117 #endif /* !DISABLE_JIT */
120 // Workaround lack of Valgrind support for 64-bit Windows
121 #define VALGRIND_DISCARD_TRANSLATIONS(...)
125 * mono_arch_patch_callsite:
127 * Patch the callsite whose address is given by ORIG_CODE so it calls ADDR. ORIG_CODE
128 * points to the pc right after the call.
131 mono_arch_patch_callsite (guint8 *method_start, guint8 *orig_code, guint8 *addr)
135 gboolean can_write = mono_breakpoint_clean_code (method_start, orig_code, 14, buf, sizeof (buf));
139 /* mov 64-bit imm into r11 (followed by call reg?) or direct call*/
140 if (((code [-13] == 0x49) && (code [-12] == 0xbb)) || (code [-5] == 0xe8)) {
141 if (code [-5] != 0xe8) {
143 InterlockedExchangePointer ((gpointer*)(orig_code - 11), addr);
144 VALGRIND_DISCARD_TRANSLATIONS (orig_code - 11, sizeof (gpointer));
147 gboolean disp_32bit = ((((gint64)addr - (gint64)orig_code)) < (1 << 30)) && ((((gint64)addr - (gint64)orig_code)) > -(1 << 30));
149 if ((((guint64)(addr)) >> 32) != 0 && !disp_32bit) {
151 * This might happen with LLVM or when calling AOTed code. Create a thunk.
153 guint8 *thunk_start, *thunk_code;
155 thunk_start = thunk_code = (guint8 *)mono_domain_code_reserve (mono_domain_get (), 32);
156 amd64_jump_membase (thunk_code, AMD64_RIP, 0);
157 *(guint64*)thunk_code = (guint64)addr;
159 g_assert ((((guint64)(addr)) >> 32) == 0);
160 mono_arch_flush_icache (thunk_start, thunk_code - thunk_start);
161 mono_profiler_code_buffer_new (thunk_start, thunk_code - thunk_start, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
164 InterlockedExchange ((gint32*)(orig_code - 4), ((gint64)addr - (gint64)orig_code));
165 VALGRIND_DISCARD_TRANSLATIONS (orig_code - 5, 4);
169 else if ((code [-7] == 0x41) && (code [-6] == 0xff) && (code [-5] == 0x15)) {
170 /* call *<OFFSET>(%rip) */
171 gpointer *got_entry = (gpointer*)((guint8*)orig_code + (*(guint32*)(orig_code - 4)));
173 InterlockedExchangePointer (got_entry, addr);
174 VALGRIND_DISCARD_TRANSLATIONS (orig_code - 5, sizeof (gpointer));
181 mono_arch_create_llvm_native_thunk (MonoDomain *domain, guint8 *addr)
184 * The caller is LLVM code and the call displacement might exceed 32 bits. We can't determine the caller address, so
185 * we add a thunk every time.
186 * Since the caller is also allocated using the domain code manager, hopefully the displacement will fit into 32 bits.
187 * FIXME: Avoid this if possible if !MONO_ARCH_NOMAP32BIT and ADDR is 32 bits.
189 guint8 *thunk_start, *thunk_code;
191 thunk_start = thunk_code = (guint8 *)mono_domain_code_reserve (mono_domain_get (), 32);
192 amd64_jump_membase (thunk_code, AMD64_RIP, 0);
193 *(guint64*)thunk_code = (guint64)addr;
195 mono_arch_flush_icache (thunk_start, thunk_code - thunk_start);
196 mono_profiler_code_buffer_new (thunk_start, thunk_code - thunk_start, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
199 #endif /* !DISABLE_JIT */
202 mono_arch_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *addr)
205 gpointer *plt_jump_table_entry;
207 /* A PLT entry: jmp *<DISP>(%rip) */
208 g_assert (code [0] == 0xff);
209 g_assert (code [1] == 0x25);
211 disp = *(gint32*)(code + 2);
213 plt_jump_table_entry = (gpointer*)(code + 6 + disp);
215 InterlockedExchangePointer (plt_jump_table_entry, addr);
220 stack_unaligned (MonoTrampolineType tramp_type)
222 printf ("%d\n", tramp_type);
223 g_assert_not_reached ();
227 mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
230 guint8 *buf, *code, *tramp, *br [2], *r11_save_code, *after_r11_save_code, *br_ex_check;
231 int i, lmf_offset, offset, res_offset, arg_offset, rax_offset, ex_offset, tramp_offset, ctx_offset, saved_regs_offset;
232 int r11_save_offset, saved_fpregs_offset, rbp_offset, framesize, orig_rsp_to_rbp_offset, cfa_offset;
234 GSList *unwind_ops = NULL;
235 MonoJumpInfo *ji = NULL;
236 const guint kMaxCodeSize = 630;
238 if (tramp_type == MONO_TRAMPOLINE_JUMP || tramp_type == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD)
243 code = buf = (guint8 *)mono_global_codeman_reserve (kMaxCodeSize + MONO_MAX_TRAMPOLINE_UNWINDINFO_SIZE);
245 /* Compute stack frame size and offsets */
247 rbp_offset = -offset;
249 offset += sizeof(mgreg_t);
250 rax_offset = -offset;
252 offset += sizeof(mgreg_t);
255 offset += sizeof(mgreg_t);
256 r11_save_offset = -offset;
258 offset += sizeof(mgreg_t);
259 tramp_offset = -offset;
261 offset += sizeof(gpointer);
262 arg_offset = -offset;
264 offset += sizeof(mgreg_t);
265 res_offset = -offset;
267 offset += sizeof (MonoContext);
268 ctx_offset = -offset;
269 saved_regs_offset = ctx_offset + MONO_STRUCT_OFFSET (MonoContext, gregs);
270 saved_fpregs_offset = ctx_offset + MONO_STRUCT_OFFSET (MonoContext, fregs);
272 offset += sizeof (MonoLMFTramp);
273 lmf_offset = -offset;
276 /* Reserve space where the callee can save the argument registers */
277 offset += 4 * sizeof (mgreg_t);
280 framesize = ALIGN_TO (offset, MONO_ARCH_FRAME_ALIGNMENT);
282 // CFA = sp + 16 (the trampoline address is on the stack)
284 mono_add_unwind_op_def_cfa (unwind_ops, code, buf, AMD64_RSP, 16);
285 // IP saved at CFA - 8
286 mono_add_unwind_op_offset (unwind_ops, code, buf, AMD64_RIP, -8);
288 orig_rsp_to_rbp_offset = 0;
289 r11_save_code = code;
290 /* Reserve space for the mov_membase_reg to save R11 */
292 after_r11_save_code = code;
294 /* Pop the return address off the stack */
295 amd64_pop_reg (code, AMD64_R11);
296 orig_rsp_to_rbp_offset += sizeof(mgreg_t);
298 cfa_offset -= sizeof(mgreg_t);
299 mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
302 * Allocate a new stack frame
304 amd64_push_reg (code, AMD64_RBP);
305 cfa_offset += sizeof(mgreg_t);
306 mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
307 mono_add_unwind_op_offset (unwind_ops, code, buf, AMD64_RBP, - cfa_offset);
309 orig_rsp_to_rbp_offset -= sizeof(mgreg_t);
310 amd64_mov_reg_reg (code, AMD64_RBP, AMD64_RSP, sizeof(mgreg_t));
311 mono_add_unwind_op_def_cfa_reg (unwind_ops, code, buf, AMD64_RBP);
312 mono_add_unwind_op_fp_alloc (unwind_ops, code, buf, AMD64_RBP, 0);
313 amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, framesize);
315 /* Compute the trampoline address from the return address */
317 /* 7 = length of call *<offset>(rip) */
318 amd64_alu_reg_imm (code, X86_SUB, AMD64_R11, 7);
320 /* 5 = length of amd64_call_membase () */
321 amd64_alu_reg_imm (code, X86_SUB, AMD64_R11, 5);
323 amd64_mov_membase_reg (code, AMD64_RBP, tramp_offset, AMD64_R11, sizeof(gpointer));
325 /* Save all registers */
326 for (i = 0; i < AMD64_NREG; ++i) {
327 if (i == AMD64_RBP) {
328 /* RAX is already saved */
329 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RBP, rbp_offset, sizeof(mgreg_t));
330 amd64_mov_membase_reg (code, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), AMD64_RAX, sizeof(mgreg_t));
331 } else if (i == AMD64_RIP) {
333 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, 8, sizeof(gpointer));
335 amd64_mov_reg_imm (code, AMD64_R11, 0);
336 amd64_mov_membase_reg (code, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), AMD64_R11, sizeof(mgreg_t));
337 } else if (i == AMD64_RSP) {
338 amd64_mov_reg_reg (code, AMD64_R11, AMD64_RSP, sizeof(mgreg_t));
339 amd64_alu_reg_imm (code, X86_ADD, AMD64_R11, framesize + 16);
340 amd64_mov_membase_reg (code, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), AMD64_R11, sizeof(mgreg_t));
341 } else if (i != AMD64_R11) {
342 amd64_mov_membase_reg (code, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), i, sizeof(mgreg_t));
344 /* We have to save R11 right at the start of
345 the trampoline code because it's used as a
347 /* This happens before the frame is set up, so it goes into the redzone */
348 amd64_mov_membase_reg (r11_save_code, AMD64_RSP, r11_save_offset + orig_rsp_to_rbp_offset, i, sizeof(mgreg_t));
349 g_assert (r11_save_code == after_r11_save_code);
351 /* Copy from the save slot into the register array slot */
352 amd64_mov_reg_membase (code, i, AMD64_RSP, r11_save_offset + orig_rsp_to_rbp_offset, sizeof(mgreg_t));
353 amd64_mov_membase_reg (code, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), i, sizeof(mgreg_t));
355 /* cfa = rbp + cfa_offset */
356 mono_add_unwind_op_offset (unwind_ops, code, buf, i, - cfa_offset + saved_regs_offset + (i * sizeof (mgreg_t)));
358 for (i = 0; i < 8; ++i)
359 amd64_movsd_membase_reg (code, AMD64_RBP, saved_fpregs_offset + (i * sizeof(mgreg_t)), i);
361 /* Check that the stack is aligned */
362 amd64_mov_reg_reg (code, AMD64_R11, AMD64_RSP, sizeof (mgreg_t));
363 amd64_alu_reg_imm (code, X86_AND, AMD64_R11, 15);
364 amd64_alu_reg_imm (code, X86_CMP, AMD64_R11, 0);
366 amd64_branch_disp (code, X86_CC_Z, 0, FALSE);
368 amd64_mov_reg_imm (code, AMD64_R11, 0);
369 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0, 8);
371 amd64_mov_reg_imm (code, MONO_AMD64_ARG_REG1, tramp_type);
372 amd64_mov_reg_imm (code, AMD64_R11, stack_unaligned);
373 amd64_call_reg (code, AMD64_R11);
375 mono_amd64_patch (br [0], code);
376 //amd64_breakpoint (code);
378 if (tramp_type != MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD) {
379 /* Obtain the trampoline argument which is encoded in the instruction stream */
381 /* Load the GOT offset */
382 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, tramp_offset, sizeof(gpointer));
384 * r11 points to a call *<offset>(%rip) instruction, load the
385 * pc-relative offset from the instruction itself.
387 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 3, 4);
388 /* 7 is the length of the call, 8 is the offset to the next got slot */
389 amd64_alu_reg_imm_size (code, X86_ADD, AMD64_RAX, 7 + sizeof (gpointer), sizeof(gpointer));
390 /* Compute the address of the GOT slot */
391 amd64_alu_reg_reg_size (code, X86_ADD, AMD64_R11, AMD64_RAX, sizeof(gpointer));
393 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0, sizeof(gpointer));
395 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, tramp_offset, sizeof(gpointer));
396 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 5, 1);
397 amd64_widen_reg (code, AMD64_RAX, AMD64_RAX, TRUE, FALSE);
398 amd64_alu_reg_imm_size (code, X86_CMP, AMD64_RAX, 4, 1);
400 x86_branch8 (code, X86_CC_NE, 6, FALSE);
401 /* 32 bit immediate */
402 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 4);
404 x86_jump8 (code, 10);
405 /* 64 bit immediate */
406 mono_amd64_patch (br [0], code);
407 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 8);
408 mono_amd64_patch (br [1], code);
410 amd64_mov_membase_reg (code, AMD64_RBP, arg_offset, AMD64_R11, sizeof(gpointer));
412 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, saved_regs_offset + (MONO_AMD64_ARG_REG1 * sizeof(mgreg_t)), sizeof(mgreg_t));
413 amd64_mov_membase_reg (code, AMD64_RBP, arg_offset, AMD64_R11, sizeof(gpointer));
420 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, 8, sizeof(gpointer));
422 amd64_mov_reg_imm (code, AMD64_R11, 0);
423 amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, rip), AMD64_R11, sizeof(mgreg_t));
425 amd64_mov_reg_reg (code, AMD64_R11, AMD64_RSP, sizeof(mgreg_t));
426 amd64_alu_reg_imm (code, X86_ADD, AMD64_R11, framesize + 16);
427 amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, rsp), AMD64_R11, sizeof(mgreg_t));
428 /* Save pointer to context */
429 amd64_lea_membase (code, AMD64_R11, AMD64_RBP, ctx_offset);
430 amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMFTramp, ctx), AMD64_R11, sizeof(mgreg_t));
433 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr");
435 amd64_mov_reg_imm (code, AMD64_R11, mono_get_lmf_addr);
437 amd64_call_reg (code, AMD64_R11);
440 amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMFTramp, lmf_addr), AMD64_RAX, sizeof(gpointer));
441 /* Save previous_lmf */
442 /* Set the lowest bit to signal that this LMF has the ip field set */
443 /* Set the third lowest bit to signal that this is a MonoLMFTramp structure */
444 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RAX, 0, sizeof(gpointer));
445 amd64_alu_reg_imm_size (code, X86_ADD, AMD64_R11, 0x5, sizeof(gpointer));
446 amd64_mov_membase_reg (code, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, previous_lmf), AMD64_R11, sizeof(gpointer));
448 amd64_lea_membase (code, AMD64_R11, AMD64_RBP, lmf_offset);
449 amd64_mov_membase_reg (code, AMD64_RAX, 0, AMD64_R11, sizeof(gpointer));
453 /* Arg1 is the pointer to the saved registers */
454 amd64_lea_membase (code, AMD64_ARG_REG1, AMD64_RBP, saved_regs_offset);
456 /* Arg2 is the address of the calling code */
458 amd64_mov_reg_membase (code, AMD64_ARG_REG2, AMD64_RBP, 8, sizeof(gpointer));
460 amd64_mov_reg_imm (code, AMD64_ARG_REG2, 0);
462 /* Arg3 is the method/vtable ptr */
463 amd64_mov_reg_membase (code, AMD64_ARG_REG3, AMD64_RBP, arg_offset, sizeof(gpointer));
465 /* Arg4 is the trampoline address */
466 amd64_mov_reg_membase (code, AMD64_ARG_REG4, AMD64_RBP, tramp_offset, sizeof(gpointer));
469 char *icall_name = g_strdup_printf ("trampoline_func_%d", tramp_type);
470 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
472 tramp = (guint8*)mono_get_trampoline_func (tramp_type);
473 amd64_mov_reg_imm (code, AMD64_R11, tramp);
475 amd64_call_reg (code, AMD64_R11);
476 amd64_mov_membase_reg (code, AMD64_RBP, res_offset, AMD64_RAX, sizeof(mgreg_t));
479 amd64_mov_reg_membase (code, AMD64_RCX, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, previous_lmf), sizeof(gpointer));
480 amd64_alu_reg_imm_size (code, X86_SUB, AMD64_RCX, 0x5, sizeof(gpointer));
481 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, lmf_offset + MONO_STRUCT_OFFSET (MonoLMFTramp, lmf_addr), sizeof(gpointer));
482 amd64_mov_membase_reg (code, AMD64_R11, 0, AMD64_RCX, sizeof(gpointer));
485 * Save rax to the stack, after the leave instruction, this will become part of
488 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RBP, res_offset, sizeof(mgreg_t));
489 amd64_mov_membase_reg (code, AMD64_RBP, rax_offset, AMD64_RAX, sizeof(mgreg_t));
491 /* Check for thread interruption */
492 /* This is not perf critical code so no need to check the interrupt flag */
494 * Have to call the _force_ variant, since there could be a protected wrapper on the top of the stack.
497 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint_noraise");
499 amd64_mov_reg_imm (code, AMD64_R11, (guint8*)mono_thread_force_interruption_checkpoint_noraise);
501 amd64_call_reg (code, AMD64_R11);
503 amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
505 amd64_branch8 (code, X86_CC_Z, -1, 1);
509 * We have an exception we want to throw in the caller's frame, so pop
510 * the trampoline frame and throw from the caller.
513 amd64_lea_membase (code, AMD64_RSP, AMD64_RBP, 0);
514 amd64_pop_reg (code, AMD64_RBP);
515 mono_add_unwind_op_same_value (unwind_ops, code, buf, AMD64_RBP);
519 /* We are in the parent frame, the exception is in rax */
521 * EH is initialized after trampolines, so get the address of the variable
522 * which contains throw_exception, and load it from there.
525 /* Not really a jit icall */
526 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "throw_exception_addr");
528 amd64_mov_reg_imm (code, AMD64_R11, (guint8*)mono_get_throw_exception_addr ());
530 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0, sizeof(gpointer));
531 amd64_mov_reg_reg (code, AMD64_ARG_REG1, AMD64_RAX, sizeof(mgreg_t));
533 * We still have the original return value on the top of the stack, so the
534 * throw trampoline will use that as the throw site.
536 amd64_jump_reg (code, AMD64_R11);
539 mono_amd64_patch (br_ex_check, code);
541 /* Restore argument registers, r10 (imt method/rgxtx)
542 and rax (needed for direct calls to C vararg functions). */
543 for (i = 0; i < AMD64_NREG; ++i)
544 if (AMD64_IS_ARGUMENT_REG (i) || i == AMD64_R10 || i == AMD64_RAX)
545 amd64_mov_reg_membase (code, i, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), sizeof(mgreg_t));
546 for (i = 0; i < 8; ++i)
547 amd64_movsd_reg_membase (code, i, AMD64_RBP, saved_fpregs_offset + (i * sizeof(mgreg_t)));
551 amd64_lea_membase (code, AMD64_RSP, AMD64_RBP, 0);
552 amd64_pop_reg (code, AMD64_RBP);
553 mono_add_unwind_op_same_value (unwind_ops, code, buf, AMD64_RBP);
557 cfa_offset -= sizeof (mgreg_t);
558 mono_add_unwind_op_def_cfa (unwind_ops, code, buf, AMD64_RSP, cfa_offset);
560 if (MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) {
562 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RSP, rax_offset - sizeof(mgreg_t), sizeof(mgreg_t));
565 /* call the compiled method using the saved rax */
566 amd64_jump_membase (code, AMD64_RSP, rax_offset - sizeof(mgreg_t));
569 g_assert ((code - buf) <= kMaxCodeSize);
570 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_MAX_TRAMPOLINE_UNWINDINFO_SIZE));
572 mono_arch_flush_icache (buf, code - buf);
573 mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
575 tramp_name = mono_get_generic_trampoline_name (tramp_type);
576 *info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);
583 mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
585 guint8 *code, *buf, *tramp;
587 gboolean far_addr = FALSE;
589 tramp = mono_get_trampoline_code (tramp_type);
591 if ((((guint64)arg1) >> 32) == 0)
596 code = buf = (guint8 *)mono_domain_code_reserve_align (domain, size, 1);
598 if (((gint64)tramp - (gint64)code) >> 31 != 0 && ((gint64)tramp - (gint64)code) >> 31 != -1) {
599 #ifndef MONO_ARCH_NOMAP32BIT
600 g_assert_not_reached ();
604 code = buf = (guint8 *)mono_domain_code_reserve_align (domain, size, 1);
608 amd64_mov_reg_imm (code, AMD64_R11, tramp);
609 amd64_call_reg (code, AMD64_R11);
611 amd64_call_code (code, tramp);
613 /* The trampoline code will obtain the argument from the instruction stream */
614 if ((((guint64)arg1) >> 32) == 0) {
616 *(guint32*)(code + 1) = (gint64)arg1;
620 *(guint64*)(code + 1) = (gint64)arg1;
624 g_assert ((code - buf) <= size);
629 mono_arch_flush_icache (buf, size);
630 mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE, mono_get_generic_trampoline_simple_name (tramp_type));
636 mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info, gboolean aot)
640 guint8 **rgctx_null_jumps;
645 MonoJumpInfo *ji = NULL;
648 mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
649 index = MONO_RGCTX_SLOT_INDEX (slot);
651 index += MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT / sizeof (gpointer);
652 for (depth = 0; ; ++depth) {
653 int size = mono_class_rgctx_get_array_size (depth, mrgctx);
655 if (index < size - 1)
660 tramp_size = 64 + 8 * depth;
662 code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
664 unwind_ops = mono_arch_get_cie_program ();
666 rgctx_null_jumps = (guint8 **)g_malloc (sizeof (guint8*) * (depth + 2));
670 amd64_mov_reg_reg (code, AMD64_RAX, AMD64_ARG_REG1, 8);
672 /* load rgctx ptr from vtable */
673 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_ARG_REG1, MONO_STRUCT_OFFSET (MonoVTable, runtime_generic_context), sizeof(gpointer));
674 /* is the rgctx ptr null? */
675 amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
676 /* if yes, jump to actual trampoline */
677 rgctx_null_jumps [0] = code;
678 amd64_branch8 (code, X86_CC_Z, -1, 1);
681 for (i = 0; i < depth; ++i) {
682 /* load ptr to next array */
683 if (mrgctx && i == 0)
684 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RAX, MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT, sizeof(gpointer));
686 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RAX, 0, sizeof(gpointer));
687 /* is the ptr null? */
688 amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
689 /* if yes, jump to actual trampoline */
690 rgctx_null_jumps [i + 1] = code;
691 amd64_branch8 (code, X86_CC_Z, -1, 1);
695 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_RAX, sizeof (gpointer) * (index + 1), sizeof(gpointer));
696 /* is the slot null? */
697 amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
698 /* if yes, jump to actual trampoline */
699 rgctx_null_jumps [depth + 1] = code;
700 amd64_branch8 (code, X86_CC_Z, -1, 1);
701 /* otherwise return */
704 for (i = mrgctx ? 1 : 0; i <= depth + 1; ++i)
705 mono_amd64_patch (rgctx_null_jumps [i], code);
707 g_free (rgctx_null_jumps);
709 /* move the rgctx pointer to the VTABLE register */
710 amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
713 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot));
714 amd64_jump_reg (code, AMD64_R11);
716 tramp = (guint8 *)mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
718 /* jump to the actual trampoline */
719 amd64_jump_code (code, tramp);
722 mono_arch_flush_icache (buf, code - buf);
723 mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
725 g_assert (code - buf <= tramp_size);
726 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_TRAMPOLINE_UNWINDINFO_SIZE(0)));
728 char *name = mono_get_rgctx_fetch_trampoline_name (slot);
729 *info = mono_tramp_info_create (name, buf, code - buf, ji, unwind_ops);
736 mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
740 MonoJumpInfo *ji = NULL;
746 code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
748 unwind_ops = mono_arch_get_cie_program ();
750 // FIXME: Currently, we always go to the slow path.
751 /* This receives a <slot, trampoline> in the rgctx arg reg. */
752 /* Load trampoline addr */
753 amd64_mov_reg_membase (code, AMD64_R11, MONO_ARCH_RGCTX_REG, 8, 8);
754 /* move the rgctx pointer to the VTABLE register */
755 amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
756 /* Jump to the trampoline */
757 amd64_jump_reg (code, AMD64_R11);
759 mono_arch_flush_icache (buf, code - buf);
760 mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
762 g_assert (code - buf <= tramp_size);
763 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_TRAMPOLINE_UNWINDINFO_SIZE(0)));
766 *info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, ji, unwind_ops);
772 mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
774 /* FIXME: This is not thread safe */
775 guint8 *code = (guint8 *)ji->code_start;
777 amd64_mov_reg_imm (code, AMD64_ARG_REG1, func_arg);
778 amd64_mov_reg_imm (code, AMD64_R11, func);
780 x86_push_imm (code, (guint64)func_arg);
781 amd64_call_reg (code, AMD64_R11);
783 #endif /* !DISABLE_JIT */
786 mono_amd64_handler_block_trampoline_helper (void)
788 MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls ();
789 return jit_tls->handler_block_return_address;
794 mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
798 MonoJumpInfo *ji = NULL;
801 code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
803 unwind_ops = mono_arch_get_cie_program ();
806 * This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
807 * We get here from the ret emitted by CEE_ENDFINALLY.
808 * The stack is misaligned.
810 /* Align the stack before the call to mono_amd64_handler_block_trampoline_helper() */
812 /* Also make room for the "register parameter stack area" as specified by the Windows x64 ABI (4 64-bit registers) */
813 amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 8 + 4 * 8);
815 amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 8);
818 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_handler_block_trampoline_helper");
819 amd64_call_reg (code, AMD64_R11);
821 amd64_mov_reg_imm (code, AMD64_RAX, mono_amd64_handler_block_trampoline_helper);
822 amd64_call_reg (code, AMD64_RAX);
824 /* Undo stack alignment */
826 amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 8 + 4 * 8);
828 amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 8);
830 /* Save the result to the stack */
831 amd64_push_reg (code, AMD64_RAX);
833 /* Make room for the "register parameter stack area" as specified by the Windows x64 ABI (4 64-bit registers) */
834 amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 4 * 8);
837 char *name = g_strdup_printf ("trampoline_func_%d", MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
838 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, name);
839 amd64_mov_reg_reg (code, AMD64_RAX, AMD64_R11, 8);
841 amd64_mov_reg_imm (code, AMD64_RAX, mono_get_trampoline_func (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD));
843 /* The stack is aligned */
844 amd64_call_reg (code, AMD64_RAX);
846 amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 4 * 8);
848 /* Load return address */
849 amd64_pop_reg (code, AMD64_RAX);
850 /* The stack is misaligned, thats what the code we branch to expects */
851 amd64_jump_reg (code, AMD64_RAX);
853 mono_arch_flush_icache (buf, code - buf);
854 mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
855 g_assert (code - buf <= tramp_size);
856 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_TRAMPOLINE_UNWINDINFO_SIZE(0)));
858 *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
862 #endif /* !DISABLE_JIT */
865 * mono_arch_get_call_target:
867 * Return the address called by the code before CODE if exists.
870 mono_arch_get_call_target (guint8 *code)
872 if (code [-5] == 0xe8) {
873 gint32 disp = *(gint32*)(code - 4);
874 guint8 *target = code + disp;
883 * mono_arch_get_plt_info_offset:
885 * Return the PLT info offset belonging to the plt entry PLT_ENTRY.
888 mono_arch_get_plt_info_offset (guint8 *plt_entry, mgreg_t *regs, guint8 *code)
890 return *(guint32*)(plt_entry + 6);
895 * mono_arch_create_sdb_trampoline:
897 * Return a trampoline which captures the current context, passes it to
898 * debugger_agent_single_step_from_context ()/debugger_agent_breakpoint_from_context (),
899 * then restores the (potentially changed) context.
902 mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
904 int tramp_size = 512;
905 int i, framesize, ctx_offset, cfa_offset, gregs_offset;
907 GSList *unwind_ops = NULL;
908 MonoJumpInfo *ji = NULL;
910 code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size + MONO_MAX_TRAMPOLINE_UNWINDINFO_SIZE);
914 /* Reserve space where the callee can save the argument registers */
915 framesize += 4 * sizeof (mgreg_t);
918 ctx_offset = framesize;
919 framesize += sizeof (MonoContext);
921 framesize = ALIGN_TO (framesize, MONO_ARCH_FRAME_ALIGNMENT);
925 mono_add_unwind_op_def_cfa (unwind_ops, code, buf, AMD64_RSP, 8);
926 // IP saved at CFA - 8
927 mono_add_unwind_op_offset (unwind_ops, code, buf, AMD64_RIP, -cfa_offset);
929 amd64_push_reg (code, AMD64_RBP);
930 cfa_offset += sizeof(mgreg_t);
931 mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
932 mono_add_unwind_op_offset (unwind_ops, code, buf, AMD64_RBP, - cfa_offset);
934 amd64_mov_reg_reg (code, AMD64_RBP, AMD64_RSP, sizeof(mgreg_t));
935 mono_add_unwind_op_def_cfa_reg (unwind_ops, code, buf, AMD64_RBP);
936 mono_add_unwind_op_fp_alloc (unwind_ops, code, buf, AMD64_RBP, 0);
937 amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, framesize);
939 gregs_offset = ctx_offset + MONO_STRUCT_OFFSET (MonoContext, gregs);
941 /* Initialize a MonoContext structure on the stack */
942 for (i = 0; i < AMD64_NREG; ++i) {
943 if (i != AMD64_RIP && i != AMD64_RSP && i != AMD64_RBP)
944 amd64_mov_membase_reg (code, AMD64_RSP, gregs_offset + (i * sizeof (mgreg_t)), i, sizeof (mgreg_t));
946 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, 0, sizeof (mgreg_t));
947 amd64_mov_membase_reg (code, AMD64_RSP, gregs_offset + (AMD64_RBP * sizeof (mgreg_t)), AMD64_R11, sizeof (mgreg_t));
948 amd64_lea_membase (code, AMD64_R11, AMD64_RBP, 2 * sizeof (mgreg_t));
949 amd64_mov_membase_reg (code, AMD64_RSP, gregs_offset + (AMD64_RSP * sizeof (mgreg_t)), AMD64_R11, sizeof (mgreg_t));
950 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, sizeof (mgreg_t), sizeof (mgreg_t));
951 amd64_mov_membase_reg (code, AMD64_RSP, gregs_offset + (AMD64_RIP * sizeof (mgreg_t)), AMD64_R11, sizeof (mgreg_t));
953 /* Call the single step/breakpoint function in sdb */
954 amd64_lea_membase (code, AMD64_ARG_REG1, AMD64_RSP, ctx_offset);
958 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "debugger_agent_single_step_from_context");
960 code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "debugger_agent_breakpoint_from_context");
963 amd64_mov_reg_imm (code, AMD64_R11, debugger_agent_single_step_from_context);
965 amd64_mov_reg_imm (code, AMD64_R11, debugger_agent_breakpoint_from_context);
967 amd64_call_reg (code, AMD64_R11);
969 /* Restore registers from ctx */
970 for (i = 0; i < AMD64_NREG; ++i) {
971 if (i != AMD64_RIP && i != AMD64_RSP && i != AMD64_RBP)
972 amd64_mov_reg_membase (code, i, AMD64_RSP, gregs_offset + (i * sizeof (mgreg_t)), sizeof (mgreg_t));
974 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RSP, gregs_offset + (AMD64_RBP * sizeof (mgreg_t)), sizeof (mgreg_t));
975 amd64_mov_membase_reg (code, AMD64_RBP, 0, AMD64_R11, sizeof (mgreg_t));
976 amd64_mov_reg_membase (code, AMD64_R11, AMD64_RSP, gregs_offset + (AMD64_RIP * sizeof (mgreg_t)), sizeof (mgreg_t));
977 amd64_mov_membase_reg (code, AMD64_RBP, sizeof (mgreg_t), AMD64_R11, sizeof (mgreg_t));
980 amd64_lea_membase (code, AMD64_RSP, AMD64_RBP, 0);
981 amd64_pop_reg (code, AMD64_RBP);
982 mono_add_unwind_op_same_value (unwind_ops, code, buf, AMD64_RBP);
986 cfa_offset -= sizeof (mgreg_t);
987 mono_add_unwind_op_def_cfa (unwind_ops, code, buf, AMD64_RSP, cfa_offset);
990 mono_arch_flush_icache (code, code - buf);
991 mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
992 g_assert (code - buf <= tramp_size);
993 g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_MAX_TRAMPOLINE_UNWINDINFO_SIZE));
995 const char *tramp_name = single_step ? "sdb_single_step_trampoline" : "sdb_breakpoint_trampoline";
996 *info = mono_tramp_info_create (tramp_name, buf, code - buf, ji, unwind_ops);
1000 #endif /* !DISABLE_JIT */
1003 * mono_arch_get_enter_icall_trampoline:
1005 * A trampoline that handles the transition from interpreter into native world.
1006 * It requiers to set up a descriptor (MethodArguments) that describes the
1007 * required arguments passed to the callee.
1010 mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
1012 #ifdef ENABLE_INTERPRETER
1013 const int gregs_num = 6;
1014 guint8 *start = NULL, *code, *exits [gregs_num], *leave_tramp;
1015 MonoJumpInfo *ji = NULL;
1016 GSList *unwind_ops = NULL;
1017 static int arg_regs[] = {AMD64_ARG_REG1, AMD64_ARG_REG2, AMD64_ARG_REG3, AMD64_ARG_REG4, AMD64_R8, AMD64_R9};
1020 start = code = (guint8 *) mono_global_codeman_reserve (256 + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
1022 /* save MethodArguments* onto stack */
1023 amd64_push_reg (code, AMD64_ARG_REG2);
1025 /* save target address on stack */
1026 amd64_push_reg (code, AMD64_ARG_REG1);
1027 amd64_push_reg (code, AMD64_RAX);
1029 /* load pointer to MethodArguments* into R11 */
1030 amd64_mov_reg_reg (code, AMD64_R11, AMD64_ARG_REG2, 8);
1032 /* TODO: do float stuff first */
1034 /* move ilen into RAX */ // TODO: struct offset
1035 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 0, 8);
1036 /* load pointer to iregs into R11 */ // TODO: struct offset
1037 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 8, 8);
1039 for (i = 0; i < gregs_num; i++) {
1040 amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
1042 x86_branch8 (code, X86_CC_Z, 0, FALSE);
1049 amd64_mov_reg_membase (code, arg_regs [i], AMD64_R11, i * sizeof (gpointer), 8);
1051 g_error ("not tested yet.");
1052 amd64_push_reg (code, AMD64_RAX);
1053 amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, i * sizeof (gpointer), 8);
1054 amd64_mov_membase_reg (code, AMD64_RBP, offset, AMD64_RAX, sizeof (gpointer));
1055 offset += sizeof (gpointer);
1056 amd64_pop_reg (code, AMD64_RAX);
1058 amd64_dec_reg_size (code, AMD64_RAX, 1);
1061 for (i = 0; i < gregs_num; i++) {
1062 x86_patch (exits [i], code);
1066 amd64_pop_reg (code, AMD64_RAX);
1067 amd64_pop_reg (code, AMD64_R11);
1069 /* call into native function */
1070 amd64_call_reg (code, AMD64_R11);
1072 /* load MethodArguments */
1073 amd64_pop_reg (code, AMD64_R11);
1074 /* load retval */ // TODO: struct offset
1075 amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0x20, 8);
1077 amd64_test_reg_reg (code, AMD64_R11, AMD64_R11);
1079 x86_branch8 (code, X86_CC_Z, 0, FALSE);
1081 amd64_mov_membase_reg (code, AMD64_R11, 0, AMD64_RAX, 8);
1083 x86_patch (leave_tramp, code);
1087 mono_arch_flush_icache (start, code - start);
1088 mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
1091 *info = mono_tramp_info_create ("enter_icall_trampoline", start, code - start, ji, unwind_ops);
1095 g_assert_not_reached ();
1097 #endif /* ENABLE_INTERPRETER */
1102 mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
1104 g_assert_not_reached ();
1109 mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericContext *mrgctx, gpointer addr)
1111 g_assert_not_reached ();
1116 mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info, gboolean aot)
1118 g_assert_not_reached ();
1123 mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info, gboolean aot)
1125 g_assert_not_reached ();
1130 mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len)
1132 g_assert_not_reached ();
1137 mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
1139 g_assert_not_reached ();
1144 mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
1146 g_assert_not_reached ();
1151 mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
1153 g_assert_not_reached ();
1158 mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
1160 g_assert_not_reached ();
1165 mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
1167 g_assert_not_reached ();
1170 #endif /* DISABLE_JIT */