start = code = mono_global_codeman_reserve (128);
- /* The + 4 aligns the stack on apple */
- stack_size = 128 + 4;
+ stack_size = 128;
+
+ /*
+ * On apple, the stack is misaligned by the pushing of the return address.
+ */
+ if (!llvm && corlib)
+ /* On OSX, we don't generate alignment code to save space */
+ stack_size += 4;
+ else
+ stack_size += MONO_ARCH_FRAME_ALIGNMENT - 4;
/*
* The stack looks like this:
/* LLVM doesn't push the arguments */
stack_offset = stack_size + 4;
} else {
- if (corlib)
+ if (corlib) {
/* Two arguments */
stack_offset = stack_size + 4 + 8;
- else
+#ifdef __APPLE__
+ /* We don't generate stack alignment code on osx to save space */
+#endif
+ } else {
/* One argument */
stack_offset = stack_size + 4 + 4;
+#ifdef __APPLE__
+ /* Pop the alignment added by OP_THROW too */
+ stack_offset += MONO_ARCH_FRAME_ALIGNMENT - 4;
+#endif
+ }
}
/* Save ESP */
x86_lea_membase (code, X86_EAX, X86_ESP, stack_offset);
return get_throw_exception ("rethrow_exception_trampoline", TRUE, FALSE, FALSE);
}
-/**
- * mono_arch_get_throw_exception_by_name:
- *
- * Returns a function pointer which can be used to raise
- * corlib exceptions. The returned function has the following
- * signature: void (*func) (gpointer ip, char *exc_name);
- * For example to raise an arithmetic exception you can use:
- *
- * x86_push_imm (code, "ArithmeticException");
- * x86_push_imm (code, <IP>)
- * x86_jump_code (code, arch_get_throw_exception_by_name ());
- *
- */
-gpointer
-mono_arch_get_throw_exception_by_name (void)
-{
- guint8* start;
- guint8 *code;
-
- start = code = mono_global_codeman_reserve (32);
-
- /* Not used */
- x86_breakpoint (code);
-
- mono_arch_flush_icache (start, code - start);
-
- return start;
-}
-
/**
* mono_arch_get_throw_corlib_exception:
*