Author: zoltan
Date: 2005-03-13 11:56:59 -0500 (Sun, 13 Mar 2005)
New Revision: 41764
Modified:
trunk/mono/mono/mini/ChangeLog
trunk/mono/mono/mini/mini-amd64.c
Log:
2005-03-13 Zoltan Varga <[EMAIL PROTECTED]>
* mini-amd64.c: Handle large stack allocations the same way as on
windows if stack overflow handling is working.
Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog 2005-03-13 16:24:52 UTC (rev 41763)
+++ trunk/mono/mono/mini/ChangeLog 2005-03-13 16:56:59 UTC (rev 41764)
@@ -1,5 +1,8 @@
2005-03-13 Zoltan Varga <[EMAIL PROTECTED]>
+ * mini-amd64.c: Handle large stack allocations the same way as on
+ windows if stack overflow handling is working.
+
* mini-amd64.c: Allocate the signal stack using mmap.
* mini.c (sigsegv_signal_handler): Fix reading of context.
Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c 2005-03-13 16:24:52 UTC (rev 41763)
+++ trunk/mono/mono/mini/mini-amd64.c 2005-03-13 16:56:59 UTC (rev 41764)
@@ -2972,48 +2972,54 @@
mono_emit_stack_alloc (guchar *code, MonoInst* tree)
{
int sreg = tree->sreg1;
-#ifdef PLATFORM_WIN32
- guint8* br[5];
+ int need_touch = FALSE;
- NOT_IMPLEMENTED;
+#if defined(PLATFORM_WIN32) || defined(MONO_ARCH_SIGSEGV_ON_ALTSTACK)
+ if (!tree->flags & MONO_INST_INIT)
+ need_touch = TRUE;
+#endif
- /*
- * Under Windows:
- * If requested stack size is larger than one page,
- * perform stack-touch operation
- */
- /*
- * Generate stack probe code.
- * Under Windows, it is necessary to allocate one page at a time,
- * "touching" stack after each successful sub-allocation. This is
- * because of the way stack growth is implemented - there is a
- * guard page before the lowest stack page that is currently commited.
- * Stack normally grows sequentially so OS traps access to the
- * guard page and commits more pages when needed.
- */
- amd64_test_reg_imm (code, sreg, ~0xFFF);
- br[0] = code; x86_branch8 (code, X86_CC_Z, 0, FALSE);
+ if (need_touch) {
+ guint8* br[5];
- br[2] = code; /* loop */
- amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 0x1000);
- amd64_test_membase_reg (code, AMD64_RSP, 0, AMD64_RSP);
- amd64_alu_reg_imm (code, X86_SUB, sreg, 0x1000);
- amd64_alu_reg_imm (code, X86_CMP, sreg, 0x1000);
- br[3] = code; x86_branch8 (code, X86_CC_AE, 0, FALSE);
- amd64_patch (br[3], br[2]);
- amd64_test_reg_reg (code, sreg, sreg);
- br[4] = code; x86_branch8 (code, X86_CC_Z, 0, FALSE);
- amd64_alu_reg_reg (code, X86_SUB, AMD64_RSP, sreg);
+ /*
+ * Under Windows:
+ * If requested stack size is larger than one page,
+ * perform stack-touch operation
+ */
+ /*
+ * Generate stack probe code.
+ * Under Windows, it is necessary to allocate one page at a
time,
+ * "touching" stack after each successful sub-allocation. This
is
+ * because of the way stack growth is implemented - there is a
+ * guard page before the lowest stack page that is currently
commited.
+ * Stack normally grows sequentially so OS traps access to the
+ * guard page and commits more pages when needed.
+ */
+ amd64_test_reg_imm (code, sreg, ~0xFFF);
+ br[0] = code; x86_branch8 (code, X86_CC_Z, 0, FALSE);
- br[1] = code; x86_jump8 (code, 0);
+ br[2] = code; /* loop */
+ amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 0x1000);
+ amd64_test_membase_reg (code, AMD64_RSP, 0, AMD64_RSP);
+ amd64_alu_reg_imm (code, X86_SUB, sreg, 0x1000);
+ amd64_alu_reg_imm (code, X86_CMP, sreg, 0x1000);
+ br[3] = code; x86_branch8 (code, X86_CC_AE, 0, FALSE);
+ amd64_patch (br[3], br[2]);
+ amd64_test_reg_reg (code, sreg, sreg);
+ br[4] = code; x86_branch8 (code, X86_CC_Z, 0, FALSE);
+ amd64_alu_reg_reg (code, X86_SUB, AMD64_RSP, sreg);
- amd64_patch (br[0], code);
- amd64_alu_reg_reg (code, X86_SUB, AMD64_RSP, sreg);
- amd64_patch (br[1], code);
- amd64_patch (br[4], code);
-#else /* PLATFORM_WIN32 */
- amd64_alu_reg_reg (code, X86_SUB, AMD64_RSP, tree->sreg1);
-#endif
+ br[1] = code; x86_jump8 (code, 0);
+
+ amd64_patch (br[0], code);
+ amd64_alu_reg_reg (code, X86_SUB, AMD64_RSP, sreg);
+ amd64_patch (br[1], code);
+ amd64_patch (br[4], code);
+ }
+ else
+ amd64_alu_reg_reg (code, X86_SUB, AMD64_RSP, tree->sreg1);
+
if (tree->flags & MONO_INST_INIT) {
int offset = 0;
if (tree->dreg != AMD64_RAX && sreg != AMD64_RAX) {
@@ -5016,7 +5022,7 @@
if (alloc_size) {
/* See mono_emit_stack_alloc */
-#ifdef PLATFORM_WIN32
+#if defined(PLATFORM_WIN32) || defined(MONO_ARCH_SIGSEGV_ON_ALTSTACK)
guint32 remaining_size = alloc_size;
while (remaining_size >= 0x1000) {
amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 0x1000);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches