Patchwork Go patch committed: Don't split stack in bytes.IndexByte

login
register
mail settings
Submitter Ian Taylor
Date Dec. 17, 2010, 6:36 a.m.
Message ID <mcrhbecx5wk.fsf@google.com>
Download mbox | patch
Permalink /patch/75838/
State New
Headers show

Comments

Ian Taylor - Dec. 17, 2010, 6:36 a.m.
The function bytes.IndexByte is written in C and simply calls memchr.
This patch changes it to not always split the stack, on the theory that
memchr does not require much stack space.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r d82eb7b97cee libgo/go/bytes/indexbyte.c
--- a/libgo/go/bytes/indexbyte.c	Thu Dec 16 22:28:48 2010 -0800
+++ b/libgo/go/bytes/indexbyte.c	Thu Dec 16 22:34:03 2010 -0800
@@ -8,11 +8,13 @@ 
 
 #include "array.h"
 
-/* This is in C so that the compiler can optimize it
-   appropriately.  */
+/* This is in C so that the compiler can optimize it appropriately.
+   We deliberately don't split the stack in case it does call the
+   library function, which shouldn't need much stack space.  */
 
 int IndexByte (struct __go_open_array, char)
-  asm ("libgo_bytes.bytes.IndexByte");
+  asm ("libgo_bytes.bytes.IndexByte")
+  __attribute__ ((no_split_stack));
 
 int
 IndexByte (struct __go_open_array s, char b)