diff options
author | Keith Randall <khr@golang.org> | 2016-04-19 12:48:09 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2016-04-19 22:27:08 +0000 |
commit | 998c8e034c98fccb52b0692b97d36a5a6d3bd31a (patch) | |
tree | f4e22ce2f5abe0373451c75c7cf34f4ecb5adcee /src/runtime/iface.go | |
parent | 8b20fd000d7e894865442134f9d6d197ac5dabed (diff) | |
download | go-998c8e034c98fccb52b0692b97d36a5a6d3bd31a.tar.gz go-998c8e034c98fccb52b0692b97d36a5a6d3bd31a.zip |
cmd/compile: convT2{I,E} don't handle direct interfaces
We now inline type to interface conversions when the type
is pointer-shaped. No need to keep code to handle that in
convT2{I,E}.
Change-Id: I3a6668259556077cbb2986a9e8fe42a625d506c9
Reviewed-on: https://go-review.googlesource.com/22249
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michel Lespinasse <walken@google.com>
Diffstat (limited to 'src/runtime/iface.go')
-rw-r--r-- | src/runtime/iface.go | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/runtime/iface.go b/src/runtime/iface.go index 8f179bac80..352ff77465 100644 --- a/src/runtime/iface.go +++ b/src/runtime/iface.go @@ -160,18 +160,16 @@ func convT2E(t *_type, elem unsafe.Pointer, x unsafe.Pointer) (e eface) { msanread(elem, t.size) } if isDirectIface(t) { - e._type = t - typedmemmove(t, unsafe.Pointer(&e.data), elem) - } else { - if x == nil { - x = newobject(t) - } + throw("direct convT2E") + } + if x == nil { + x = newobject(t) // TODO: We allocate a zeroed object only to overwrite it with // actual data. Figure out how to avoid zeroing. Also below in convT2I. - typedmemmove(t, x, elem) - e._type = t - e.data = x } + typedmemmove(t, x, elem) + e._type = t + e.data = x return } @@ -184,16 +182,14 @@ func convT2I(tab *itab, elem unsafe.Pointer, x unsafe.Pointer) (i iface) { msanread(elem, t.size) } if isDirectIface(t) { - i.tab = tab - typedmemmove(t, unsafe.Pointer(&i.data), elem) - } else { - if x == nil { - x = newobject(t) - } - typedmemmove(t, x, elem) - i.tab = tab - i.data = x + throw("direct convT2I") + } + if x == nil { + x = newobject(t) } + typedmemmove(t, x, elem) + i.tab = tab + i.data = x return } |