aboutsummaryrefslogtreecommitdiff
path: root/libgo/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-06-21 22:00:57 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-06-21 22:00:57 +0000
commit0514cb33749fefd2542e7294a35d0ef0ccae30b3 (patch)
tree7c947df211513d9ca430a41d1980e1b9e624177d /libgo/go
parentfd4e7255b60901581961b62e364ce85baf52d631 (diff)
downloadgcc-0514cb33749fefd2542e7294a35d0ef0ccae30b3.zip
gcc-0514cb33749fefd2542e7294a35d0ef0ccae30b3.tar.gz
gcc-0514cb33749fefd2542e7294a35d0ef0ccae30b3.tar.bz2
compiler: open code some type assertions
Now that type equality is just simple pointer equality, we can open code some type assertions instead of making runtime calls. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182977 From-SVN: r272577
Diffstat (limited to 'libgo/go')
-rw-r--r--libgo/go/runtime/iface.go37
1 files changed, 4 insertions, 33 deletions
diff --git a/libgo/go/runtime/iface.go b/libgo/go/runtime/iface.go
index 1c3a5f3..6def738 100644
--- a/libgo/go/runtime/iface.go
+++ b/libgo/go/runtime/iface.go
@@ -15,10 +15,7 @@ import (
//
//go:linkname requireitab runtime.requireitab
//go:linkname assertitab runtime.assertitab
-//go:linkname assertI2T runtime.assertI2T
-//go:linkname ifacetypeeq runtime.ifacetypeeq
-//go:linkname efacetype runtime.efacetype
-//go:linkname ifacetype runtime.ifacetype
+//go:linkname panicdottype runtime.panicdottype
//go:linkname ifaceE2E2 runtime.ifaceE2E2
//go:linkname ifaceI2E2 runtime.ifaceI2E2
//go:linkname ifaceE2I2 runtime.ifaceE2I2
@@ -356,35 +353,9 @@ func assertitab(lhs, rhs *_type) unsafe.Pointer {
return getitab(lhs, rhs, false)
}
-// Check whether an interface type may be converted to a non-interface
-// type, panicing if not.
-func assertI2T(lhs, rhs, inter *_type) {
- if rhs == nil {
- panic(&TypeAssertionError{nil, nil, lhs, ""})
- }
- if !eqtype(lhs, rhs) {
- panic(&TypeAssertionError{inter, rhs, lhs, ""})
- }
-}
-
-// Compare two type descriptors for equality.
-func ifacetypeeq(a, b *_type) bool {
- return eqtype(a, b)
-}
-
-// Return the type descriptor of an empty interface.
-// FIXME: This should be inlined by the compiler.
-func efacetype(e eface) *_type {
- return e._type
-}
-
-// Return the type descriptor of a non-empty interface.
-// FIXME: This should be inlined by the compiler.
-func ifacetype(i iface) *_type {
- if i.tab == nil {
- return nil
- }
- return *(**_type)(i.tab)
+// panicdottype is called when doing an i.(T) conversion and the conversion fails.
+func panicdottype(lhs, rhs, inter *_type) {
+ panic(&TypeAssertionError{inter, rhs, lhs, ""})
}
// Convert an empty interface to an empty interface, for a comma-ok