]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6c, cmd/8c: cut stack frames by about half
authorRuss Cox <rsc@golang.org>
Mon, 18 Feb 2013 18:24:04 +0000 (13:24 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 18 Feb 2013 18:24:04 +0000 (13:24 -0500)
The routine that adds an automatic to the stack was
adding ptrsize-1 to the size before rounding up.
That addition would only make sense to turn a round down
into a round up. Before a round up, it just wastes a word.

The effect was that a 6c function with one local and
one two-word function call used (8+8)+(16+8) = 40 bytes
instead of 8+16 = 24 bytes.

The wasted space mostly didn't matter, but one place where
it does matter is when trying to stay within the 128-byte
total frame constraint for #pragma textflag 7 functions.

This only affects the C compilers, not the Go compilers.

5c already had correct code, which is now copied to 6c and 8c.

R=ken2
CC=golang-dev
https://golang.org/cl/7303099

src/cmd/6c/swt.c
src/cmd/8c/swt.c

index 2c5b3e604cfdace520b1339d8157f9eeb6aac157..53b12d9941aadd5b69a58e3845ca4d33916a8948 100644 (file)
@@ -626,8 +626,8 @@ align(int32 i, Type *t, int op, int32 *maxalign)
 int32
 maxround(int32 max, int32 v)
 {
-       v += SZ_VLONG-1;
+       v = xround(v, SZ_LONG);
        if(v > max)
-               max = xround(v, SZ_VLONG);
+               return v;
        return max;
 }
index 18611ea1e836b74ce62a50df5828b4fffcc9877f..dc68b60354153e060109582f91e04a9faaa289c9 100644 (file)
@@ -632,8 +632,8 @@ align(int32 i, Type *t, int op, int32 *maxalign)
 int32
 maxround(int32 max, int32 v)
 {
-       v += SZ_LONG-1;
+       v = xround(v, SZ_LONG);
        if(v > max)
-               max = xround(v, SZ_LONG);
+               return v;
        return max;
 }