]> git.proxmox.com Git - rustc.git/blob - vendor/psm/src/arch/x86_64_windows_gnu.s
New upstream version 1.45.0+dfsg1
[rustc.git] / vendor / psm / src / arch / x86_64_windows_gnu.s
1 #include "psm.h"
2
3 .text
4
5 .def rust_psm_stack_direction
6 .scl 2
7 .type 32
8 .endef
9 .globl rust_psm_stack_direction
10 .p2align 4
11 rust_psm_stack_direction:
12 /* extern "sysv64" fn() -> u8 (%al) */
13 .cfi_startproc
14 movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
15 retq
16 .cfi_endproc
17
18 .def rust_psm_stack_pointer
19 .scl 2
20 .type 32
21 .endef
22 .globl rust_psm_stack_pointer
23 .p2align 4
24 rust_psm_stack_pointer:
25 /* extern "sysv64" fn() -> *mut u8 (%rax) */
26 .cfi_startproc
27 leaq 8(%rsp), %rax
28 retq
29 .cfi_endproc
30
31
32 .def rust_psm_replace_stack
33 .scl 2
34 .type 32
35 .endef
36 .globl rust_psm_replace_stack
37 .p2align 4
38 rust_psm_replace_stack:
39 /* extern "sysv64" fn(%rdi: usize, %rsi: extern "sysv64" fn(usize), %rdx: *mut u8, %rcx: *mut u8) */
40 .cfi_startproc
41 /*
42 All we gotta do is set the stack pointer to %rdx & tail-call the callback in %rsi.
43
44 8-byte offset necessary to account for the "return" pointer that would otherwise be placed onto
45 stack with a regular call
46 */
47 movq %gs:0x08, %rdx
48 movq %gs:0x10, %rcx
49 leaq -8(%rdx), %rsp
50 jmpq *%rsi
51 .cfi_endproc
52
53
54 .def rust_psm_on_stack
55 .scl 2
56 .type 32
57 .endef
58 .globl rust_psm_on_stack
59 .p2align 4
60 rust_psm_on_stack:
61 /*
62 extern "sysv64" fn(%rdi: usize, %rsi: usize,
63 %rdx: extern "sysv64" fn(usize, usize), %rcx: *mut u8, %r8: *mut u8)
64
65 NB: on Windows for SEH to work at all, the pointers in TIB, thread information block, need to be
66 fixed up. Otherwise, it seems that exception mechanism on Windows will not bother looking for
67 exception handlers at *all* if they happen to fall outside the are specified in TIB.
68
69 This necessitates an API difference from the usual 4-argument signature used elsewhere.
70
71 FIXME: this needs a catch-all exception handler that aborts in case somebody unwinds into here.
72 */
73 .cfi_startproc
74 pushq %rbp
75 .cfi_def_cfa %rsp, 16
76 .cfi_offset %rbp, -16
77 pushq %gs:0x08
78 .cfi_def_cfa %rsp, 24
79 pushq %gs:0x10
80 .cfi_def_cfa %rsp, 32
81
82 movq %rsp, %rbp
83 .cfi_def_cfa_register %rbp
84 movq %rcx, %gs:0x08
85 movq %r8, %gs:0x10
86 movq %rcx, %rsp
87 callq *%rdx
88 movq %rbp, %rsp
89
90 popq %gs:0x10
91 .cfi_def_cfa %rsp, 24
92 popq %gs:0x08
93 .cfi_def_cfa %rsp, 16
94 popq %rbp
95 .cfi_def_cfa %rsp, 8
96 retq
97 .cfi_endproc