Commit dafbcf6d authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: remove syslook's copy parameter

Instead make substArgTypes responsible for cloning the function
definition Node and the function signature Type tree.

Passes toolstash -cmp.

Change-Id: I9ec84c90a7ae83d164d3f578e84a91cf1490d8ab
Reviewed-on: https://go-review.googlesource.com/20239
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 8b51ee83
...@@ -570,16 +570,16 @@ func eqmemfunc(size int64, type_ *Type, needsize *int) *Node { ...@@ -570,16 +570,16 @@ func eqmemfunc(size int64, type_ *Type, needsize *int) *Node {
switch size { switch size {
default: default:
fn = syslook("memequal", 1) fn = syslook("memequal")
*needsize = 1 *needsize = 1
case 1, 2, 4, 8, 16: case 1, 2, 4, 8, 16:
buf := fmt.Sprintf("memequal%d", int(size)*8) buf := fmt.Sprintf("memequal%d", int(size)*8)
fn = syslook(buf, 1) fn = syslook(buf)
*needsize = 0 *needsize = 0
} }
substArgTypes(fn, type_, type_) substArgTypes(&fn, type_, type_)
return fn return fn
} }
......
...@@ -801,7 +801,7 @@ func cgen_wbptr(n, res *Node) { ...@@ -801,7 +801,7 @@ func cgen_wbptr(n, res *Node) {
Cgenr(n, &src, nil) Cgenr(n, &src, nil)
} }
wbVar := syslook("writeBarrier", 0) wbVar := syslook("writeBarrier")
wbEnabled := Nod(ODOT, wbVar, newname(wbVar.Type.Type.Sym)) wbEnabled := Nod(ODOT, wbVar, newname(wbVar.Type.Type.Sym))
wbEnabled = typecheck(&wbEnabled, Erv) wbEnabled = typecheck(&wbEnabled, Erv)
pbr := Thearch.Ginscmp(ONE, Types[TUINT8], wbEnabled, Nodintconst(0), -1) pbr := Thearch.Ginscmp(ONE, Types[TUINT8], wbEnabled, Nodintconst(0), -1)
...@@ -2874,8 +2874,8 @@ func cgen_append(n, res *Node) { ...@@ -2874,8 +2874,8 @@ func cgen_append(n, res *Node) {
arg.Xoffset += int64(Widthptr) arg.Xoffset += int64(Widthptr)
Regfree(&rlen) Regfree(&rlen)
fn := syslook("growslice", 1) fn := syslook("growslice")
substArgTypes(fn, res.Type.Type, res.Type.Type) substArgTypes(&fn, res.Type.Type, res.Type.Type)
Ginscall(fn, 0) Ginscall(fn, 0)
if Widthptr == 4 && Widthreg == 8 { if Widthptr == 4 && Widthreg == 8 {
......
...@@ -434,7 +434,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) { ...@@ -434,7 +434,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) {
q := Gbranch(obj.AJMP, nil, 0) q := Gbranch(obj.AJMP, nil, 0)
Patch(p, Pc) Patch(p, Pc)
Regrealloc(&r2) // reclaim from above, for this failure path Regrealloc(&r2) // reclaim from above, for this failure path
fn := syslook("panicdottype", 0) fn := syslook("panicdottype")
dowidth(fn.Type) dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil) call := Nod(OCALLFUNC, fn, nil)
r1.Type = byteptr r1.Type = byteptr
...@@ -522,7 +522,7 @@ func Cgen_As2dottype(n, res, resok *Node) { ...@@ -522,7 +522,7 @@ func Cgen_As2dottype(n, res, resok *Node) {
q := Gbranch(obj.AJMP, nil, 0) q := Gbranch(obj.AJMP, nil, 0)
Patch(p, Pc) Patch(p, Pc)
fn := syslook("panicdottype", 0) fn := syslook("panicdottype")
dowidth(fn.Type) dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil) call := Nod(OCALLFUNC, fn, nil)
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type))) setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
......
...@@ -132,7 +132,7 @@ func fninit(n *NodeList) { ...@@ -132,7 +132,7 @@ func fninit(n *NodeList) {
b.Likely = 1 b.Likely = 1
r = append(r, b) r = append(r, b)
// (4a) // (4a)
b.Nbody.Set([]*Node{Nod(OCALL, syslook("throwinit", 0), nil)}) b.Nbody.Set([]*Node{Nod(OCALL, syslook("throwinit"), nil)})
// (6) // (6)
a = Nod(OAS, gatevar, Nodintconst(1)) a = Nod(OAS, gatevar, Nodintconst(1))
......
...@@ -230,14 +230,14 @@ func walkrange(n *Node) { ...@@ -230,14 +230,14 @@ func walkrange(n *Node) {
keyname := newname(th.Type.Sym) // depends on layout of iterator struct. See reflect.go:hiter keyname := newname(th.Type.Sym) // depends on layout of iterator struct. See reflect.go:hiter
valname := newname(th.Type.Down.Sym) // ditto valname := newname(th.Type.Down.Sym) // ditto
fn := syslook("mapiterinit", 1) fn := syslook("mapiterinit")
substArgTypes(fn, t.Down, t.Type, th) substArgTypes(&fn, t.Down, t.Type, th)
init = list(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil))) init = list(init, mkcall1(fn, nil, nil, typename(t), ha, Nod(OADDR, hit, nil)))
n.Left = Nod(ONE, Nod(ODOT, hit, keyname), nodnil()) n.Left = Nod(ONE, Nod(ODOT, hit, keyname), nodnil())
fn = syslook("mapiternext", 1) fn = syslook("mapiternext")
substArgTypes(fn, th) substArgTypes(&fn, th)
n.Right = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil)) n.Right = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil))
key := Nod(ODOT, hit, keyname) key := Nod(ODOT, hit, keyname)
...@@ -297,7 +297,7 @@ func walkrange(n *Node) { ...@@ -297,7 +297,7 @@ func walkrange(n *Node) {
hv2 = temp(runetype) hv2 = temp(runetype)
a = Nod(OAS2, nil, nil) a = Nod(OAS2, nil, nil)
a.List = list(list1(hv1), hv2) a.List = list(list1(hv1), hv2)
fn := syslook("stringiter2", 0) fn := syslook("stringiter2")
a.Rlist = list1(mkcall1(fn, getoutargx(fn.Type), nil, ha, hv1)) a.Rlist = list1(mkcall1(fn, getoutargx(fn.Type), nil, ha, hv1))
} }
......
...@@ -2778,7 +2778,7 @@ func (s *state) insertWBmove(t *Type, left, right *ssa.Value, line int32) { ...@@ -2778,7 +2778,7 @@ func (s *state) insertWBmove(t *Type, left, right *ssa.Value, line int32) {
bElse := s.f.NewBlock(ssa.BlockPlain) bElse := s.f.NewBlock(ssa.BlockPlain)
bEnd := s.f.NewBlock(ssa.BlockPlain) bEnd := s.f.NewBlock(ssa.BlockPlain)
aux := &ssa.ExternSymbol{Types[TBOOL], syslook("writeBarrier", 0).Sym} aux := &ssa.ExternSymbol{Types[TBOOL], syslook("writeBarrier").Sym}
flagaddr := s.newValue1A(ssa.OpAddr, Ptrto(Types[TUINT32]), aux, s.sb) flagaddr := s.newValue1A(ssa.OpAddr, Ptrto(Types[TUINT32]), aux, s.sb)
// TODO: select the .enabled field. It is currently first, so not needed for now. // TODO: select the .enabled field. It is currently first, so not needed for now.
// Load word, test byte, avoiding partial register write from load byte. // Load word, test byte, avoiding partial register write from load byte.
...@@ -2823,7 +2823,7 @@ func (s *state) insertWBstore(t *Type, left, right *ssa.Value, line int32) { ...@@ -2823,7 +2823,7 @@ func (s *state) insertWBstore(t *Type, left, right *ssa.Value, line int32) {
bElse := s.f.NewBlock(ssa.BlockPlain) bElse := s.f.NewBlock(ssa.BlockPlain)
bEnd := s.f.NewBlock(ssa.BlockPlain) bEnd := s.f.NewBlock(ssa.BlockPlain)
aux := &ssa.ExternSymbol{Types[TBOOL], syslook("writeBarrier", 0).Sym} aux := &ssa.ExternSymbol{Types[TBOOL], syslook("writeBarrier").Sym}
flagaddr := s.newValue1A(ssa.OpAddr, Ptrto(Types[TUINT32]), aux, s.sb) flagaddr := s.newValue1A(ssa.OpAddr, Ptrto(Types[TUINT32]), aux, s.sb)
// TODO: select the .enabled field. It is currently first, so not needed for now. // TODO: select the .enabled field. It is currently first, so not needed for now.
// Load word, test byte, avoiding partial register write from load byte. // Load word, test byte, avoiding partial register write from load byte.
......
...@@ -1112,10 +1112,15 @@ func assignconvfn(n *Node, t *Type, context func() string) *Node { ...@@ -1112,10 +1112,15 @@ func assignconvfn(n *Node, t *Type, context func() string) *Node {
// substArgTypes substitutes the given list of types for // substArgTypes substitutes the given list of types for
// successive occurrences of the "any" placeholder in the // successive occurrences of the "any" placeholder in the
// type syntax expression n.Type. // type syntax expression n.Type.
func substArgTypes(n *Node, types ...*Type) { func substArgTypes(np **Node, types ...*Type) {
n := Nod(0, nil, nil)
*n = **np
*np = n
for _, t := range types { for _, t := range types {
dowidth(t) dowidth(t)
} }
n.Type = deep(n.Type)
substAny(&n.Type, &types) substAny(&n.Type, &types)
if len(types) > 0 { if len(types) > 0 {
Fatalf("substArgTypes: too many argument types") Fatalf("substArgTypes: too many argument types")
...@@ -1259,21 +1264,12 @@ func deep(t *Type) *Type { ...@@ -1259,21 +1264,12 @@ func deep(t *Type) *Type {
return nt return nt
} }
func syslook(name string, copy int) *Node { func syslook(name string) *Node {
s := Pkglookup(name, Runtimepkg) s := Pkglookup(name, Runtimepkg)
if s == nil || s.Def == nil { if s == nil || s.Def == nil {
Fatalf("syslook: can't find runtime.%s", name) Fatalf("syslook: can't find runtime.%s", name)
} }
if copy == 0 {
return s.Def return s.Def
}
n := Nod(0, nil, nil)
*n = *s.Def
n.Type = deep(s.Def.Type)
return n
} }
// compute a hash value for type t. // compute a hash value for type t.
...@@ -2149,7 +2145,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2149,7 +2145,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
l = list(l, nodlit(v)) l = list(l, nodlit(v))
v.U = method.Sym.Name v.U = method.Sym.Name
l = list(l, nodlit(v)) // method name l = list(l, nodlit(v)) // method name
call := Nod(OCALL, syslook("panicwrap", 0), nil) call := Nod(OCALL, syslook("panicwrap"), nil)
call.List = l call.List = l
n.Nbody.Set([]*Node{call}) n.Nbody.Set([]*Node{call})
fn.Nbody.Append(n) fn.Nbody.Append(n)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment