Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/compile: make interface conversion function selection ABI insensi…
…tive Before register ABI, we always pass argument in memory, and the compiler chooses interface conversion functions solely based on the memory layout. As long as the two types have identical memory layout, it is fine to mix and match, e.g. convT64 takes a uint64 argument, but it can be used for things like float64 or struct { x [4]struct{}; y int64 }. With register ABI, those types may be passed differently, e.g. uint64 is passed in an integer register, float64 is passed in a floating point register, the struct above is passed in memory. I made a few attempts in the previous CLs to try to choose the right function based on the argument type, but none of them is really correct. Instead, this CL changes it to always pass the argument in the same type the runtime expects, and do conversion before the call in the compiler. The conversion can be no-op (e.g. a named type to its underlying type), direct (e.g. int64 to uint64), or through memory (e.g. *(*uint64)(unsafe.Pointer(&arg))). This way, the front end does not need to know the ABI. (It only needs to know how to convert types, and it already does.) TODO: do something similar for map functions. Change-Id: I33fc780a47c3f332b765e09b5e527f52ea1d6b5c Reviewed-on: https://go-review.googlesource.com/c/go/+/309029 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
- Loading branch information