DECL_OFFSET(MonoJitTlsData, lmf)
DECL_OFFSET(MonoJitTlsData, class_cast_from)
DECL_OFFSET(MonoJitTlsData, class_cast_to)
-DECL_OFFSET(MonoJitTlsData, handler_block_return_address)
DECL_OFFSET(MonoJitTlsData, restore_stack_prot)
DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, locals_size)
#ifdef DISABLE_REMOTING
if (tramp_type == MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING)
continue;
-#endif
-#ifndef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
- if (tramp_type == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD)
- continue;
#endif
mono_arch_create_generic_trampoline ((MonoTrampolineType)tramp_type, &info, acfg->aot_opts.use_trampolines_page? 2: TRUE);
emit_trampoline (acfg, acfg->got_offset, info);
}
}
-#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD_AOT
- mono_arch_create_handler_block_trampoline (&info, TRUE);
- emit_trampoline (acfg, acfg->got_offset, info);
-#endif
-
if (mono_aot_mode_is_interp (&acfg->aot_opts)) {
mono_arch_get_enter_icall_trampoline (&info);
emit_trampoline (acfg, acfg->got_offset, info);
mono_aot_register_jit_icall ("mono_amd64_throw_corlib_exception", mono_amd64_throw_corlib_exception);
mono_aot_register_jit_icall ("mono_amd64_resume_unwind", mono_amd64_resume_unwind);
mono_aot_register_jit_icall ("mono_amd64_get_original_ip", mono_amd64_get_original_ip);
- mono_aot_register_jit_icall ("mono_amd64_handler_block_trampoline_helper", mono_amd64_handler_block_trampoline_helper);
#if defined(MONO_ARCH_GSHAREDVT_SUPPORTED)
mono_aot_register_jit_icall ("mono_amd64_start_gsharedvt_call", mono_amd64_start_gsharedvt_call);
ctx->gregs [reg] = val;
}
-gpointer
-mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value)
-{
- gpointer *sp, old_value;
- char *bp;
-
- /*Load the spvar*/
- bp = (char *)MONO_CONTEXT_GET_BP (ctx);
- sp = (gpointer *)*(gpointer*)(bp + clause->exvar_offset);
-
- old_value = *sp;
- if (old_value < ji->code_start || (char*)old_value > ((char*)ji->code_start + ji->code_size))
- return old_value;
-
- *sp = new_value;
-
- return old_value;
-}
-
/*
* mono_arch_emit_load_aotconst:
*
#define MONO_ARCH_DYN_CALL_PARAM_AREA (DYN_CALL_STACK_ARGS * 8)
#define MONO_ARCH_LLVM_SUPPORTED 1
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD_AOT 1
#define MONO_ARCH_HAVE_CARD_TABLE_WBARRIER 1
#define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
#define MONO_ARCH_GC_MAPS_SUPPORTED 1
int
mono_amd64_get_tls_gs_offset (void) MONO_LLVM_INTERNAL;
-gpointer
-mono_amd64_handler_block_trampoline_helper (void);
-
#if defined(TARGET_WIN32) && !defined(DISABLE_JIT)
#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
mono_aot_register_jit_icall ("mono_arm_start_gsharedvt_call", mono_arm_start_gsharedvt_call);
#endif
mono_aot_register_jit_icall ("mono_arm_unaligned_stack", mono_arm_unaligned_stack);
- mono_aot_register_jit_icall ("mono_arm_handler_block_trampoline_helper", mono_arm_handler_block_trampoline_helper);
#if defined(__ARM_EABI__)
eabi_supported = TRUE;
#endif
return mono_arm_get_exception_trampolines (aot);
}
-gpointer
-mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value)
-{
- gpointer *lr_loc;
- char *old_value;
- char *bp;
-
- /*Load the spvar*/
- bp = MONO_CONTEXT_GET_BP (ctx);
- lr_loc = (gpointer*)(bp + clause->exvar_offset);
-
- old_value = *lr_loc;
- if ((char*)old_value < (char*)ji->code_start || (char*)old_value > ((char*)ji->code_start + ji->code_size))
- return old_value;
-
- *lr_loc = new_value;
-
- return old_value;
-}
-
#if defined(MONO_ARCH_SOFT_DEBUG_SUPPORTED)
/*
* mono_arch_set_breakpoint:
#define MONO_ARCH_GC_MAPS_SUPPORTED 1
#define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
#define MONO_ARCH_HAVE_CONTEXT_SET_INT_REG 1
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
-#ifndef TARGET_IOS
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD_AOT 1
-#endif
#define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
#define MONO_ARCH_GSHAREDVT_SUPPORTED 1
#define MONO_ARCH_HAVE_GENERAL_RGCTX_LAZY_FETCH_TRAMPOLINE 1
void
mono_arm_unaligned_stack (MonoMethod *method);
-gpointer
-mono_arm_handler_block_trampoline_helper (gpointer *ptr);
-
/* MonoJumpInfo **ji */
guint8*
mono_arm_emit_aotconst (gpointer ji, guint8 *code, guint8 *buf, int dreg, int patch_type, gconstpointer data);
{
mono_aot_register_jit_icall ("mono_arm_throw_exception", mono_arm_throw_exception);
mono_aot_register_jit_icall ("mono_arm_resume_unwind", mono_arm_resume_unwind);
- mono_aot_register_jit_icall ("mono_arm_handler_block_trampoline_helper", mono_arm_handler_block_trampoline_helper);
if (!mono_aot_only)
bp_trampoline = mini_get_breakpoint_trampoline ();
return get_call_info (mp, sig);
}
-gpointer
-mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value)
-{
- gpointer *lr_loc;
- char *old_value;
- char *bp;
-
- /*Load the spvar*/
- bp = MONO_CONTEXT_GET_BP (ctx);
- lr_loc = (gpointer*)(bp + clause->exvar_offset);
-
- old_value = *lr_loc;
- if ((char*)old_value < (char*)ji->code_start || (char*)old_value > ((char*)ji->code_start + ji->code_size))
- return old_value;
-
- *lr_loc = new_value;
-
- return old_value;
-}
#define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
#define MONO_ARCH_HAVE_OPCODE_NEEDS_EMULATION 1
#define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
#define MONO_ARCH_HAVE_INIT_LMF_EXT 1
-#ifndef TARGET_IOS
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD_AOT 1
-#endif
#ifdef TARGET_IOS
void mono_arm_resume_unwind (gpointer arg, mgreg_t pc, mgreg_t *int_regs, gdouble *fp_regs, gboolean corlib, gboolean rethrow);
-gpointer mono_arm_handler_block_trampoline_helper (gpointer *ptr);
-
CallInfo* mono_arch_get_call_info (MonoMemPool *mp, MonoMethodSignature *sig);
#endif /* __MONO_MINI_ARM64_H__ */
FindHandlerBlockData data = { 0 };
MonoJitTlsData *jit_tls = (MonoJitTlsData *)ctx->unwind_data [MONO_UNWIND_DATA_JIT_TLS];
-#ifndef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD_AOT
- if (mono_aot_only)
- return FALSE;
-#endif
-
/* Guard against a null MonoJitTlsData. This can happens if the thread receives the
* interrupt signal before the JIT has time to initialize its TLS data for the given thread.
*/
}
}
-
-#if 0
-// FIXME: To get the test case finally_block_ending_in_dead_bb to work properly we need to define the following
-// (in mini-ppc.h) and then implement the fuction mono_arch_create_handler_block_trampoline.
-// #define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
-
-gpointer
-mono_arch_create_handler_block_trampoline (void)
-{
- . . .
-}
-#endif
#define MONO_ARCH_HAVE_DECOMPOSE_VTYPE_OPTS 1
#define MONO_ARCH_RETURN_CAN_USE_MULTIPLE_REGISTERS 1
-// FIXME: To get the test case finally_block_ending_in_dead_bb to work properly define the following
-// and then implement the fuction mono_arch_create_handler_block_trampoline.
-// #define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
-
// Define "DEBUG_ELFABIV2" to allow for debugging output for ELF ABI v2 function call and return codegen
// #define DEBUG_ELFABIV2
/*========================= End of Function ========================*/
-/*------------------------------------------------------------------*/
-/* */
-/* Name - mono_arch_install_handler_block_guard */
-/* */
-/* Function - */
-/* */
-/*------------------------------------------------------------------*/
-
-gpointer
-mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause,
- MonoContext *ctx, gpointer new_value)
-{
- int offset;
- gpointer *sp, old_value;
- char *bp;
-
- offset = clause->exvar_offset;
-
- /*Load the spvar*/
- bp = MONO_CONTEXT_GET_BP (ctx);
- sp = *(gpointer*)(bp + offset);
-
- old_value = *sp;
- if (old_value < ji->code_start || (char*)old_value > ((char*)ji->code_start + ji->code_size))
- return old_value;
-
- *sp = new_value;
-
- return old_value;
-}
-
-/*========================= End of Function ========================*/
-
/*------------------------------------------------------------------*/
/* */
/* Name - get_delegate_invoke_impl. */
#define MONO_ARCH_GC_MAPS_SUPPORTED 1
#define MONO_ARCH_GSHARED_SUPPORTED 1
#define MONO_ARCH_MONITOR_ENTER_ADJUSTMENT 1
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
#define MONO_ARCH_HAVE_INVALIDATE_METHOD 1
#define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
#define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
return code;
}
-#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
-static gpointer
-mono_handler_block_guard_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_info, guint8* tramp)
-{
- MONO_REQ_GC_UNSAFE_MODE;
-
- MonoContext ctx;
- MonoException *exc;
- MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls ();
- gpointer resume_ip = jit_tls->handler_block_return_address;
-
- memcpy (&ctx, &jit_tls->handler_block_context, sizeof (MonoContext));
- MONO_CONTEXT_SET_IP (&ctx, jit_tls->handler_block_return_address);
-
- jit_tls->handler_block_return_address = NULL;
- jit_tls->handler_block = NULL;
-
- if (!resume_ip) /*this should not happen, but we should avoid crashing */
- exc = mono_get_exception_execution_engine ("Invalid internal state, resuming abort after handler block but no resume ip found");
- else
- exc = mono_thread_resume_interruption (TRUE);
-
- if (exc) {
- mono_handle_exception (&ctx, (MonoObject *)exc);
- mono_restore_context (&ctx);
- }
-
- return resume_ip;
-}
-
-gpointer
-mono_create_handler_block_trampoline (void)
-{
- static gpointer code;
-
- if (code)
- return code;
-
- if (mono_aot_only) {
- gpointer tmp = mono_aot_get_trampoline ("handler_block_trampoline");
- g_assert (tmp);
- mono_memory_barrier ();
- code = tmp;
- return code;
- }
-
- mono_trampolines_lock ();
- if (!code) {
- MonoTrampInfo *info;
- gpointer tmp;
-
- tmp = mono_arch_create_handler_block_trampoline (&info, FALSE);
- mono_tramp_info_register (info, NULL);
- mono_memory_barrier ();
- code = tmp;
- }
- mono_trampolines_unlock ();
-
- return code;
-}
-#endif
-
/*
* mono_get_trampoline_func:
*
#endif
case MONO_TRAMPOLINE_VCALL:
return mono_vcall_trampoline;
-#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
- case MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD:
- return mono_handler_block_guard_trampoline;
-#endif
default:
g_assert_not_reached ();
return NULL;
mono_trampoline_code [MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING] = create_trampoline_code (MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING);
#endif
mono_trampoline_code [MONO_TRAMPOLINE_VCALL] = create_trampoline_code (MONO_TRAMPOLINE_VCALL);
-#ifdef MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD
- mono_trampoline_code [MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD] = create_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
- mono_create_handler_block_trampoline ();
-#endif
mono_counters_register ("Calls to trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &trampoline_calls);
mono_counters_register ("JIT trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &jit_trampolines);
"delegate",
"restore_stack_prot",
"generic_virtual_remoting",
- "vcall",
- "handler_block_guard"
+ "vcall"
};
/*
#endif /* MONO_ARCH_SIMD_INTRINSICS */
}
-/*MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD*/
-gpointer
-mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value)
-{
- int offset;
- gpointer *sp, old_value;
- char *bp;
-
- offset = clause->exvar_offset;
-
- /*Load the spvar*/
- bp = MONO_CONTEXT_GET_BP (ctx);
- sp = *(gpointer*)(bp + offset);
-
- old_value = *sp;
- if (old_value < ji->code_start || (char*)old_value > ((char*)ji->code_start + ji->code_size))
- return old_value;
-
- *sp = new_value;
-
- return old_value;
-}
-
/*
* mono_aot_emit_load_got_addr:
*
#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
#define MONO_ARCH_HAVE_EXCEPTIONS_INIT 1
-#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
#define MONO_ARCH_HAVE_CARD_TABLE_WBARRIER 1
#define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
MonoContext ex_ctx;
ResumeState resume_state;
- /*Variabled use to implement handler blocks (finally/catch/etc) guards during interruption*/
- /* handler block return address */
- gpointer handler_block_return_address;
-
/* handler block been guarded. It's safe to store this even for dynamic methods since there
is an activation on stack making sure it will remain alive.*/
MonoJitExceptionInfo *handler_block;
MONO_TRAMPOLINE_RESTORE_STACK_PROT,
MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING,
MONO_TRAMPOLINE_VCALL,
- MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD,
MONO_TRAMPOLINE_NUM
} MonoTrampolineType;
/* These trampolines receive an argument directly in a register */
#define MONO_TRAMPOLINE_TYPE_HAS_ARG(t) \
- ((t) == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD)
+ (FALSE)
/* optimization flags */
#define OPTFLAG(id,shift,name,descr) MONO_OPT_ ## id = 1 << shift,
GSList *mono_arch_get_trampolines (gboolean aot);
gpointer mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info);
-/* Handle block guard */
-gpointer mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value);
-gpointer mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot);
-gpointer mono_create_handler_block_trampoline (void);
-
/*New interruption machinery */
void
mono_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data);
MonoJumpInfo *ji = NULL;
const guint kMaxCodeSize = 630;
- if (tramp_type == MONO_TRAMPOLINE_JUMP || tramp_type == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD)
+ if (tramp_type == MONO_TRAMPOLINE_JUMP)
has_caller = FALSE;
else
has_caller = TRUE;
mono_amd64_patch (br [0], code);
//amd64_breakpoint (code);
- if (tramp_type != MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD) {
- /* Obtain the trampoline argument which is encoded in the instruction stream */
- if (aot) {
- /* Load the GOT offset */
- amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, tramp_offset, sizeof(gpointer));
- /*
- * r11 points to a call *<offset>(%rip) instruction, load the
- * pc-relative offset from the instruction itself.
- */
- amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 3, 4);
- /* 7 is the length of the call, 8 is the offset to the next got slot */
- amd64_alu_reg_imm_size (code, X86_ADD, AMD64_RAX, 7 + sizeof (gpointer), sizeof(gpointer));
- /* Compute the address of the GOT slot */
- amd64_alu_reg_reg_size (code, X86_ADD, AMD64_R11, AMD64_RAX, sizeof(gpointer));
- /* Load the value */
- amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0, sizeof(gpointer));
- } else {
- amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, tramp_offset, sizeof(gpointer));
- amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 5, 1);
- amd64_widen_reg (code, AMD64_RAX, AMD64_RAX, TRUE, FALSE);
- amd64_alu_reg_imm_size (code, X86_CMP, AMD64_RAX, 4, 1);
- br [0] = code;
- x86_branch8 (code, X86_CC_NE, 6, FALSE);
- /* 32 bit immediate */
- amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 4);
- br [1] = code;
- x86_jump8 (code, 10);
- /* 64 bit immediate */
- mono_amd64_patch (br [0], code);
- amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 8);
- mono_amd64_patch (br [1], code);
- }
- amd64_mov_membase_reg (code, AMD64_RBP, arg_offset, AMD64_R11, sizeof(gpointer));
+ /* Obtain the trampoline argument which is encoded in the instruction stream */
+ if (aot) {
+ /* Load the GOT offset */
+ amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, tramp_offset, sizeof(gpointer));
+ /*
+ * r11 points to a call *<offset>(%rip) instruction, load the
+ * pc-relative offset from the instruction itself.
+ */
+ amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 3, 4);
+ /* 7 is the length of the call, 8 is the offset to the next got slot */
+ amd64_alu_reg_imm_size (code, X86_ADD, AMD64_RAX, 7 + sizeof (gpointer), sizeof(gpointer));
+ /* Compute the address of the GOT slot */
+ amd64_alu_reg_reg_size (code, X86_ADD, AMD64_R11, AMD64_RAX, sizeof(gpointer));
+ /* Load the value */
+ amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0, sizeof(gpointer));
} else {
- amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, saved_regs_offset + (MONO_AMD64_ARG_REG1 * sizeof(mgreg_t)), sizeof(mgreg_t));
- amd64_mov_membase_reg (code, AMD64_RBP, arg_offset, AMD64_R11, sizeof(gpointer));
+ amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, tramp_offset, sizeof(gpointer));
+ amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 5, 1);
+ amd64_widen_reg (code, AMD64_RAX, AMD64_RAX, TRUE, FALSE);
+ amd64_alu_reg_imm_size (code, X86_CMP, AMD64_RAX, 4, 1);
+ br [0] = code;
+ x86_branch8 (code, X86_CC_NE, 6, FALSE);
+ /* 32 bit immediate */
+ amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 4);
+ br [1] = code;
+ x86_jump8 (code, 10);
+ /* 64 bit immediate */
+ mono_amd64_patch (br [0], code);
+ amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 6, 8);
+ mono_amd64_patch (br [1], code);
}
+ amd64_mov_membase_reg (code, AMD64_RBP, arg_offset, AMD64_R11, sizeof(gpointer));
/* Save LMF begin */
}
#endif /* !DISABLE_JIT */
-gpointer
-mono_amd64_handler_block_trampoline_helper (void)
-{
- MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls ();
- return jit_tls->handler_block_return_address;
-}
-
-#ifndef DISABLE_JIT
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- guint8 *code, *buf;
- int tramp_size = 64;
- MonoJumpInfo *ji = NULL;
- GSList *unwind_ops;
-
- code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size + MONO_TRAMPOLINE_UNWINDINFO_SIZE(0));
-
- unwind_ops = mono_arch_get_cie_program ();
-
- /*
- * This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
- * We get here from the ret emitted by CEE_ENDFINALLY.
- * The stack is misaligned.
- */
- /* Align the stack before the call to mono_amd64_handler_block_trampoline_helper() */
-#ifdef TARGET_WIN32
- /* Also make room for the "register parameter stack area" as specified by the Windows x64 ABI (4 64-bit registers) */
- amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 8 + 4 * 8);
-#else
- amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 8);
-#endif
- if (aot) {
- code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_amd64_handler_block_trampoline_helper");
- amd64_call_reg (code, AMD64_R11);
- } else {
- amd64_mov_reg_imm (code, AMD64_RAX, mono_amd64_handler_block_trampoline_helper);
- amd64_call_reg (code, AMD64_RAX);
- }
- /* Undo stack alignment */
-#ifdef TARGET_WIN32
- amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 8 + 4 * 8);
-#else
- amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 8);
-#endif
- /* Save the result to the stack */
- amd64_push_reg (code, AMD64_RAX);
-#ifdef TARGET_WIN32
- /* Make room for the "register parameter stack area" as specified by the Windows x64 ABI (4 64-bit registers) */
- amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 4 * 8);
-#endif
- if (aot) {
- char *name = g_strdup_printf ("trampoline_func_%d", MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
- code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, name);
- amd64_mov_reg_reg (code, AMD64_RAX, AMD64_R11, 8);
- } else {
- amd64_mov_reg_imm (code, AMD64_RAX, mono_get_trampoline_func (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD));
- }
- /* The stack is aligned */
- amd64_call_reg (code, AMD64_RAX);
-#ifdef TARGET_WIN32
- amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, 4 * 8);
-#endif
- /* Load return address */
- amd64_pop_reg (code, AMD64_RAX);
- /* The stack is misaligned, thats what the code we branch to expects */
- amd64_jump_reg (code, AMD64_RAX);
-
- mono_arch_flush_icache (buf, code - buf);
- MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL));
- g_assert (code - buf <= tramp_size);
- g_assert_checked (mono_arch_unwindinfo_validate_size (unwind_ops, MONO_TRAMPOLINE_UNWINDINFO_SIZE(0)));
-
- *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
-
- return buf;
-}
-#endif /* !DISABLE_JIT */
-
/*
* mono_arch_get_call_target:
*
return NULL;
}
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
void
mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
{
*(guint8**)jump_entry = addr;
}
-gpointer
-mono_arm_handler_block_trampoline_helper (gpointer *ptr)
-{
- MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
- return jit_tls->handler_block_return_address;
-}
-
#ifndef DISABLE_JIT
#define arm_is_imm12(v) ((int)(v) > -4096 && (int)(v) < 4096)
return buf;
}
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- guint8 *tramp;
- guint8 *code, *buf;
- int tramp_size = 64;
- MonoJumpInfo *ji = NULL;
- GSList *unwind_ops = NULL;
-
- code = buf = mono_global_codeman_reserve (tramp_size);
-
- unwind_ops = mono_arch_get_cie_program ();
-
- tramp = mono_arch_create_specific_trampoline (NULL, MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD, NULL, NULL);
-
- /*
- This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
- */
-
- /*
- * We are in a method frame after the call emitted by OP_CALL_HANDLER.
- */
- /* Obtain jit_tls->handler_block_return_address */
- if (aot) {
- code = mono_arm_emit_aotconst (&ji, code, buf, ARMREG_R0, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_arm_handler_block_trampoline_helper");
- } else {
- ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0);
- ARM_B (code, 0);
- *(gpointer*)code = mono_arm_handler_block_trampoline_helper;
- code += 4;
- }
- ARM_BLX_REG (code, ARMREG_R0);
- /* Set it as the return address so the trampoline will return to it */
- ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_R0);
-
- /* Call the trampoline */
- if (aot) {
- char *name = g_strdup_printf ("trampoline_func_%d", MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
- code = mono_arm_emit_aotconst (&ji, code, buf, ARMREG_R0, MONO_PATCH_INFO_JIT_ICALL_ADDR, name);
- code = emit_bx (code, ARMREG_R0);
- } else {
- ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0);
- code = emit_bx (code, ARMREG_R0);
- *(gpointer*)code = tramp;
- code += 4;
- }
-
- mono_arch_flush_icache (buf, code - buf);
- MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL));
- g_assert (code - buf <= tramp_size);
-
- *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
-
- return buf;
-}
-
guint8*
mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
{
return NULL;
}
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
guint8*
mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
{
return ((guint32*)plt_entry) [4];
}
-gpointer
-mono_arm_handler_block_trampoline_helper (gpointer *ptr)
-{
- MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
- return jit_tls->handler_block_return_address;
-}
-
#ifndef DISABLE_JIT
guchar*
return buf;
}
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- guint8 *tramp;
- guint8 *code, *buf;
- int tramp_size = 64;
- MonoJumpInfo *ji = NULL;
- GSList *unwind_ops = NULL;
-
- code = buf = mono_global_codeman_reserve (tramp_size);
-
- unwind_ops = NULL;
-
- /*
- This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
- */
-
- /*
- * We are in a method frame after the call emitted by OP_CALL_HANDLER.
- */
- /* Call a helper to obtain jit_tls->handler_block_return_address */
- if (aot)
- code = mono_arm_emit_aotconst (&ji, code, buf, ARMREG_IP0, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_arm_handler_block_trampoline_helper");
- else
- code = mono_arm_emit_imm64 (code, ARMREG_IP0, (guint64)mono_arm_handler_block_trampoline_helper);
- arm_blrx (code, ARMREG_IP0);
- /* Set it as the return address so the trampoline will return to it */
- arm_movx (code, ARMREG_LR, ARMREG_R0);
-
- /* Call the C trampoline function */
- if (aot) {
- char *name = g_strdup_printf ("trampoline_func_%d", MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
- code = mono_arm_emit_aotconst (&ji, code, buf, ARMREG_IP0, MONO_PATCH_INFO_JIT_ICALL_ADDR, name);
- } else {
- tramp = mono_arch_create_specific_trampoline (NULL, MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD, NULL, NULL);
- code = mono_arm_emit_imm64 (code, ARMREG_IP0, (guint64)tramp);
- }
- arm_brx (code, ARMREG_IP0);
-
- mono_arch_flush_icache (buf, code - buf);
- MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL));
- g_assert (code - buf <= tramp_size);
-
- *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
-
- return buf;
-}
-
/*
* mono_arch_create_sdb_trampoline:
*
return NULL;
}
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- g_assert_not_reached ();
- return NULL;
-}
-
gpointer
mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
{
code = buf = mono_global_codeman_reserve(512);
- if ((tramp_type == MONO_TRAMPOLINE_JUMP) ||
- (tramp_type == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD))
+ if (tramp_type == MONO_TRAMPOLINE_JUMP)
has_caller = 0;
else
has_caller = 1;
}
/*========================= End of Function ========================*/
-
-/*------------------------------------------------------------------*/
-/* */
-/* Name - handler_block_trampoline_helper */
-/* */
-/* Function - */
-/* */
-/*------------------------------------------------------------------*/
-
-static void
-handler_block_trampoline_helper (gpointer *ptr)
-{
- MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
- *ptr = jit_tls->handler_block_return_address;
-}
-
-/*========================= End of Function ========================*/
-
-/*------------------------------------------------------------------*/
-/* */
-/* Name - mono_arch_create_handler_block_trampoline */
-/* */
-/* Function - */
-/* */
-/*------------------------------------------------------------------*/
-
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
- guint8 *code, *buf;
- int tramp_size = 64;
- MonoJumpInfo *ji = NULL;
- GSList *unwind_ops = NULL;
-
- g_assert (!aot);
-
- code = buf = mono_global_codeman_reserve (tramp_size);
-
- /*
- * This trampoline restore the call chain of the handler block
- * then jumps into the code that deals with it.
- */
-
- /*
- * Slow path uses a C helper
- */
- S390_SET (code, s390_r2, tramp);
- S390_SET (code, s390_r1, handler_block_trampoline_helper);
- s390_br (code, s390_r1);
-
- mono_arch_flush_icache (buf, code - buf);
- MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL));
- g_assert (code - buf <= tramp_size);
-
- *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
-
- return buf;
-}
-
-/*========================= End of Function ========================*/
mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
x86_ret (code);
} else {
- /* The trampoline argument is at the top of the stack, and it contains the address we need to branch to */
- if (tramp_type == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD) {
- x86_pop_reg (code, X86_EAX);
- cfa_offset -= sizeof (mgreg_t);
- mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
- x86_alu_reg_imm (code, X86_ADD, X86_ESP, 0x8);
- x86_jump_reg (code, X86_EAX);
- } else {
- x86_ret (code);
- }
+ x86_ret (code);
}
g_assert ((code - buf) <= 256);
x86_call_code (code, (guint8*)func);
}
-static gpointer
-handler_block_trampoline_helper (void)
-{
- MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
- return jit_tls->handler_block_return_address;
-}
-
-gpointer
-mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
-{
- guint8 *tramp = mono_get_trampoline_code (MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD);
- guint8 *code, *buf;
- int tramp_size = 64;
- MonoJumpInfo *ji = NULL;
- int cfa_offset;
- GSList *unwind_ops = NULL;
-
- g_assert (!aot);
-
- code = buf = mono_global_codeman_reserve (tramp_size);
-
- unwind_ops = mono_arch_get_cie_program ();
- cfa_offset = sizeof (mgreg_t);
- /*
- This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
- */
-
- /*
- * We are in a method frame after the call emitted by OP_CALL_HANDLER.
- */
-
- /*Slow path uses a c helper*/
- x86_call_code (code, handler_block_trampoline_helper);
- /* Simulate a call */
- /*Fix stack alignment*/
- x86_alu_reg_imm (code, X86_SUB, X86_ESP, 0x4);
- cfa_offset += sizeof (mgreg_t);
- mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
-
- /* This is the address the trampoline will return to */
- x86_push_reg (code, X86_EAX);
- cfa_offset += sizeof (mgreg_t);
- mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
-
- /* Dummy trampoline argument, since we call the generic trampoline directly */
- x86_push_imm (code, 0);
- cfa_offset += sizeof (mgreg_t);
- mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
- x86_jump_code (code, tramp);
-
- mono_arch_flush_icache (buf, code - buf);
- MONO_PROFILER_RAISE (jit_code_buffer, (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL));
- g_assert (code - buf <= tramp_size);
-
- *info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
-
- return buf;
-}
-
guint8*
mono_arch_get_call_target (guint8 *code)
{