}
if (mono_debug_using_mono_debugger ()) {
- guint8 buf [16], *code;
+ guint8 buf [16];
mono_breakpoint_clean_code (NULL, (gpointer)rip, 8, buf, sizeof (buf));
- code = buf + 8;
if (buf [3] == 0xe8) {
MonoContext ctx_cp = ctx;
guint8 *code;
MonoJumpInfo *ji = NULL;
GSList *unwind_ops = NULL;
- int i, stack_size, arg_offsets [16], regs_offset;
+ int i, stack_size, arg_offsets [16], regs_offset, dummy_stack_space;
const guint kMaxCodeSize = NACL_SIZE (256, 512);
+#ifdef TARGET_WIN32
+ dummy_stack_space = 6 * sizeof(mgreg_t); /* Windows expects stack space allocated for all 6 dummy args. */
+#else
+ dummy_stack_space = 0;
+#endif
+
start = code = mono_global_codeman_reserve (kMaxCodeSize);
/* The stack is unaligned on entry */
- stack_size = 192 + 8;
+ stack_size = 192 + 8 + dummy_stack_space;
code = start;
* the stack by passing 6 dummy values in registers.
*/
- arg_offsets [0] = 0;
- arg_offsets [1] = sizeof(mgreg_t);
- arg_offsets [2] = sizeof(mgreg_t) * 2;
- arg_offsets [3] = sizeof(mgreg_t) * 3;
- regs_offset = sizeof(mgreg_t) * 4;
+ arg_offsets [0] = dummy_stack_space + 0;
+ arg_offsets [1] = dummy_stack_space + sizeof(mgreg_t);
+ arg_offsets [2] = dummy_stack_space + sizeof(mgreg_t) * 2;
+ arg_offsets [3] = dummy_stack_space + sizeof(mgreg_t) * 3;
+ regs_offset = dummy_stack_space + sizeof(mgreg_t) * 4;
/* Save registers */
for (i = 0; i < AMD64_NREG; ++i)
ji = mono_patch_info_list_prepend (ji, code - start, MONO_PATCH_INFO_JIT_ICALL_ADDR, corlib ? "mono_amd64_throw_corlib_exception" : "mono_amd64_throw_exception");
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
} else {
- amd64_mov_reg_imm (code, AMD64_R11, resume_unwind ? (mono_amd64_resume_unwind) : (corlib ? (gpointer)mono_amd64_throw_corlib_exception : (gpointer)mono_amd64_throw_exception));
+ amd64_mov_reg_imm (code, AMD64_R11, resume_unwind ? ((gpointer)mono_amd64_resume_unwind) : (corlib ? (gpointer)mono_amd64_throw_corlib_exception : (gpointer)mono_amd64_throw_exception));
}
amd64_call_reg (code, AMD64_R11);
amd64_breakpoint (code);