Consider the following program:
package p
func f[T any](s chan T) {
s <- <-s
}
var x = f[int]
This produces:
TEXT command-line-arguments.f[go.shape.int](SB), DUPOK|ABIInternal, $40-16
PUSHQ BP
MOVQ SP, BP
SUBQ $32, SP
MOVQ BX, .s+56(SP)
MOVQ $0, ..autotmp_2+24(SP)
MOVQ BX, AX // (lmao)
LEAQ ..autotmp_2+24(SP), BX
CALL runtime.chanrecv1(SB)
MOVQ ..autotmp_2+24(SP), CX
MOVQ CX, ..autotmp_3+16(SP)
MOVQ .s+56(SP), AX
LEAQ ..autotmp_3+16(SP), BX
NOP
CALL runtime.chansend1(SB)
ADDQ $32, SP
POPQ BP
RET
Notice (lmao), where rax is unceremoniously clobbered. This is the type dictionary, which is not used by either chanrecv or chansend, because those functions only take the channel pointer itself and a pointer to the input or output. Other channel operations have similar ABI.
Consider the following program:
This produces:
Notice
(lmao), whereraxis unceremoniously clobbered. This is the type dictionary, which is not used by eitherchanrecvorchansend, because those functions only take the channel pointer itself and a pointer to the input or output. Other channel operations have similar ABI.