Skip to content

proposal: cmd/compile: add GOEXPERIMENT=2pointers-closures #80537

Description

@Jorropo

Proposal Details

Add a GOEXPERIMENT 2pointers-closures which changes unsafe.Sizeof(func(){}) from unsafe.Sizeof(uintptr(0)) to unsafe.Sizeof(uintptr(0)) * 2.

This is an ABI breaking change I want to try targeted at optimizing the the typescript compiler.
It would transform closure := ptr.method from a heap allocation at worst.
To an LEAQ and a MOV.

basically use a representation for closures that is nearly identical to a single method interface
so the above pseudo code would compile to:

closure := abi.closure{&type.method.descriptor, ptr}

where type.method.descriptor is a .rodata objecting contains the method's PC and all of reflect's required info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions