aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/iface.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-09-17 15:04:36 -0700
committerKeith Randall <khr@golang.org>2016-09-19 02:37:08 +0000
commit6129f37367686edf7c2732fbb5300d5f28203743 (patch)
tree18dfa388342ea4868caab33c299be065d558be76 /src/runtime/iface.go
parent892d146a7aae17e5fe22e04b16ba4da7e3d8c767 (diff)
downloadgo-6129f37367686edf7c2732fbb5300d5f28203743.tar.gz
go-6129f37367686edf7c2732fbb5300d5f28203743.zip
cmd/compile: inline convT2{I,E} when result doesn't escape
No point in calling a function when we can build the interface using a known type (or itab) and the address of a local. Get rid of third arg (preallocated stack space) to convT2{I,E}. Makes go binary smaller by 0.2% benchmark old ns/op new ns/op delta BenchmarkEfaceInteger-8 16.7 10.1 -39.52% Update #17118 Update #15375 Change-Id: I9724a1f802bfa1e3957bf1856b55558278e198a2 Reviewed-on: https://go-review.googlesource.com/29373 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/runtime/iface.go')
-rw-r--r--src/runtime/iface.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/runtime/iface.go b/src/runtime/iface.go
index 7f24a6e69c..476ec7e8b2 100644
--- a/src/runtime/iface.go
+++ b/src/runtime/iface.go
@@ -152,7 +152,7 @@ func itabsinit() {
unlock(&ifaceLock)
}
-func convT2E(t *_type, elem unsafe.Pointer, x unsafe.Pointer) (e eface) {
+func convT2E(t *_type, elem unsafe.Pointer) (e eface) {
if raceenabled {
raceReadObjectPC(t, elem, getcallerpc(unsafe.Pointer(&t)), funcPC(convT2E))
}
@@ -162,18 +162,16 @@ func convT2E(t *_type, elem unsafe.Pointer, x unsafe.Pointer) (e eface) {
if isDirectIface(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.
- }
+ 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
return
}
-func convT2I(tab *itab, elem unsafe.Pointer, x unsafe.Pointer) (i iface) {
+func convT2I(tab *itab, elem unsafe.Pointer) (i iface) {
t := tab._type
if raceenabled {
raceReadObjectPC(t, elem, getcallerpc(unsafe.Pointer(&tab)), funcPC(convT2I))
@@ -184,9 +182,7 @@ func convT2I(tab *itab, elem unsafe.Pointer, x unsafe.Pointer) (i iface) {
if isDirectIface(t) {
throw("direct convT2I")
}
- if x == nil {
- x = newobject(t)
- }
+ x := newobject(t)
typedmemmove(t, x, elem)
i.tab = tab
i.data = x