]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: make morestack cutoff the same on all architectures
authorMichael Munday <munday@ca.ibm.com>
Tue, 28 Mar 2017 19:10:20 +0000 (15:10 -0400)
committerMichael Munday <munday@ca.ibm.com>
Wed, 29 Mar 2017 20:35:46 +0000 (20:35 +0000)
There is always 128 bytes available below the stackguard. Allow functions
with medium-sized stack frames to use this, potentially allowing them to
avoid growing the stack.

This change makes all architectures use the same calculation as x86.

Change-Id: I2afb1a7c686ae5a933e50903b31ea4106e4cd0a0
Reviewed-on: https://go-review.googlesource.com/38734
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/internal/obj/arm/obj5.go
src/cmd/internal/obj/arm64/obj7.go
src/cmd/internal/obj/mips/obj0.go
src/cmd/internal/obj/ppc64/obj9.go
src/cmd/internal/obj/s390x/objz.go

index 0d798e4400580040d6f4449e4625a3a3239cf3c1..630a59cc66091ab11d7d617a0a235df7afd52320 100644 (file)
@@ -747,14 +747,14 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
                p.Reg = REGSP
        } else if framesize <= obj.StackBig {
                // large stack: SP-framesize < stackguard-StackSmall
-               //      MOVW $-framesize(SP), R2
+               //      MOVW $-(framesize-StackSmall)(SP), R2
                //      CMP stackguard, R2
                p = obj.Appendp(ctxt, p)
 
                p.As = AMOVW
                p.From.Type = obj.TYPE_ADDR
                p.From.Reg = REGSP
-               p.From.Offset = int64(-framesize)
+               p.From.Offset = -(int64(framesize) - obj.StackSmall)
                p.To.Type = obj.TYPE_REG
                p.To.Reg = REG_R2
 
index 2d195b19deb2d325ea8e672604b0f7c37d018d3a..020b6e05c1061b838ade4a2a44f9a6052120030f 100644 (file)
@@ -82,13 +82,13 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
                p.Reg = REG_R2
        } else if framesize <= obj.StackBig {
                // large stack: SP-framesize < stackguard-StackSmall
-               //      SUB     $framesize, SP, R2
+               //      SUB     $(framesize-StackSmall), SP, R2
                //      CMP     stackguard, R2
                p = obj.Appendp(ctxt, p)
 
                p.As = ASUB
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(framesize)
+               p.From.Offset = int64(framesize) - obj.StackSmall
                p.Reg = REGSP
                p.To.Type = obj.TYPE_REG
                p.To.Reg = REG_R2
index 11434751e22ff45a09b72a41906fb14f6620aac0..53f648780ad279a6d510b2425380d8477841aa67 100644 (file)
@@ -658,13 +658,13 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
                p.To.Reg = REG_R1
        } else if framesize <= obj.StackBig {
                // large stack: SP-framesize < stackguard-StackSmall
-               //      ADD     $-framesize, SP, R2
+               //      ADD     $-(framesize-StackSmall), SP, R2
                //      SGTU    R2, stackguard, R1
                p = obj.Appendp(ctxt, p)
 
                p.As = add
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(-framesize)
+               p.From.Offset = -(int64(framesize) - obj.StackSmall)
                p.Reg = REGSP
                p.To.Type = obj.TYPE_REG
                p.To.Reg = REG_R2
index 5639ec989dad7ecc53867a201a0c1a1e24e05652..9a3dc4cc724283b5a7247eb1b503d58ce48f934b 100644 (file)
@@ -868,13 +868,13 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
                p.To.Reg = REGSP
        } else if framesize <= obj.StackBig {
                // large stack: SP-framesize < stackguard-StackSmall
-               //      ADD $-framesize, SP, R4
+               //      ADD $-(framesize-StackSmall), SP, R4
                //      CMP stackguard, R4
                p = obj.Appendp(ctxt, p)
 
                p.As = AADD
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(-framesize)
+               p.From.Offset = -(int64(framesize) - obj.StackSmall)
                p.Reg = REGSP
                p.To.Type = obj.TYPE_REG
                p.To.Reg = REG_R4
index 3ca6d19f99f628c54d73fbdd2c99a30869101c18..f5d9365fe42f6eaf3a238bcbac465957d1013c6b 100644 (file)
@@ -586,13 +586,13 @@ func stacksplitPre(ctxt *obj.Link, p *obj.Prog, framesize int32) (*obj.Prog, *ob
 
        } else if framesize <= obj.StackBig {
                // large stack: SP-framesize < stackguard-StackSmall
-               //      ADD $-framesize, SP, R4
+               //      ADD $-(framesize-StackSmall), SP, R4
                //      CMP stackguard, R4
                p = obj.Appendp(ctxt, p)
 
                p.As = AADD
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(-framesize)
+               p.From.Offset = -(int64(framesize) - obj.StackSmall)
                p.Reg = REGSP
                p.To.Type = obj.TYPE_REG
                p.To.Reg = REG_R4