From 5a75d6a08ebb727c0e2bf5c8fbcbc104d260d302 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 3 Jan 2017 16:15:38 -0800 Subject: 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 TryBot-Result: Gobot Gobot Reviewed-by: Josh Bleecher Snyder Reviewed-by: David Chase --- src/runtime/runtime2.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/runtime/runtime2.go') 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 } -- cgit v1.3