compiler: simplify runtime.interfaceMethod signature slightly

Code size is not affected, as dead arguments are eliminated anyway.
It makes future interface optimizations hopefully easier to implement.
Этот коммит содержится в:
Ayke van Laethem 2018-11-05 19:04:10 +01:00
родитель 611bca39ab
коммит d1c0d6120a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED
2 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -2272,8 +2272,9 @@ func (c *Compiler) getInvokeCall(frame *Frame, instr *ssa.CallCommon) (llvm.Valu
llvmFnType = llvmFnType.Subtypes()[1] llvmFnType = llvmFnType.Subtypes()[1]
} }
typecode := c.builder.CreateExtractValue(itf, 0, "invoke.typecode")
values := []llvm.Value{ values := []llvm.Value{
itf, typecode,
llvm.ConstInt(c.ctx.Int16Type(), uint64(c.ir.MethodNum(instr.Method)), false), llvm.ConstInt(c.ctx.Int16Type(), uint64(c.ir.MethodNum(instr.Method)), false),
} }
fn := c.createRuntimeCall("interfaceMethod", values, "invoke.func") fn := c.createRuntimeCall("interfaceMethod", values, "invoke.func")

Просмотреть файл

@ -48,12 +48,12 @@ var (
// Get the function pointer for the method on the interface. // Get the function pointer for the method on the interface.
// This is a compiler intrinsic. // This is a compiler intrinsic.
//go:nobounds //go:nobounds
func interfaceMethod(itf _interface, method uint16) *uint8 { func interfaceMethod(typecode uint16, method uint16) *uint8 {
// This function doesn't do bounds checking as the supplied method must be // This function doesn't do bounds checking as the supplied method must be
// in the list of signatures. The compiler will only emit // in the list of signatures. The compiler will only emit
// runtime.interfaceMethod calls when the method actually exists on this // runtime.interfaceMethod calls when the method actually exists on this
// interface (proven by the typechecker). // interface (proven by the typechecker).
i := methodSetRanges[itf.typecode-firstTypeWithMethods].index i := methodSetRanges[typecode-firstTypeWithMethods].index
for { for {
if methodSetSignatures[i] == method { if methodSetSignatures[i] == method {
return methodSetFunctions[i] return methodSetFunctions[i]