diff options
| author | Keith Randall <khr@golang.org> | 2017-01-03 16:15:38 -0800 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2017-02-13 18:16:31 +0000 |
| commit | 5a75d6a08ebb727c0e2bf5c8fbcbc104d260d302 (patch) | |
| tree | 7fa0fe7218a250e9636b7bcbb487a8cd8e765907 /src/runtime/runtime2.go | |
| parent | ee2f5fafd88b5ce1404fa40e3645a409e9630897 (diff) | |
| download | go-5a75d6a08ebb727c0e2bf5c8fbcbc104d260d302.tar.xz | |
cmd/compile: optimize non-empty-interface type conversions
When doing i.(T) for non-empty-interface i and concrete type T,
there's no need to read the type out of the itab. Just compare the
itab to the itab we expect for that interface/type pair.
Also optimize type switches by putting the type hash of the
concrete type in the itab. That way we don't need to load the
type pointer out of the itab.
Update #18492
Change-Id: I49e280a21e5687e771db5b8a56b685291ac168ce
Reviewed-on: https://go-review.googlesource.com/34810
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 9cb2b85f33..8cf13e96d8 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -644,8 +644,10 @@ type itab struct { inter *interfacetype _type *_type link *itab - bad int32 - inhash int32 // has this itab been added to hash? + hash uint32 // copy of _type.hash. Used for type switches. + bad bool // type does not implement interface + inhash bool // has this itab been added to hash? + unused [2]byte fun [1]uintptr // variable sized } |
