mirror of
https://github.com/golang/go
synced 2024-11-17 16:54:44 -07:00
cbcf8efa5f
That way we don't need to call into the runtime for every type assertion (to an interface type). name old time/op new time/op delta TypeAssert-24 3.78ns ± 3% 1.00ns ± 1% -73.53% (p=0.000 n=10+8) Change-Id: I0ba308aaf0f24a5495b4e13c814d35af0c58bfde Reviewed-on: https://go-review.googlesource.com/c/go/+/529316 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
28 lines
621 B
Go
28 lines
621 B
Go
// asmcheck
|
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package codegen
|
|
|
|
type I interface{ M() }
|
|
|
|
func NopConvertIface(x I) I {
|
|
// amd64:-`.*runtime.convI2I`
|
|
return I(x)
|
|
}
|
|
|
|
func NopConvertGeneric[T any](x T) T {
|
|
// amd64:-`.*runtime.convI2I`
|
|
return T(x)
|
|
}
|
|
|
|
var NopConvertGenericIface = NopConvertGeneric[I]
|
|
|
|
func ConvToM(x any) I {
|
|
// amd64:`CALL\truntime.typeAssert`,`MOVL\t16\(.*\)`,`MOVQ\t8\(.*\)(.*\*1)`
|
|
// arm64:`CALL\truntime.typeAssert`,`LDAR`,`MOVWU`,`MOVD\t\(R.*\)\(R.*\)`
|
|
return x.(I)
|
|
}
|