Skip to content

Commit 430b820

Browse files
committed
cmd/internal/obj/{ppc64,s390x}: mark functions with small stacks NOSPLIT
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 <[email protected]>
1 parent c1ab165 commit 430b820

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/cmd/internal/obj/ppc64/obj9.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
457457
aoffset = 0
458458
autosize = int32(textstksiz)
459459

460-
if p.Mark&LEAF != 0 && autosize == 0 && p.From3.Offset&obj.NOFRAME == 0 {
460+
if p.Mark&LEAF != 0 && autosize == 0 {
461461
// A leaf function with no locals has no frame.
462462
p.From3.Offset |= obj.NOFRAME
463463
}
@@ -468,6 +468,12 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
468468
autosize += int32(ctxt.FixedFrameSize())
469469
}
470470

471+
if p.Mark&LEAF != 0 && autosize < obj.StackSmall {
472+
// A leaf function with a small stack can be marked
473+
// NOSPLIT, avoiding a stack check.
474+
p.From3.Offset |= obj.NOSPLIT
475+
}
476+
471477
p.To.Offset = int64(autosize)
472478

473479
q = p

src/cmd/internal/obj/s390x/objz.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
380380
case obj.ATEXT:
381381
autosize = int32(textstksiz)
382382

383-
if p.Mark&LEAF != 0 && autosize == 0 && p.From3.Offset&obj.NOFRAME == 0 {
383+
if p.Mark&LEAF != 0 && autosize == 0 {
384384
// A leaf function with no locals has no frame.
385385
p.From3.Offset |= obj.NOFRAME
386386
}
@@ -391,11 +391,17 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
391391
autosize += int32(ctxt.FixedFrameSize())
392392
}
393393

394+
if p.Mark&LEAF != 0 && autosize < obj.StackSmall {
395+
// A leaf function with a small stack can be marked
396+
// NOSPLIT, avoiding a stack check.
397+
p.From3.Offset |= obj.NOSPLIT
398+
}
399+
394400
p.To.Offset = int64(autosize)
395401

396402
q = p
397403

398-
if p.From3.Offset&obj.NOSPLIT == 0 && p.From3.Offset&obj.NOFRAME == 0 {
404+
if p.From3.Offset&obj.NOSPLIT == 0 {
399405
p, pPreempt = stacksplitPre(ctxt, p, autosize) // emit pre part of split check
400406
pPre = p
401407
wasSplit = true //need post part of split

0 commit comments

Comments
 (0)