mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj/arm64: simplify huge frame prologue
CL 307010 for arm64. Change-Id: I6c6e1bd6065df059e50c3632a9eb669b64fce899 Reviewed-on: https://go-review.googlesource.com/c/go/+/307050 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
24dd8cfe23
commit
4702dd67a7
1 changed files with 18 additions and 38 deletions
|
|
@ -107,55 +107,35 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||||
p.From.Reg = REG_R1
|
p.From.Reg = REG_R1
|
||||||
p.Reg = REG_R2
|
p.Reg = REG_R2
|
||||||
} else {
|
} else {
|
||||||
// Such a large stack we need to protect against wraparound
|
// Such a large stack we need to protect against underflow.
|
||||||
// if SP is close to zero.
|
// The runtime guarantees SP > objabi.StackBig, but
|
||||||
// SP-stackguard+StackGuard < framesize + (StackGuard-StackSmall)
|
// framesize is large enough that SP-framesize may
|
||||||
// The +StackGuard on both sides is required to keep the left side positive:
|
// underflow, causing a direct comparison with the
|
||||||
// SP is allowed to be slightly below stackguard. See stack.h.
|
// stack guard to incorrectly succeed. We explicitly
|
||||||
// CMP $StackPreempt, R1
|
// guard against underflow.
|
||||||
// BEQ label_of_call_to_morestack
|
//
|
||||||
// ADD $StackGuard, SP, R2
|
// SUBS $(framesize-StackSmall), SP, R2
|
||||||
// SUB R1, R2
|
// // On underflow, jump to morestack
|
||||||
// MOV $(framesize+(StackGuard-StackSmall)), R3
|
// BLO label_of_call_to_morestack
|
||||||
// CMP R3, R2
|
// CMP stackguard, R2
|
||||||
p = obj.Appendp(p, c.newprog)
|
|
||||||
|
|
||||||
p.As = ACMP
|
p = obj.Appendp(p, c.newprog)
|
||||||
|
p.As = ASUBS
|
||||||
p.From.Type = obj.TYPE_CONST
|
p.From.Type = obj.TYPE_CONST
|
||||||
p.From.Offset = objabi.StackPreempt
|
p.From.Offset = int64(framesize) - objabi.StackSmall
|
||||||
p.Reg = REG_R1
|
|
||||||
|
|
||||||
p = obj.Appendp(p, c.newprog)
|
|
||||||
q = p
|
|
||||||
p.As = ABEQ
|
|
||||||
p.To.Type = obj.TYPE_BRANCH
|
|
||||||
|
|
||||||
p = obj.Appendp(p, c.newprog)
|
|
||||||
p.As = AADD
|
|
||||||
p.From.Type = obj.TYPE_CONST
|
|
||||||
p.From.Offset = int64(objabi.StackGuard)
|
|
||||||
p.Reg = REGSP
|
p.Reg = REGSP
|
||||||
p.To.Type = obj.TYPE_REG
|
p.To.Type = obj.TYPE_REG
|
||||||
p.To.Reg = REG_R2
|
p.To.Reg = REG_R2
|
||||||
|
|
||||||
p = obj.Appendp(p, c.newprog)
|
p = obj.Appendp(p, c.newprog)
|
||||||
p.As = ASUB
|
q = p
|
||||||
p.From.Type = obj.TYPE_REG
|
p.As = ABLO
|
||||||
p.From.Reg = REG_R1
|
p.To.Type = obj.TYPE_BRANCH
|
||||||
p.To.Type = obj.TYPE_REG
|
|
||||||
p.To.Reg = REG_R2
|
|
||||||
|
|
||||||
p = obj.Appendp(p, c.newprog)
|
|
||||||
p.As = AMOVD
|
|
||||||
p.From.Type = obj.TYPE_CONST
|
|
||||||
p.From.Offset = int64(framesize) + (int64(objabi.StackGuard) - objabi.StackSmall)
|
|
||||||
p.To.Type = obj.TYPE_REG
|
|
||||||
p.To.Reg = REG_R3
|
|
||||||
|
|
||||||
p = obj.Appendp(p, c.newprog)
|
p = obj.Appendp(p, c.newprog)
|
||||||
p.As = ACMP
|
p.As = ACMP
|
||||||
p.From.Type = obj.TYPE_REG
|
p.From.Type = obj.TYPE_REG
|
||||||
p.From.Reg = REG_R3
|
p.From.Reg = REG_R1
|
||||||
p.Reg = REG_R2
|
p.Reg = REG_R2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue