@@ -29,21 +29,21 @@ pub const closure_thunk = $if amd64 {
2929 [
3030 u8 (0xF3 ), 0x44 , 0x0F , 0x7E , 0x3D , 0xF7 , 0xBF , 0xFF , 0xFF , // movq xmm15, QWORD PTR [rip - userdata]
3131 0xFF , 0x25 , 0xF9 , 0xBF , 0xFF , 0xFF // jmp QWORD PTR [rip - fn]
32- ]
32+ ]!
3333} $else $if i386 {
3434 [
3535 u8 (0xe8 ), 0x00 , 0x00 , 0x00 , 0x00 , // call here
3636 // here:
3737 0x59 , // pop ecx
3838 0x66 , 0x0F , 0x6E , 0xF9 , // movd xmm7, ecx
3939 0xff , 0xA1 , 0xff , 0xbf , 0xff , 0xff , // jmp DWORD PTR [ecx - 0x4001] # <fn>
40- ]
40+ ]!
4141} $else $if arm64 {
4242 [
4343 u8 (0x11 ), 0x00 , 0xFE , 0x5C , // ldr d17, userdata
4444 0x30 , 0x00 , 0xFE , 0x58 , // ldr x16, fn
4545 0x00 , 0x02 , 0x1F , 0xD6 // br x16
46- ]
46+ ]!
4747} $else $if arm32 {
4848 [
4949 u8 (0x04 ), 0xC0 , 0x4F , 0xE2 , // adr ip, here
@@ -52,28 +52,28 @@ pub const closure_thunk = $if amd64 {
5252 0x90 , 0xCA , 0x07 , 0xEE , // vmov s15, ip
5353 0x00 , 0xC0 , 0x9C , 0xE5 , // ldr ip, [ip, 0]
5454 0x1C , 0xFF , 0x2F , 0xE1 // bx ip
55- ]
55+ ]!
5656} $else $if rv64 {
5757 [
5858 u8 (0x97 ), 0xCF , 0xFF , 0xFF , // auipc t6, 0xffffc
5959 0x03 , 0xBF , 0x8F , 0x00 , // ld t5, 8(t6)
6060 0x07 , 0xB3 , 0x0F , 0x00 , // fld ft6, 0(t6)
6161 0x67 , 0x00 , 0x0F , 0x00 , // jr t5
62- ]
62+ ]!
6363} $else $if rv32 {
6464 [
6565 u8 (0x97 ), 0xCF , 0xFF , 0xFF , // auipc t6, 0xffffc
6666 0x03 , 0xAF , 0x4F , 0x00 , // lw t5, 4(t6)
6767 0x07 , 0xAB , 0x0F , 0x00 , // flw fs6, 0(t6)
6868 0x67 , 0x00 , 0x0F , 0x00 // jr t5
69- ]
69+ ]!
7070} $else $if s390 x {
7171 [
7272 u8 (0xC0 ), 0x70 , 0xFF , 0xFF , 0xE0 , 0x00 , // larl %r7, -16384
7373 0x68 , 0xF0 , 0x70 , 0x00 , // ld %f15, 0(%r7)
7474 0xE3 , 0x70 , 0x70 , 0x08 , 0x00 , 0x04 , // lg %r7, 8(%r7)
7575 0x07 , 0xF7 , // br %r7
76- ]
76+ ]!
7777} $else $if ppc64 le {
7878 [
7979 u8 (0xa6 ), 0x02 , 0x08 , 0x7c , // mflr %r0
@@ -85,67 +85,67 @@ pub const closure_thunk = $if amd64 {
8585 0xa6 , 0x03 , 0x08 , 0x7c , // mtlr %r0
8686 0xa6 , 0x03 , 0xc9 , 0x7d , // mtctr %r14
8787 0x20 , 0x04 , 0x80 , 0x4e , // bctr
88- ]
88+ ]!
8989} $else $if loongarch64 {
9090 [
9191 u8 (0x92 ), 0xFF , 0xFF , 0x1D , // pcaddu12i t6, -4
9292 0x48 , 0x02 , 0x80 , 0x2B , // fld.d f8, t6, 0
9393 0x51 , 0x22 , 0xC0 , 0x28 , // ld.d t5, t6, 8
9494 0x20 , 0x02 , 0x00 , 0x4C , // jr t5
95- ]
95+ ]!
9696} $else {
97- [] u8 {}
97+ [u8 ( 0 )] !
9898}
9999
100100const closure_get_data_bytes = $if amd64 {
101101 [
102102 u8 (0x66 ), 0x4C , 0x0F , 0x7E , 0xF8 , // movq rax, xmm15
103103 0xC3 // ret
104- ]
104+ ]!
105105} $else $if i386 {
106106 [
107107 u8 (0x66 ), 0x0F , 0x7E , 0xF8 , // movd eax, xmm7
108108 0x8B , 0x80 , 0xFB , 0xBF , 0xFF , 0xFF , // mov eax, DWORD PTR [eax - 0x4005]
109109 0xc3 // ret
110- ]
110+ ]!
111111} $else $if arm64 {
112112 [
113113 u8 (0x20 ), 0x02 , 0x66 , 0x9E , // fmov x0, d17
114114 0xC0 , 0x03 , 0x5F , 0xD6 // ret
115- ]
115+ ]!
116116} $else $if arm32 {
117117 [
118118 u8 (0x90 ), 0x0A , 0x17 , 0xEE , // vmov r0, s15
119119 0x04 , 0x00 , 0x10 , 0xE5 , // ldr r0, [r0, #-4]
120120 0x1E , 0xFF , 0x2F , 0xE1 // bx lr
121- ]
121+ ]!
122122} $else $if rv64 {
123123 [
124124 u8 (0x53 ), 0x05 , 0x03 , 0xE2 , // fmv.x.d a0, ft6
125125 0x67 , 0x80 , 0x00 , 0x00 , // ret
126- ]
126+ ]!
127127} $else $if rv32 {
128128 [
129129 u8 (0x53 ), 0x05 , 0x0B , 0xE0 , // fmv.x.w a0, fs6
130130 0x67 , 0x80 , 0x00 , 0x00 // ret
131- ]
131+ ]!
132132} $else $if s390 x {
133133 [
134134 u8 (0xB3 ), 0xCD , 0x00 , 0x2F , // lgdr %r2, %f15
135135 0x07 , 0xFE , // br %r14
136- ]
136+ ]!
137137} $else $if ppc64 le {
138138 [
139139 u8 (0x66 ), 0x00 , 0xc3 , 0x7d , // mfvsrd %r3, %f14
140140 0x20 , 0x00 , 0x80 , 0x4e , // blr
141- ]
141+ ]!
142142} $else $if loongarch64 {
143143 [
144144 u8 (0x04 ), 0xB9 , 0x14 , 0x01 , // movfr2gr.d a0, f8
145145 0x20 , 0x00 , 0x00 , 0x4C , // ret
146- ]
146+ ]!
147147} $else {
148- [] u8 {}
148+ [u8 ( 0 )] !
149149}
150150// vfmt on
151151
@@ -172,7 +172,7 @@ fn closure_alloc() {
172172
173173 // Fill page with closure templates
174174 for remaining > 0 {
175- unsafe { vmemcpy (x, closure_thunk.data , closure_thunk.len) } // Copy template
175+ unsafe { vmemcpy (x, & closure_thunk[ 0 ] , closure_thunk.len) } // Copy template
176176 remaining--
177177 unsafe {
178178 x + = closure_size // Move to next slot
@@ -198,7 +198,7 @@ fn closure_init() {
198198 // Temporarily enable write access to executable memory
199199 closure_memory_protect_platform (g_closure.closure_ptr, page_size, .read_write)
200200 // Copy closure entry stub code
201- vmemcpy (g_closure.closure_ptr, closure_get_data_bytes.data , closure_get_data_bytes.len)
201+ vmemcpy (g_closure.closure_ptr, & closure_get_data_bytes[ 0 ] , closure_get_data_bytes.len)
202202 // Re-enormalize execution protection
203203 closure_memory_protect_platform (g_closure.closure_ptr, page_size, .read_exec)
204204 }
0 commit comments