Commit 6703adde authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: drop legacy code for generating iface wrappers

Originally, scalar values were directly stored within interface values
as long as they fit into a pointer-sized slot of memory. And since
interface method calls always pass the full pointer-sized value as the
receiver argument, value-narrowing wrappers were necessary to adapt to
the calling convention for methods with smaller receiver types.

However, for precise garbage collection, we now only store actual
pointers within interface values, so these wrappers are no longer
necessary.

Passes toolstash-check.

Change-Id: I5303bfeb8d0f11db619b5a5d06b37ac898588670
Reviewed-on: https://go-review.googlesource.com/104875
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent e8aa9a53
......@@ -829,7 +829,7 @@ func functypefield0(t *types.Type, this *types.Field, in, out []*types.Field) {
var methodsym_toppkg *types.Pkg
func methodsym(nsym *types.Sym, t0 *types.Type, iface bool) *types.Sym {
func methodsym(nsym *types.Sym, t0 *types.Type) *types.Sym {
if t0 == nil {
Fatalf("methodsym: nil receiver type")
}
......@@ -850,14 +850,6 @@ func methodsym(nsym *types.Sym, t0 *types.Type, iface bool) *types.Sym {
t0 = types.NewPtr(t)
}
suffix := ""
if iface {
dowidth(t0)
if t0.Width < int64(Widthptr) {
suffix = "·i"
}
}
var spkg *types.Pkg
if s != nil {
spkg = s.Pkg
......@@ -868,9 +860,9 @@ func methodsym(nsym *types.Sym, t0 *types.Type, iface bool) *types.Sym {
}
var p string
if t0.Sym == nil && t0.IsPtr() {
p = fmt.Sprintf("(%-S)%s.%s%s", t0, pkgprefix, nsym.Name, suffix)
p = fmt.Sprintf("(%-S)%s.%s", t0, pkgprefix, nsym.Name)
} else {
p = fmt.Sprintf("%-S%s.%s%s", t0, pkgprefix, nsym.Name, suffix)
p = fmt.Sprintf("%-S%s.%s", t0, pkgprefix, nsym.Name)
}
if spkg == nil {
......
......@@ -427,16 +427,16 @@ func methods(t *types.Type) []*Sig {
sig.pkg = method.Pkg
}
sig.isym = methodsym(method, it, true)
sig.tsym = methodsym(method, t, false)
sig.isym = methodsym(method, it)
sig.tsym = methodsym(method, t)
sig.type_ = methodfunc(f.Type, t)
sig.mtype = methodfunc(f.Type, nil)
if !sig.isym.Siggen() {
sig.isym.SetSiggen(true)
if !eqtype(this, it) || this.Width < int64(Widthptr) {
if !eqtype(this, it) {
compiling_wrappers = true
genwrapper(it, f, sig.isym, true)
genwrapper(it, f, sig.isym)
compiling_wrappers = false
}
}
......@@ -445,7 +445,7 @@ func methods(t *types.Type) []*Sig {
sig.tsym.SetSiggen(true)
if !eqtype(this, t) {
compiling_wrappers = true
genwrapper(t, f, sig.tsym, false)
genwrapper(t, f, sig.tsym)
compiling_wrappers = false
}
}
......@@ -493,10 +493,10 @@ func imethods(t *types.Type) []*Sig {
// IfaceType.Method is not in the reflect data.
// Generate the method body, so that compiled
// code can refer to it.
isym := methodsym(method, t, false)
isym := methodsym(method, t)
if !isym.Siggen() {
isym.SetSiggen(true)
genwrapper(t, f, isym, false)
genwrapper(t, f, isym)
}
}
......
......@@ -1654,7 +1654,7 @@ func structargs(tl *types.Type, mustname bool) []*Node {
// rcvr - U
// method - M func (t T)(), a TFIELD type struct
// newnam - the eventual mangled name of this function
func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface bool) {
func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) {
if false && Debug['r'] != 0 {
fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam)
}
......@@ -1676,19 +1676,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface
out := structargs(method.Type.Results(), false)
t := nod(OTFUNC, nil, nil)
l := []*Node{this}
if iface && rcvr.Width < int64(Widthptr) {
// Building method for interface table and receiver
// is smaller than the single pointer-sized word
// that the interface call will pass in.
// Add a dummy padding argument after the
// receiver to make up the difference.
tpad := types.NewArray(types.Types[TUINT8], int64(Widthptr)-rcvr.Width)
pad := namedfield(".pad", tpad)
l = append(l, pad)
}
t.List.Set(append(l, in...))
t.List.Set(append([]*Node{this}, in...))
t.Rlist.Set(out)
newnam.SetOnExportList(true) // prevent export; see closure.go
......@@ -1735,7 +1723,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface
as := nod(OAS, this.Left, nod(OCONVNOP, dot, nil))
as.Right.Type = rcvr
fn.Nbody.Append(as)
fn.Nbody.Append(nodSym(ORETJMP, nil, methodsym(method.Sym, methodrcvr, false)))
fn.Nbody.Append(nodSym(ORETJMP, nil, methodsym(method.Sym, methodrcvr)))
} else {
fn.Func.SetWrapper(true) // ignore frame for panic+recover matching
call := nod(OCALL, dot, nil)
......
......@@ -2352,7 +2352,7 @@ func looktypedot(n *Node, t *types.Type, dostrcmp int) bool {
return false
}
n.Sym = methodsym(n.Sym, t, false)
n.Sym = methodsym(n.Sym, t)
n.Xoffset = f1.Offset
n.Type = f1.Type
n.Op = ODOTINTER
......@@ -2378,7 +2378,7 @@ func looktypedot(n *Node, t *types.Type, dostrcmp int) bool {
return false
}
n.Sym = methodsym(n.Sym, t, false)
n.Sym = methodsym(n.Sym, t)
n.Xoffset = f2.Offset
n.Type = f2.Type
n.Op = ODOTMETH
......@@ -2495,7 +2495,7 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field {
return nil
}
n.Sym = methodsym(n.Sym, n.Left.Type, false)
n.Sym = methodsym(n.Sym, n.Left.Type)
n.Xoffset = f2.Offset
n.Type = f2.Type
......
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