mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove gdata layer in slicesym
The previous change moved code around to create slicesym. This change simplifies slicesym and its callsites by accepting an int64 for lencap instead of a node, and by removing all the calls to gdata. It also stops modifying n, which avoids the need to make a copy of it. Passes toolstash-check. Change-Id: I4d25454d11b4bb8941000244443e3c99eef4bdd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/227550 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
7096b1700d
commit
0a18cbc2e6
2 changed files with 12 additions and 17 deletions
|
|
@ -418,13 +418,16 @@ func dsymptrWeakOff(s *obj.LSym, off int, x *obj.LSym) int {
|
|||
}
|
||||
|
||||
// slicesym writes a static slice symbol {&arr, lencap, lencap} to n.
|
||||
func slicesym(n, arr, lencap *Node) {
|
||||
// arr must be an ONAME. slicesym does not modify n.
|
||||
func slicesym(n, arr *Node, lencap int64) {
|
||||
s := n.Sym.Linksym()
|
||||
base := n.Xoffset
|
||||
gdata(n, nod(OADDR, arr, nil), Widthptr)
|
||||
n.Xoffset = base + sliceLenOffset
|
||||
gdata(n, lencap, Widthptr)
|
||||
n.Xoffset = base + sliceCapOffset
|
||||
gdata(n, lencap, Widthptr)
|
||||
if arr.Op != ONAME {
|
||||
Fatalf("slicesym non-name arr %v", arr)
|
||||
}
|
||||
s.WriteAddr(Ctxt, base, Widthptr, arr.Sym.Linksym(), arr.Xoffset)
|
||||
s.WriteInt(Ctxt, base+sliceLenOffset, Widthptr, lencap)
|
||||
s.WriteInt(Ctxt, base+sliceCapOffset, Widthptr, lencap)
|
||||
}
|
||||
|
||||
func gdata(nam *Node, nr *Node, wid int) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue