Skip to content

cmd/compile: channel operations require but do not use a type dictionary #78379

Description

@mcy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions