builtin.closure #
The files in this directory implement the closure
feature of the V language, which is called internally by the V compiler.
Constants #
const closure_thunk = $if amd64 {
[
u8(0xF3),
0x44,
0x0F,
0x7E,
0x3D,
0xF7,
0xBF,
0xFF,
0xFF, // movq xmm15, QWORD PTR [rip - userdata]
0xFF,
0x25,
0xF9,
0xBF,
0xFF,
0xFF, // jmp QWORD PTR [rip - fn]
]
} $else $if i386 {
[
u8(0xe8),
0x00,
0x00,
0x00,
0x00, // call here
// here:
0x59, // pop ecx
0x66,
0x0F,
0x6E,
0xF9, // movd xmm7, ecx
0xff,
0xA1,
0xff,
0xbf,
0xff,
0xff, // jmp DWORD PTR [ecx - 0x4001] #
]
} $else $if arm64 {
[
u8(0x11),
0x00,
0xFE,
0x5C, // ldr d17, userdata
0x30,
0x00,
0xFE,
0x58, // ldr x16, fn
0x00,
0x02,
0x1F,
0xD6, // br x16
]
} $else $if arm32 {
[
u8(0x04),
0xC0,
0x4F,
0xE2, // adr ip, here
// here:
0x01,
0xC9,
0x4C,
0xE2, // sub ip, ip, #0x4000
0x90,
0xCA,
0x07,
0xEE, // vmov s15, ip
0x00,
0xC0,
0x9C,
0xE5, // ldr ip, [ip, 0]
0x1C,
0xFF,
0x2F,
0xE1, // bx ip
]
} $else $if rv64 {
[
u8(0x97),
0xCF,
0xFF,
0xFF, // auipc t6, 0xffffc
0x03,
0xBF,
0x8F,
0x00, // ld t5, 8(t6)
0x07,
0xB3,
0x0F,
0x00, // fld ft6, 0(t6)
0x67,
0x00,
0x0F,
0x00, // jr t5
]
} $else $if rv32 {
[
u8(0x97),
0xCF,
0xFF,
0xFF, // auipc t6, 0xffffc
0x03,
0xAF,
0x4F,
0x00, // lw t5, 4(t6)
0x07,
0xAB,
0x0F,
0x00, // flw fs6, 0(t6)
0x67,
0x00,
0x0F,
0x00, // jr t5
]
} $else $if s390x {
[
u8(0xC0),
0x70,
0xFF,
0xFF,
0xE0,
0x00, // larl %r7, -16384
0x68,
0xF0,
0x70,
0x00, // ld %f15, 0(%r7)
0xE3,
0x70,
0x70,
0x08,
0x00,
0x04, // lg %r7, 8(%r7)
0x07,
0xF7, // br %r7
]
} $else $if ppc64le {
[
u8(0xa6),
0x02,
0x08,
0x7c, // mflr %r0
0x05,
0x00,
0x00,
0x48, // bl here
0xa6,
0x02,
0xc8,
0x7d, // here: mflr %r14
0xf8,
0xbf,
0xce,
0x39, // addi %r14, %r14, -16392
0x00,
0x00,
0xce,
0xc9, // lfd %f14, 0(%r14)
0x08,
0x00,
0xce,
0xe9, // ld %r14, 8(%r14)
0xa6,
0x03,
0x08,
0x7c, // mtlr %r0
0xa6,
0x03,
0xc9,
0x7d, // mtctr %r14
0x20,
0x04,
0x80,
0x4e, // bctr
]
} $else $if loongarch64 {
[
u8(0x92),
0xFF,
0xFF,
0x1D, // pcaddu12i t6, -4
0x48,
0x02,
0x80,
0x2B, // fld.d f8, t6, 0
0x51,
0x22,
0xC0,
0x28, // ld.d t5, t6, 8
0x20,
0x02,
0x00,
0x4C, // jr t5
]
} $else {
[]u8{}
}
refer to https://godbolt.org/z/r7P3EYv6c for a complete assembly vfmt off
struct C.pthread_mutex_t #
@[typedef]
struct C.pthread_mutex_t {}