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 {
switch size {
default:
fn = syslook("memequal", 1)
fn = syslook("memequal")
*needsize = 1
case 1, 2, 4, 8, 16:
buf := fmt.Sprintf("memequal%d", int(size)*8)
fn = syslook(buf, 1)
fn = syslook(buf)
*needsize = 0
}
substArgTypes(fn, type_, type_)
substArgTypes(&fn, type_, type_)
return fn
}
......
......@@ -801,7 +801,7 @@ func cgen_wbptr(n, res *Node) {
Cgenr(n, &src, nil)
}
wbVar := syslook("writeBarrier", 0)
wbVar := syslook("writeBarrier")
wbEnabled := Nod(ODOT, wbVar, newname(wbVar.Type.Type.Sym))
wbEnabled = typecheck(&wbEnabled, Erv)
pbr := Thearch.Ginscmp(ONE, Types[TUINT8], wbEnabled, Nodintconst(0), -1)
......@@ -2874,8 +2874,8 @@ func cgen_append(n, res *Node) {
arg.Xoffset += int64(Widthptr)
Regfree(&rlen)
fn := syslook("growslice", 1)
substArgTypes(fn, res.Type.Type, res.Type.Type)
fn := syslook("growslice")
substArgTypes(&fn, res.Type.Type, res.Type.Type)
Ginscall(fn, 0)
if Widthptr == 4 && Widthreg == 8 {
......
......@@ -434,7 +434,7 @@ func cgen_dottype(n *Node, res, resok *Node, wb bool) {
q := Gbranch(obj.AJMP, nil, 0)
Patch(p, Pc)
Regrealloc(&r2) // reclaim from above, for this failure path
fn := syslook("panicdottype", 0)
fn := syslook("panicdottype")
dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil)
r1.Type = byteptr
......@@ -522,7 +522,7 @@ func Cgen_As2dottype(n, res, resok *Node) {
q := Gbranch(obj.AJMP, nil, 0)
Patch(p, Pc)
fn := syslook("panicdottype", 0)
fn := syslook("panicdottype")
dowidth(fn.Type)
call := Nod(OCALLFUNC, fn, nil)
setNodeSeq(&call.List, list(list(list1(&r1), &r2), typename(n.Left.Type)))
......
......@@ -132,7 +132,7 @@ func fninit(n *NodeList) {
b.Likely = 1
r = append(r, b)
// (4a)
b.Nbody.Set([]*Node{Nod(OCALL, syslook("throwinit", 0), nil)})
b.Nbody.Set([]*Node{Nod(OCALL, syslook("throwinit"), nil)})
// (6)
a = Nod(OAS, gatevar, Nodintconst(1))
......
......@@ -230,14 +230,14 @@ func walkrange(n *Node) {
keyname := newname(th.Type.Sym) // depends on layout of iterator struct. See reflect.go:hiter
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)))
n.Left = Nod(ONE, Nod(ODOT, hit, keyname), nodnil())
fn = syslook("mapiternext", 1)
substArgTypes(fn, th)
fn = syslook("mapiternext")
substArgTypes(&fn, th)
n.Right = mkcall1(fn, nil, nil, Nod(OADDR, hit, nil))
key := Nod(ODOT, hit, keyname)
......@@ -297,7 +297,7 @@ func walkrange(n *Node) {
hv2 = temp(runetype)
a = Nod(OAS2, nil, nil)
a.List = list(list1(hv1), hv2)
fn := syslook("stringiter2", 0)
fn := syslook("stringiter2")
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) {
bElse := 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)
// 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.
......@@ -2823,7 +2823,7 @@ func (s *state) insertWBstore(t *Type, left, right *ssa.Value, line int32) {
bElse := 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)
// 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.
......
......@@ -1112,10 +1112,15 @@ func assignconvfn(n *Node, t *Type, context func() string) *Node {
// substArgTypes substitutes the given list of types for
// successive occurrences of the "any" placeholder in the
// 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 {
dowidth(t)
}
n.Type = deep(n.Type)
substAny(&n.Type, &types)
if len(types) > 0 {
Fatalf("substArgTypes: too many argument types")
......@@ -1259,21 +1264,12 @@ func deep(t *Type) *Type {
return nt
}
func syslook(name string, copy int) *Node {
func syslook(name string) *Node {
s := Pkglookup(name, Runtimepkg)
if s == nil || s.Def == nil {
Fatalf("syslook: can't find runtime.%s", name)
}
if copy == 0 {
return s.Def
}
n := Nod(0, nil, nil)
*n = *s.Def
n.Type = deep(s.Def.Type)
return n
return s.Def
}
// compute a hash value for type t.
......@@ -2149,7 +2145,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
l = list(l, nodlit(v))
v.U = method.Sym.Name
l = list(l, nodlit(v)) // method name
call := Nod(OCALL, syslook("panicwrap", 0), nil)
call := Nod(OCALL, syslook("panicwrap"), nil)
call.List = l
n.Nbody.Set([]*Node{call})
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