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)
......
...@@ -746,8 +746,8 @@ opswitch: ...@@ -746,8 +746,8 @@ opswitch:
Warn("type assertion not inlined") Warn("type assertion not inlined")
} }
fn := syslook(assertFuncName(r.Left.Type, r.Type, false), 1) fn := syslook(assertFuncName(r.Left.Type, r.Type, false))
substArgTypes(fn, r.Left.Type, r.Type) substArgTypes(&fn, r.Left.Type, r.Type)
n = mkcall1(fn, nil, init, typename(r.Type), r.Left, n1) n = mkcall1(fn, nil, init, typename(r.Type), r.Left, n1)
walkexpr(&n, init) walkexpr(&n, init)
...@@ -988,8 +988,8 @@ opswitch: ...@@ -988,8 +988,8 @@ opswitch:
if Debug_typeassert > 0 { if Debug_typeassert > 0 {
Warn("type assertion not inlined") Warn("type assertion not inlined")
} }
fn := syslook(assertFuncName(from.Type, t, true), 1) fn := syslook(assertFuncName(from.Type, t, true))
substArgTypes(fn, from.Type, t) substArgTypes(&fn, from.Type, t)
call := mkcall1(fn, oktype, init, typename(t), from, resptr) call := mkcall1(fn, oktype, init, typename(t), from, resptr)
n = Nod(OAS, ok, call) n = Nod(OAS, ok, call)
typecheck(&n, Etop) typecheck(&n, Etop)
...@@ -1052,7 +1052,7 @@ opswitch: ...@@ -1052,7 +1052,7 @@ opswitch:
typecheck(&n1, Etop) typecheck(&n1, Etop)
appendNodeSeqNode(init, n1) appendNodeSeqNode(init, n1)
fn := syslook("typ2Itab", 0) fn := syslook("typ2Itab")
n1 = Nod(OCALL, fn, nil) n1 = Nod(OCALL, fn, nil)
setNodeSeq(&n1.List, ll) setNodeSeq(&n1.List, ll)
typecheck(&n1, Erv) typecheck(&n1, Erv)
...@@ -1101,11 +1101,11 @@ opswitch: ...@@ -1101,11 +1101,11 @@ opswitch:
ll = list(ll, r) ll = list(ll, r)
} }
fn := syslook(convFuncName(n.Left.Type, n.Type), 1) fn := syslook(convFuncName(n.Left.Type, n.Type))
if !Isinter(n.Left.Type) { if !Isinter(n.Left.Type) {
substArgTypes(fn, n.Left.Type, n.Left.Type, n.Type) substArgTypes(&fn, n.Left.Type, n.Left.Type, n.Type)
} else { } else {
substArgTypes(fn, n.Left.Type, n.Type) substArgTypes(&fn, n.Left.Type, n.Type)
} }
dowidth(fn.Type) dowidth(fn.Type)
n = Nod(OCALL, fn, nil) n = Nod(OCALL, fn, nil)
...@@ -1417,9 +1417,9 @@ opswitch: ...@@ -1417,9 +1417,9 @@ opswitch:
// cannot use chanfn - closechan takes any, not chan any // cannot use chanfn - closechan takes any, not chan any
case OCLOSE: case OCLOSE:
fn := syslook("closechan", 1) fn := syslook("closechan")
substArgTypes(fn, n.Left.Type) substArgTypes(&fn, n.Left.Type)
n = mkcall1(fn, nil, init, n.Left) n = mkcall1(fn, nil, init, n.Left)
case OMAKECHAN: case OMAKECHAN:
...@@ -1450,8 +1450,8 @@ opswitch: ...@@ -1450,8 +1450,8 @@ opswitch:
r = Nod(OADDR, var_, nil) r = Nod(OADDR, var_, nil)
} }
fn := syslook("makemap", 1) fn := syslook("makemap")
substArgTypes(fn, hmap(t), mapbucket(t), t.Down, t.Type) substArgTypes(&fn, hmap(t), mapbucket(t), t.Down, t.Type)
n = mkcall1(fn, n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64]), a, r) n = mkcall1(fn, n.Type, init, typename(n.Type), conv(n.Left, Types[TINT64]), a, r)
case OMAKESLICE: case OMAKESLICE:
...@@ -1480,9 +1480,9 @@ opswitch: ...@@ -1480,9 +1480,9 @@ opswitch:
n = r n = r
} else { } else {
// makeslice(t *Type, nel int64, max int64) (ary []any) // makeslice(t *Type, nel int64, max int64) (ary []any)
fn := syslook("makeslice", 1) fn := syslook("makeslice")
substArgTypes(fn, t.Type) // any-1 substArgTypes(&fn, t.Type) // any-1
n = mkcall1(fn, n.Type, init, typename(n.Type), conv(l, Types[TINT64]), conv(r, Types[TINT64])) n = mkcall1(fn, n.Type, init, typename(n.Type), conv(l, Types[TINT64]), conv(r, Types[TINT64]))
} }
...@@ -1563,14 +1563,14 @@ opswitch: ...@@ -1563,14 +1563,14 @@ opswitch:
} }
var fn *Node var fn *Node
if isnilinter(n.Left.Type) { if isnilinter(n.Left.Type) {
fn = syslook("efaceeq", 1) fn = syslook("efaceeq")
} else { } else {
fn = syslook("ifaceeq", 1) fn = syslook("ifaceeq")
} }
n.Right = cheapexpr(n.Right, init) n.Right = cheapexpr(n.Right, init)
n.Left = cheapexpr(n.Left, init) n.Left = cheapexpr(n.Left, init)
substArgTypes(fn, n.Right.Type, n.Left.Type) substArgTypes(&fn, n.Right.Type, n.Left.Type)
r := mkcall1(fn, n.Type, init, n.Left, n.Right) r := mkcall1(fn, n.Type, init, n.Left, n.Right)
// TODO(marvin): Fix Node.EType type union. // TODO(marvin): Fix Node.EType type union.
if Op(n.Etype) == ONE { if Op(n.Etype) == ONE {
...@@ -2010,35 +2010,35 @@ func walkprint(nn *Node, init nodesOrNodeListPtr) *Node { ...@@ -2010,35 +2010,35 @@ func walkprint(nn *Node, init nodesOrNodeListPtr) *Node {
et = n.Type.Etype et = n.Type.Etype
if Isinter(n.Type) { if Isinter(n.Type) {
if isnilinter(n.Type) { if isnilinter(n.Type) {
on = syslook("printeface", 1) on = syslook("printeface")
} else { } else {
on = syslook("printiface", 1) on = syslook("printiface")
} }
substArgTypes(on, n.Type) // any-1 substArgTypes(&on, n.Type) // any-1
} else if Isptr[et] || et == TCHAN || et == TMAP || et == TFUNC || et == TUNSAFEPTR { } else if Isptr[et] || et == TCHAN || et == TMAP || et == TFUNC || et == TUNSAFEPTR {
on = syslook("printpointer", 1) on = syslook("printpointer")
substArgTypes(on, n.Type) // any-1 substArgTypes(&on, n.Type) // any-1
} else if Isslice(n.Type) { } else if Isslice(n.Type) {
on = syslook("printslice", 1) on = syslook("printslice")
substArgTypes(on, n.Type) // any-1 substArgTypes(&on, n.Type) // any-1
} else if Isint[et] { } else if Isint[et] {
if et == TUINT64 { if et == TUINT64 {
if (t.Sym.Pkg == Runtimepkg || compiling_runtime != 0) && t.Sym.Name == "hex" { if (t.Sym.Pkg == Runtimepkg || compiling_runtime != 0) && t.Sym.Name == "hex" {
on = syslook("printhex", 0) on = syslook("printhex")
} else { } else {
on = syslook("printuint", 0) on = syslook("printuint")
} }
} else { } else {
on = syslook("printint", 0) on = syslook("printint")
} }
} else if Isfloat[et] { } else if Isfloat[et] {
on = syslook("printfloat", 0) on = syslook("printfloat")
} else if Iscomplex[et] { } else if Iscomplex[et] {
on = syslook("printcomplex", 0) on = syslook("printcomplex")
} else if et == TBOOL { } else if et == TBOOL {
on = syslook("printbool", 0) on = syslook("printbool")
} else if et == TSTRING { } else if et == TSTRING {
on = syslook("printstring", 0) on = syslook("printstring")
} else { } else {
badtype(OPRINT, n.Type, nil) badtype(OPRINT, n.Type, nil)
continue continue
...@@ -2080,8 +2080,8 @@ func walkprint(nn *Node, init nodesOrNodeListPtr) *Node { ...@@ -2080,8 +2080,8 @@ func walkprint(nn *Node, init nodesOrNodeListPtr) *Node {
func callnew(t *Type) *Node { func callnew(t *Type) *Node {
dowidth(t) dowidth(t)
fn := syslook("newobject", 1) fn := syslook("newobject")
substArgTypes(fn, t) substArgTypes(&fn, t)
return mkcall1(fn, Ptrto(t), nil, typename(t)) return mkcall1(fn, Ptrto(t), nil, typename(t))
} }
...@@ -2698,7 +2698,7 @@ func vmkcall(fn *Node, t *Type, init nodesOrNodeListPtr, va []*Node) *Node { ...@@ -2698,7 +2698,7 @@ func vmkcall(fn *Node, t *Type, init nodesOrNodeListPtr, va []*Node) *Node {
} }
func mkcall(name string, t *Type, init nodesOrNodeListPtr, args ...*Node) *Node { func mkcall(name string, t *Type, init nodesOrNodeListPtr, args ...*Node) *Node {
return vmkcall(syslook(name, 0), t, init, args) return vmkcall(syslook(name), t, init, args)
} }
func mkcall1(fn *Node, t *Type, init nodesOrNodeListPtr, args ...*Node) *Node { func mkcall1(fn *Node, t *Type, init nodesOrNodeListPtr, args ...*Node) *Node {
...@@ -2719,14 +2719,14 @@ func chanfn(name string, n int, t *Type) *Node { ...@@ -2719,14 +2719,14 @@ func chanfn(name string, n int, t *Type) *Node {
if t.Etype != TCHAN { if t.Etype != TCHAN {
Fatalf("chanfn %v", t) Fatalf("chanfn %v", t)
} }
fn := syslook(name, 1) fn := syslook(name)
switch n { switch n {
default: default:
Fatalf("chanfn %d", n) Fatalf("chanfn %d", n)
case 1: case 1:
substArgTypes(fn, t.Type) substArgTypes(&fn, t.Type)
case 2: case 2:
substArgTypes(fn, t.Type, t.Type) substArgTypes(&fn, t.Type, t.Type)
} }
return fn return fn
} }
...@@ -2735,8 +2735,8 @@ func mapfn(name string, t *Type) *Node { ...@@ -2735,8 +2735,8 @@ func mapfn(name string, t *Type) *Node {
if t.Etype != TMAP { if t.Etype != TMAP {
Fatalf("mapfn %v", t) Fatalf("mapfn %v", t)
} }
fn := syslook(name, 1) fn := syslook(name)
substArgTypes(fn, t.Down, t.Type, t.Down, t.Type) substArgTypes(&fn, t.Down, t.Type, t.Down, t.Type)
return fn return fn
} }
...@@ -2744,14 +2744,14 @@ func mapfndel(name string, t *Type) *Node { ...@@ -2744,14 +2744,14 @@ func mapfndel(name string, t *Type) *Node {
if t.Etype != TMAP { if t.Etype != TMAP {
Fatalf("mapfn %v", t) Fatalf("mapfn %v", t)
} }
fn := syslook(name, 1) fn := syslook(name)
substArgTypes(fn, t.Down, t.Type, t.Down) substArgTypes(&fn, t.Down, t.Type, t.Down)
return fn return fn
} }
func writebarrierfn(name string, l *Type, r *Type) *Node { func writebarrierfn(name string, l *Type, r *Type) *Node {
fn := syslook(name, 1) fn := syslook(name)
substArgTypes(fn, l, r) substArgTypes(&fn, l, r)
return fn return fn
} }
...@@ -2810,7 +2810,7 @@ func addstr(n *Node, init nodesOrNodeListPtr) *Node { ...@@ -2810,7 +2810,7 @@ func addstr(n *Node, init nodesOrNodeListPtr) *Node {
slice.Esc = EscNone slice.Esc = EscNone
} }
cat := syslook(fn, 0) cat := syslook(fn)
r := Nod(OCALL, cat, nil) r := Nod(OCALL, cat, nil)
setNodeSeq(&r.List, args) setNodeSeq(&r.List, args)
typecheck(&r, Erv) typecheck(&r, Erv)
...@@ -2859,8 +2859,8 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node { ...@@ -2859,8 +2859,8 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node {
nif.Left = Nod(OGT, nt, Nodintconst(0)) nif.Left = Nod(OGT, nt, Nodintconst(0))
// instantiate growslice_n(Type*, []any, int) []any // instantiate growslice_n(Type*, []any, int) []any
fn := syslook("growslice_n", 1) // growslice_n(<type>, old []T, n int64) (ret []T) fn := syslook("growslice_n") // growslice_n(<type>, old []T, n int64) (ret []T)
substArgTypes(fn, s.Type.Type, s.Type.Type) substArgTypes(&fn, s.Type.Type, s.Type.Type)
// s = growslice_n(T, s, n) // s = growslice_n(T, s, n)
nif.Nbody.Set([]*Node{Nod(OAS, s, mkcall1(fn, s.Type, &nif.Ninit, typename(s.Type), s, nt))}) nif.Nbody.Set([]*Node{Nod(OAS, s, mkcall1(fn, s.Type, &nif.Ninit, typename(s.Type), s, nt))})
...@@ -2873,8 +2873,8 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node { ...@@ -2873,8 +2873,8 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node {
nptr1.Etype = 1 nptr1.Etype = 1
nptr2 := l2 nptr2 := l2
fn := syslook("typedslicecopy", 1) fn := syslook("typedslicecopy")
substArgTypes(fn, l1.Type, l2.Type) substArgTypes(&fn, l1.Type, l2.Type)
nt := mkcall1(fn, Types[TINT], &l, typename(l1.Type.Type), nptr1, nptr2) nt := mkcall1(fn, Types[TINT], &l, typename(l1.Type.Type), nptr1, nptr2)
l = append(l, nt) l = append(l, nt)
} else if instrumenting { } else if instrumenting {
...@@ -2886,11 +2886,11 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node { ...@@ -2886,11 +2886,11 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node {
nptr2 := l2 nptr2 := l2
var fn *Node var fn *Node
if l2.Type.Etype == TSTRING { if l2.Type.Etype == TSTRING {
fn = syslook("slicestringcopy", 1) fn = syslook("slicestringcopy")
} else { } else {
fn = syslook("slicecopy", 1) fn = syslook("slicecopy")
} }
substArgTypes(fn, l1.Type, l2.Type) substArgTypes(&fn, l1.Type, l2.Type)
nt := mkcall1(fn, Types[TINT], &l, nptr1, nptr2, Nodintconst(s.Type.Type.Width)) nt := mkcall1(fn, Types[TINT], &l, nptr1, nptr2, Nodintconst(s.Type.Type.Width))
l = append(l, nt) l = append(l, nt)
} else { } else {
...@@ -2902,8 +2902,8 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node { ...@@ -2902,8 +2902,8 @@ func appendslice(n *Node, init nodesOrNodeListPtr) *Node {
nptr2 := Nod(OSPTR, l2, nil) nptr2 := Nod(OSPTR, l2, nil)
fn := syslook("memmove", 1) fn := syslook("memmove")
substArgTypes(fn, s.Type.Type, s.Type.Type) substArgTypes(&fn, s.Type.Type, s.Type.Type)
nwid := cheapexpr(conv(Nod(OLEN, l2, nil), Types[TUINTPTR]), &l) nwid := cheapexpr(conv(Nod(OLEN, l2, nil), Types[TUINTPTR]), &l)
...@@ -2994,8 +2994,8 @@ func walkappend(n *Node, init nodesOrNodeListPtr, dst *Node) *Node { ...@@ -2994,8 +2994,8 @@ func walkappend(n *Node, init nodesOrNodeListPtr, dst *Node) *Node {
nx := Nod(OIF, nil, nil) // if cap(s) - len(s) < argc nx := Nod(OIF, nil, nil) // if cap(s) - len(s) < argc
nx.Left = Nod(OLT, Nod(OSUB, Nod(OCAP, ns, nil), Nod(OLEN, ns, nil)), na) nx.Left = Nod(OLT, Nod(OSUB, Nod(OCAP, ns, nil), Nod(OLEN, ns, nil)), na)
fn := syslook("growslice", 1) // growslice(<type>, old []T, mincap int) (ret []T) fn := syslook("growslice") // growslice(<type>, old []T, mincap int) (ret []T)
substArgTypes(fn, ns.Type.Type, ns.Type.Type) substArgTypes(&fn, ns.Type.Type, ns.Type.Type)
nx.Nbody.Set([]*Node{Nod(OAS, ns, mkcall1(fn, ns.Type, &nx.Ninit, typename(ns.Type), ns, Nod(OADD, Nod(OLEN, ns, nil), na)))}) nx.Nbody.Set([]*Node{Nod(OAS, ns, mkcall1(fn, ns.Type, &nx.Ninit, typename(ns.Type), ns, Nod(OADD, Nod(OLEN, ns, nil), na)))})
...@@ -3045,11 +3045,11 @@ func copyany(n *Node, init nodesOrNodeListPtr, runtimecall bool) *Node { ...@@ -3045,11 +3045,11 @@ func copyany(n *Node, init nodesOrNodeListPtr, runtimecall bool) *Node {
if runtimecall { if runtimecall {
var fn *Node var fn *Node
if n.Right.Type.Etype == TSTRING { if n.Right.Type.Etype == TSTRING {
fn = syslook("slicestringcopy", 1) fn = syslook("slicestringcopy")
} else { } else {
fn = syslook("slicecopy", 1) fn = syslook("slicecopy")
} }
substArgTypes(fn, n.Left.Type, n.Right.Type) substArgTypes(&fn, n.Left.Type, n.Right.Type)
return mkcall1(fn, n.Type, init, n.Left, n.Right, Nodintconst(n.Left.Type.Type.Width)) return mkcall1(fn, n.Type, init, n.Left, n.Right, Nodintconst(n.Left.Type.Type.Width))
} }
...@@ -3077,9 +3077,9 @@ func copyany(n *Node, init nodesOrNodeListPtr, runtimecall bool) *Node { ...@@ -3077,9 +3077,9 @@ func copyany(n *Node, init nodesOrNodeListPtr, runtimecall bool) *Node {
l = list(l, nif) l = list(l, nif)
// Call memmove. // Call memmove.
fn := syslook("memmove", 1) fn := syslook("memmove")
substArgTypes(fn, nl.Type.Type, nl.Type.Type) substArgTypes(&fn, nl.Type.Type, nl.Type.Type)
nwid := temp(Types[TUINTPTR]) nwid := temp(Types[TUINTPTR])
l = list(l, Nod(OAS, nwid, conv(nlen, Types[TUINTPTR]))) l = list(l, Nod(OAS, nwid, conv(nlen, Types[TUINTPTR])))
nwid = Nod(OMUL, nwid, Nodintconst(nl.Type.Type.Width)) nwid = Nod(OMUL, nwid, Nodintconst(nl.Type.Type.Width))
...@@ -3103,8 +3103,8 @@ func eqfor(t *Type, needsize *int) *Node { ...@@ -3103,8 +3103,8 @@ func eqfor(t *Type, needsize *int) *Node {
} }
if a == AMEM { if a == AMEM {
n := syslook("memequal", 1) n := syslook("memequal")
substArgTypes(n, t, t) substArgTypes(&n, t, t)
*needsize = 1 *needsize = 1
return n return n
} }
......
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