]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/{ppc64,s390x}: mark functions with small stacks NOSPLIT
authorMichael Munday <munday@ca.ibm.com>
Tue, 18 Oct 2016 15:47:42 +0000 (11:47 -0400)
committerMichael Munday <munday@ca.ibm.com>
Tue, 18 Oct 2016 17:07:14 +0000 (17:07 +0000)
This change omits the stack check on ppc64 and s390x when the size of
a stack frame is less than obj.StackSmall. This is an optimization
x86 already performs.

The effect on s390x isn't huge because we were already omitting the
stack check when the frame size was 0 (it shaves about 1K from the
size of bin/go). On ppc64 however this change reduces the size of the
.text section in bin/go by 33K (1%).

Updates #13379 (for ppc64).

Change-Id: I6af0eb987646bea47fcaf0a812db3496bab0f680
Reviewed-on: https://go-review.googlesource.com/31357
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/obj/ppc64/obj9.go
src/cmd/internal/obj/s390x/objz.go

index 0786870fe93a4bfad09a7970b78813fcf68132db..978007c396f23ffcdeb9377a2fe660085f5ccefb 100644 (file)
@@ -457,7 +457,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
                        aoffset = 0
                        autosize = int32(textstksiz)
 
-                       if p.Mark&LEAF != 0 && autosize == 0 && p.From3.Offset&obj.NOFRAME == 0 {
+                       if p.Mark&LEAF != 0 && autosize == 0 {
                                // A leaf function with no locals has no frame.
                                p.From3.Offset |= obj.NOFRAME
                        }
@@ -468,6 +468,12 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
                                autosize += int32(ctxt.FixedFrameSize())
                        }
 
+                       if p.Mark&LEAF != 0 && autosize < obj.StackSmall {
+                               // A leaf function with a small stack can be marked
+                               // NOSPLIT, avoiding a stack check.
+                               p.From3.Offset |= obj.NOSPLIT
+                       }
+
                        p.To.Offset = int64(autosize)
 
                        q = p
index 941e1e8d103b4ae77f6479ecce8caef1915dd0e6..179b5b1396dc0c9dfbf387470c6b0d8c770918a6 100644 (file)
@@ -380,7 +380,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
                case obj.ATEXT:
                        autosize = int32(textstksiz)
 
-                       if p.Mark&LEAF != 0 && autosize == 0 && p.From3.Offset&obj.NOFRAME == 0 {
+                       if p.Mark&LEAF != 0 && autosize == 0 {
                                // A leaf function with no locals has no frame.
                                p.From3.Offset |= obj.NOFRAME
                        }
@@ -391,11 +391,17 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
                                autosize += int32(ctxt.FixedFrameSize())
                        }
 
+                       if p.Mark&LEAF != 0 && autosize < obj.StackSmall {
+                               // A leaf function with a small stack can be marked
+                               // NOSPLIT, avoiding a stack check.
+                               p.From3.Offset |= obj.NOSPLIT
+                       }
+
                        p.To.Offset = int64(autosize)
 
                        q = p
 
-                       if p.From3.Offset&obj.NOSPLIT == 0 && p.From3.Offset&obj.NOFRAME == 0 {
+                       if p.From3.Offset&obj.NOSPLIT == 0 {
                                p, pPreempt = stacksplitPre(ctxt, p, autosize) // emit pre part of split check
                                pPre = p
                                wasSplit = true //need post part of split