Commit c78d072c authored by Keith Randall's avatar Keith Randall

Revert "Revert "cmd/compile: inline convI2E""

This reverts commit 7dd9c385.

Reason for revert: Reverting the revert, which will re-enable the convI2E optimization.  We originally reverted the convI2E optimization because it was making the builder fail, but the underlying cause was later determined to be unrelated.

Original CL: https://go-review.googlesource.com/31260
Revert CL: https://go-review.googlesource.com/31310
Real bug: https://go-review.googlesource.com/c/25159
Real fix: https://go-review.googlesource.com/c/31316

Change-Id: I17237bb577a23a7675a5caab970ccda71a4124f2
Reviewed-on: https://go-review.googlesource.com/32023
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent c60d9a33
This diff is collapsed.
......@@ -58,7 +58,6 @@ func slicecopy(to any, fr any, wid uintptr) int
func slicestringcopy(to any, fr any) int
// interface conversions
func convI2E(elem any) (ret any)
func convI2I(typ *byte, elem any) (ret any)
func convT2E(typ *byte, elem *any) (ret any)
func convT2I(tab *byte, elem *any) (ret any)
......
......@@ -410,16 +410,14 @@ func walkexprlistcheap(s []*Node, init *Nodes) {
}
}
// Build name of function: convI2E etc.
// Build name of function for interface conversion.
// Not all names are possible
// (e.g., we'll never generate convE2E or convE2I).
// (e.g., we'll never generate convE2E or convE2I or convI2E).
func convFuncName(from, to *Type) string {
tkind := to.iet()
switch from.iet() {
case 'I':
switch tkind {
case 'E':
return "convI2E"
case 'I':
return "convI2I"
}
......@@ -1080,6 +1078,34 @@ opswitch:
break
}
// Implement interface to empty interface conversion.
// tmp = i.itab
// if tmp != nil {
// tmp = tmp.type
// }
// e = iface{tmp, i.data}
if n.Type.IsEmptyInterface() && n.Left.Type.IsInterface() && !n.Left.Type.IsEmptyInterface() {
// Evaluate the input interface.
c := temp(n.Left.Type)
init.Append(nod(OAS, c, n.Left))
// Get the itab out of the interface.
tmp := temp(ptrto(Types[TUINT8]))
init.Append(nod(OAS, tmp, typecheck(nod(OITAB, c, nil), Erv)))
// Get the type out of the itab.
nif := nod(OIF, typecheck(nod(ONE, tmp, nodnil()), Erv), nil)
nif.Nbody.Set1(nod(OAS, tmp, itabType(tmp)))
init.Append(nif)
// Build the result.
e := nod(OEFACE, tmp, ifaceData(c, ptrto(Types[TUINT8])))
e.Type = n.Type // assign type manually, typecheck doesn't understand OEFACE.
e.Typecheck = 1
n = e
break
}
var ll []*Node
if n.Type.IsEmptyInterface() {
if !n.Left.Type.IsInterface() {
......
......@@ -264,16 +264,6 @@ func assertE2T2(t *_type, e eface, r unsafe.Pointer) bool {
return true
}
func convI2E(i iface) (r eface) {
tab := i.tab
if tab == nil {
return
}
r._type = tab._type
r.data = i.data
return
}
func assertI2E(inter *interfacetype, i iface, r *eface) {
tab := i.tab
if tab == nil {
......
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