mirror of
https://github.com/golang/go
synced 2024-11-18 06:24:47 -07:00
cmd/internal/obj: consolidate emitting entry stack map
The obj package needs to emit the PCDATA to select the entry stack map before calling morestack. Currently this is copied for every architecture. Since we're about to change how this works, consolidate all of these copies into a single helper function. For #24543. Change-Id: Ia92d94de78f8e23fd06dba747c43e03e5989f67b Reviewed-on: https://go-review.googlesource.com/109346 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
837ed98d63
commit
02495da6b6
@ -768,13 +768,7 @@ func (c *ctxt5) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||
spfix.As = obj.ANOP
|
||||
spfix.Spadj = -framesize
|
||||
|
||||
pcdata := obj.Appendp(spfix, c.newprog)
|
||||
pcdata.Pos = c.cursym.Func.Text.Pos
|
||||
pcdata.As = obj.APCDATA
|
||||
pcdata.From.Type = obj.TYPE_CONST
|
||||
pcdata.From.Offset = objabi.PCDATA_StackMapIndex
|
||||
pcdata.To.Type = obj.TYPE_CONST
|
||||
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
|
||||
pcdata := c.ctxt.EmitEntryLiveness(c.cursym, spfix, c.newprog)
|
||||
|
||||
// MOVW LR, R3
|
||||
movw := obj.Appendp(pcdata, c.newprog)
|
||||
|
@ -167,13 +167,7 @@ func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||
spfix.As = obj.ANOP
|
||||
spfix.Spadj = -framesize
|
||||
|
||||
pcdata := obj.Appendp(spfix, c.newprog)
|
||||
pcdata.Pos = c.cursym.Func.Text.Pos
|
||||
pcdata.As = obj.APCDATA
|
||||
pcdata.From.Type = obj.TYPE_CONST
|
||||
pcdata.From.Offset = objabi.PCDATA_StackMapIndex
|
||||
pcdata.To.Type = obj.TYPE_CONST
|
||||
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
|
||||
pcdata := c.ctxt.EmitEntryLiveness(c.cursym, spfix, c.newprog)
|
||||
|
||||
// MOV LR, R3
|
||||
movlr := obj.Appendp(pcdata, c.newprog)
|
||||
|
@ -790,6 +790,8 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||
p.Mark |= LABEL
|
||||
}
|
||||
|
||||
p = c.ctxt.EmitEntryLiveness(c.cursym, p, c.newprog)
|
||||
|
||||
// JAL runtime.morestack(SB)
|
||||
p = obj.Appendp(p, c.newprog)
|
||||
|
||||
|
@ -190,3 +190,18 @@ func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
|
||||
s.Type = objabi.STLSBSS
|
||||
}
|
||||
}
|
||||
|
||||
// EmitEntryLiveness generates PCDATA Progs after p to switch to the
|
||||
// liveness map active at the entry of function s. It returns the last
|
||||
// Prog generated.
|
||||
func (ctxt *Link) EmitEntryLiveness(s *LSym, p *Prog, newprog ProgAlloc) *Prog {
|
||||
pcdata := Appendp(p, newprog)
|
||||
pcdata.Pos = s.Func.Text.Pos
|
||||
pcdata.As = APCDATA
|
||||
pcdata.From.Type = TYPE_CONST
|
||||
pcdata.From.Offset = objabi.PCDATA_StackMapIndex
|
||||
pcdata.To.Type = TYPE_CONST
|
||||
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
|
||||
|
||||
return pcdata
|
||||
}
|
||||
|
@ -966,6 +966,8 @@ func (c *ctxt9) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||
q.Pcond = p
|
||||
}
|
||||
|
||||
p = c.ctxt.EmitEntryLiveness(c.cursym, p, c.newprog)
|
||||
|
||||
var morestacksym *obj.LSym
|
||||
if c.cursym.CFunc() {
|
||||
morestacksym = c.ctxt.Lookup("runtime.morestackc")
|
||||
|
@ -679,13 +679,7 @@ func (c *ctxtz) stacksplitPost(p *obj.Prog, pPre *obj.Prog, pPreempt *obj.Prog,
|
||||
spfix.As = obj.ANOP
|
||||
spfix.Spadj = -framesize
|
||||
|
||||
pcdata := obj.Appendp(spfix, c.newprog)
|
||||
pcdata.Pos = c.cursym.Func.Text.Pos
|
||||
pcdata.As = obj.APCDATA
|
||||
pcdata.From.Type = obj.TYPE_CONST
|
||||
pcdata.From.Offset = objabi.PCDATA_StackMapIndex
|
||||
pcdata.To.Type = obj.TYPE_CONST
|
||||
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
|
||||
pcdata := c.ctxt.EmitEntryLiveness(c.cursym, spfix, c.newprog)
|
||||
|
||||
// MOVD LR, R5
|
||||
p = obj.Appendp(pcdata, c.newprog)
|
||||
|
@ -1150,13 +1150,7 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
|
||||
spfix.As = obj.ANOP
|
||||
spfix.Spadj = -framesize
|
||||
|
||||
pcdata := obj.Appendp(spfix, newprog)
|
||||
pcdata.Pos = cursym.Func.Text.Pos
|
||||
pcdata.As = obj.APCDATA
|
||||
pcdata.From.Type = obj.TYPE_CONST
|
||||
pcdata.From.Offset = objabi.PCDATA_StackMapIndex
|
||||
pcdata.To.Type = obj.TYPE_CONST
|
||||
pcdata.To.Offset = -1 // pcdata starts at -1 at function entry
|
||||
pcdata := ctxt.EmitEntryLiveness(cursym, spfix, newprog)
|
||||
|
||||
call := obj.Appendp(pcdata, newprog)
|
||||
call.Pos = cursym.Func.Text.Pos
|
||||
|
Loading…
Reference in New Issue
Block a user