This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [split] Add x86 support


On 09/25/2009 05:56 PM, Ian Lance Taylor wrote:
This adds x86-specific support for -fsplit-stack.  This uses the stack
protector field in the TCB.  I've filed a glibc bug asking for a new
field, but no response as yet.

Don't take it as gospel, but Uli gave me 5 slots for transactional memory, and I only really need 3. Word 15 should be free.


+(define_expand "split_stack_check_small"
+(define_expand "split_stack_check_large"

There's no point in separate patterns here, since _small is exactly _large with stack_pointer_rtx. Although I like Ross' idea to use a special memory thingy, to avoid new patterns at all.


+	  else
+	    {
+	      /* FIXME: We could make this work by pushing a register
+		 around the addition and comparison.  */
+	      sorry ("-fsplit-stack does not support 3 register parameters");
+	      scratch_regno = CX_REG;
+	    }

There's no reason to use a push either, so long as you're prepared to add some extra unwind info. You can do


	sub	$10000, %esp
	cmp	%esp, %gs:0x14
	lea	-10000(%esp), %esp

or perhaps even begin with the assumption that the stack allocation will
succeed, and only in the failure case deallocate and call __morestack.
Something like

	sub	$10000, %esp
	cmp	$esp, %gs:0x14
	jcc	.Lmorestack
.Lmorestack_ret:
	// rest of prologue

// rest of function

.Lmorestack:
	add	$10000, %esp
	pushl	$10000
	pushl	$64
	call	__morestack
	jmp	.Lmorestack_ret

+  /* Get more stack space.  We pass in the desired stack space and the
+     size of the arguments to copy to the new stack.  In 32-bit mode
+     we push the parameters; __morestack will return on a new stack
+     anyhow.  In 64-bit mode we pass the parameters in r10 and
+     r11.  */

You need to care for the static chain register. And the new static chain push in the case of regparm=3.



r~



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]