Commit 7dd9c385 authored by Matthew Dempsky's avatar Matthew Dempsky

Revert "cmd/compile: inline convI2E"

This reverts commit 395d36a6.

Appears to be responsible for builder failures.

Change-Id: Ic6c6307f662767e529060b88704a9f074785d99e
Reviewed-on: https://go-review.googlesource.com/31310
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent 9ee21f90
This diff is collapsed.
......@@ -58,6 +58,7 @@ 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,14 +410,16 @@ func walkexprlistcheap(s []*Node, init *Nodes) {
}
}
// Build name of function for interface conversion.
// Build name of function: convI2E etc.
// Not all names are possible
// (e.g., we'll never generate convE2E or convE2I or convI2E).
// (e.g., we'll never generate convE2E or convE2I).
func convFuncName(from, to *Type) string {
tkind := to.iet()
switch from.iet() {
case 'I':
switch tkind {
case 'E':
return "convI2E"
case 'I':
return "convI2I"
}
......@@ -1078,34 +1080,6 @@ 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,6 +264,16 @@ 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