public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext.
@ 2021-04-10 17:01 Iain Buclaw
0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-04-10 17:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d17435597c873aebdfaf14e8bd579ee8e5583113
commit d17435597c873aebdfaf14e8bd579ee8e5583113
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu Dec 10 14:31:10 2020 +0000
D, Darwin : OS-specific version of fibre_switchContext.
Cater for Mach-O assemblers in two places:
1/ Use .p2align to make it specific that we have power-of-2
alignment demands.
2/ Provide a CFI and FDE without relying on .cfi_xxxx directives
which are not supported by all Darwin's assemblers and are
not yet in use for GCC.
Diff:
---
libphobos/libdruntime/config/x86/switchcontext.S | 160 +++++++++++++++++++++--
1 file changed, 150 insertions(+), 10 deletions(-)
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 8af3f5488ba..86187c938e5 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -29,13 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# include <cet.h>
#endif
-#if defined(__i386__) && !defined(__CET__)
+#if !defined(__MACH__)
+# if defined(__i386__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -63,17 +64,17 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
-#elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
+# elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -102,8 +103,147 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
+# endif
+
+#elif !defined(__CET__) /* Mach-O / Darwin without CET. */
+
+# if defined(__i386__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // save current stack state
+ push %ebp
+ mov %esp, %ebp
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
+
+ // store oldp again with more accurate address
+ mov 8(%ebp), %eax
+ mov %esp, (%eax)
+ // load newp to begin context switch
+ mov 12(%ebp), %esp
+
+ // load saved state from new stack
+ pop %eax
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x7c # sleb128 -4; CIE Data Alignment Factor
+ .byte 0x8 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x5 # uleb128 0x5
+ .byte 0x4 # uleb128 0x4
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .byte 0x1 # uleb128 0x1
+ .p2align 2,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .long LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .long L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 2,0
+LEFDE1:
+
+# elif defined(__x86_64__) && !defined(__ILP32__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // Save current stack state.save current stack state
+ push %rbp
+ mov %rsp, %rbp
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %rbx
+
+ // store oldp again with more accurate address
+ mov %rsp, (%rdi)
+ // load newp to begin context switch
+ mov %rsi, %rsp
+
+ // load saved state from new stack
+ pop %rbx
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbp
+
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 0x10 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x7 # uleb128 0x7
+ .byte 0x8 # uleb128 0x8
+ .byte 0x90 # DW_CFA_offset, column 0x10
+ .byte 0x1 # uleb128 0x1
+ .p2align 3,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .quad LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .quad L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 3,0
+LEFDE1:
+
+# endif
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext.
@ 2021-04-10 15:05 Iain Buclaw
0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-04-10 15:05 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:af2cddb5396255251a8531930c749c4a77f80c3c
commit af2cddb5396255251a8531930c749c4a77f80c3c
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu Dec 10 14:31:10 2020 +0000
D, Darwin : OS-specific version of fibre_switchContext.
Cater for Mach-O assemblers in two places:
1/ Use .p2align to make it specific that we have power-of-2
alignment demands.
2/ Provide a CFI and FDE without relying on .cfi_xxxx directives
which are not supported by all Darwin's assemblers and are
not yet in use for GCC.
Diff:
---
libphobos/libdruntime/config/x86/switchcontext.S | 160 +++++++++++++++++++++--
1 file changed, 150 insertions(+), 10 deletions(-)
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 8af3f5488ba..86187c938e5 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -29,13 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# include <cet.h>
#endif
-#if defined(__i386__) && !defined(__CET__)
+#if !defined(__MACH__)
+# if defined(__i386__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -63,17 +64,17 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
-#elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
+# elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -102,8 +103,147 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
+# endif
+
+#elif !defined(__CET__) /* Mach-O / Darwin without CET. */
+
+# if defined(__i386__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // save current stack state
+ push %ebp
+ mov %esp, %ebp
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
+
+ // store oldp again with more accurate address
+ mov 8(%ebp), %eax
+ mov %esp, (%eax)
+ // load newp to begin context switch
+ mov 12(%ebp), %esp
+
+ // load saved state from new stack
+ pop %eax
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x7c # sleb128 -4; CIE Data Alignment Factor
+ .byte 0x8 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x5 # uleb128 0x5
+ .byte 0x4 # uleb128 0x4
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .byte 0x1 # uleb128 0x1
+ .p2align 2,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .long LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .long L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 2,0
+LEFDE1:
+
+# elif defined(__x86_64__) && !defined(__ILP32__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // Save current stack state.save current stack state
+ push %rbp
+ mov %rsp, %rbp
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %rbx
+
+ // store oldp again with more accurate address
+ mov %rsp, (%rdi)
+ // load newp to begin context switch
+ mov %rsi, %rsp
+
+ // load saved state from new stack
+ pop %rbx
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbp
+
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 0x10 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x7 # uleb128 0x7
+ .byte 0x8 # uleb128 0x8
+ .byte 0x90 # DW_CFA_offset, column 0x10
+ .byte 0x1 # uleb128 0x1
+ .p2align 3,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .quad LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .quad L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 3,0
+LEFDE1:
+
+# endif
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext.
@ 2021-03-14 22:01 Iain Buclaw
0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-03-14 22:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:68c1b46bc1ce10e235f0bd24ec05536ca01417e6
commit 68c1b46bc1ce10e235f0bd24ec05536ca01417e6
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu Dec 10 14:31:10 2020 +0000
D, Darwin : OS-specific version of fibre_switchContext.
Cater for Mach-O assemblers in two places:
1/ Use .p2align to make it specific that we have power-of-2
alignment demands.
2/ Provide a CFI and FDE without relying on .cfi_xxxx directives
which are not supported by all Darwin's assemblers and are
not yet in use for GCC.
Diff:
---
libphobos/libdruntime/config/x86/switchcontext.S | 160 +++++++++++++++++++++--
1 file changed, 150 insertions(+), 10 deletions(-)
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 8af3f5488ba..86187c938e5 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -29,13 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# include <cet.h>
#endif
-#if defined(__i386__) && !defined(__CET__)
+#if !defined(__MACH__)
+# if defined(__i386__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -63,17 +64,17 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
-#elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
+# elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -102,8 +103,147 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
+# endif
+
+#elif !defined(__CET__) /* Mach-O / Darwin without CET. */
+
+# if defined(__i386__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // save current stack state
+ push %ebp
+ mov %esp, %ebp
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
+
+ // store oldp again with more accurate address
+ mov 8(%ebp), %eax
+ mov %esp, (%eax)
+ // load newp to begin context switch
+ mov 12(%ebp), %esp
+
+ // load saved state from new stack
+ pop %eax
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x7c # sleb128 -4; CIE Data Alignment Factor
+ .byte 0x8 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x5 # uleb128 0x5
+ .byte 0x4 # uleb128 0x4
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .byte 0x1 # uleb128 0x1
+ .p2align 2,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .long LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .long L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 2,0
+LEFDE1:
+
+# elif defined(__x86_64__) && !defined(__ILP32__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // Save current stack state.save current stack state
+ push %rbp
+ mov %rsp, %rbp
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %rbx
+
+ // store oldp again with more accurate address
+ mov %rsp, (%rdi)
+ // load newp to begin context switch
+ mov %rsi, %rsp
+
+ // load saved state from new stack
+ pop %rbx
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbp
+
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 0x10 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x7 # uleb128 0x7
+ .byte 0x8 # uleb128 0x8
+ .byte 0x90 # DW_CFA_offset, column 0x10
+ .byte 0x1 # uleb128 0x1
+ .p2align 3,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .quad LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .quad L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 3,0
+LEFDE1:
+
+# endif
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext.
@ 2021-03-07 17:02 Iain Buclaw
0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-03-07 17:02 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f2ef793645f007c32e69d278c77cb9d9cd14c1ab
commit f2ef793645f007c32e69d278c77cb9d9cd14c1ab
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu Dec 10 14:31:10 2020 +0000
D, Darwin : OS-specific version of fibre_switchContext.
Cater for Mach-O assemblers in two places:
1/ Use .p2align to make it specific that we have power-of-2
alignment demands.
2/ Provide a CFI and FDE without relying on .cfi_xxxx directives
which are not supported by all Darwin's assemblers and are
not yet in use for GCC.
Diff:
---
libphobos/libdruntime/config/x86/switchcontext.S | 160 +++++++++++++++++++++--
1 file changed, 150 insertions(+), 10 deletions(-)
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 8af3f5488ba..86187c938e5 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -29,13 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# include <cet.h>
#endif
-#if defined(__i386__) && !defined(__CET__)
+#if !defined(__MACH__)
+# if defined(__i386__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -63,17 +64,17 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
-#elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
+# elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -102,8 +103,147 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
+# endif
+
+#elif !defined(__CET__) /* Mach-O / Darwin without CET. */
+
+# if defined(__i386__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // save current stack state
+ push %ebp
+ mov %esp, %ebp
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
+
+ // store oldp again with more accurate address
+ mov 8(%ebp), %eax
+ mov %esp, (%eax)
+ // load newp to begin context switch
+ mov 12(%ebp), %esp
+
+ // load saved state from new stack
+ pop %eax
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x7c # sleb128 -4; CIE Data Alignment Factor
+ .byte 0x8 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x5 # uleb128 0x5
+ .byte 0x4 # uleb128 0x4
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .byte 0x1 # uleb128 0x1
+ .p2align 2,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .long LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .long L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 2,0
+LEFDE1:
+
+# elif defined(__x86_64__) && !defined(__ILP32__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // Save current stack state.save current stack state
+ push %rbp
+ mov %rsp, %rbp
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %rbx
+
+ // store oldp again with more accurate address
+ mov %rsp, (%rdi)
+ // load newp to begin context switch
+ mov %rsi, %rsp
+
+ // load saved state from new stack
+ pop %rbx
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbp
+
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 0x10 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x7 # uleb128 0x7
+ .byte 0x8 # uleb128 0x8
+ .byte 0x90 # DW_CFA_offset, column 0x10
+ .byte 0x1 # uleb128 0x1
+ .p2align 3,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .quad LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .quad L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 3,0
+LEFDE1:
+
+# endif
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext.
@ 2021-01-30 19:09 Iain Buclaw
0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-01-30 19:09 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d102e6b64c93662a4f7e21f9b00c6ccbdb8d5618
commit d102e6b64c93662a4f7e21f9b00c6ccbdb8d5618
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu Dec 10 14:31:10 2020 +0000
D, Darwin : OS-specific version of fibre_switchContext.
Cater for Mach-O assemblers in two places:
1/ Use .p2align to make it specific that we have power-of-2
alignment demands.
2/ Provide a CFI and FDE without relying on .cfi_xxxx directives
which are not supported by all Darwin's assemblers and are
not yet in use for GCC.
Diff:
---
libphobos/libdruntime/config/x86/switchcontext.S | 160 +++++++++++++++++++++--
1 file changed, 150 insertions(+), 10 deletions(-)
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 8af3f5488ba..86187c938e5 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -29,13 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# include <cet.h>
#endif
-#if defined(__i386__) && !defined(__CET__)
+#if !defined(__MACH__)
+# if defined(__i386__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -63,17 +64,17 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
-#elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
+# elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -102,8 +103,147 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
+# endif
+
+#elif !defined(__CET__) /* Mach-O / Darwin without CET. */
+
+# if defined(__i386__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // save current stack state
+ push %ebp
+ mov %esp, %ebp
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
+
+ // store oldp again with more accurate address
+ mov 8(%ebp), %eax
+ mov %esp, (%eax)
+ // load newp to begin context switch
+ mov 12(%ebp), %esp
+
+ // load saved state from new stack
+ pop %eax
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x7c # sleb128 -4; CIE Data Alignment Factor
+ .byte 0x8 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x5 # uleb128 0x5
+ .byte 0x4 # uleb128 0x4
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .byte 0x1 # uleb128 0x1
+ .p2align 2,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .long LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .long L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 2,0
+LEFDE1:
+
+# elif defined(__x86_64__) && !defined(__ILP32__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // Save current stack state.save current stack state
+ push %rbp
+ mov %rsp, %rbp
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %rbx
+
+ // store oldp again with more accurate address
+ mov %rsp, (%rdi)
+ // load newp to begin context switch
+ mov %rsi, %rsp
+
+ // load saved state from new stack
+ pop %rbx
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbp
+
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 0x10 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x7 # uleb128 0x7
+ .byte 0x8 # uleb128 0x8
+ .byte 0x90 # DW_CFA_offset, column 0x10
+ .byte 0x1 # uleb128 0x1
+ .p2align 3,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .quad LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .quad L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 3,0
+LEFDE1:
+
+# endif
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext.
@ 2021-01-28 17:32 Iain Buclaw
0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-01-28 17:32 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7adbe3113a29f773ecf50e2ba7f0d0212e300d12
commit 7adbe3113a29f773ecf50e2ba7f0d0212e300d12
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu Dec 10 14:31:10 2020 +0000
D, Darwin : OS-specific version of fibre_switchContext.
Cater for Mach-O assemblers in two places:
1/ Use .p2align to make it specific that we have power-of-2
alignment demands.
2/ Provide a CFI and FDE without relying on .cfi_xxxx directives
which are not supported by all Darwin's assemblers and are
not yet in use for GCC.
Diff:
---
libphobos/libdruntime/config/x86/switchcontext.S | 160 +++++++++++++++++++++--
1 file changed, 150 insertions(+), 10 deletions(-)
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 8af3f5488ba..86187c938e5 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -29,13 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# include <cet.h>
#endif
-#if defined(__i386__) && !defined(__CET__)
+#if !defined(__MACH__)
+# if defined(__i386__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -63,17 +64,17 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
-#elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
+# elif defined(__x86_64__) && !defined(__ILP32__) && !defined(__CET__)
.text
.globl CSYM(fiber_switchContext)
-#if defined(__ELF__)
+# if defined(__ELF__)
.type CSYM(fiber_switchContext), @function
-#endif
+# endif
.align 16
CSYM(fiber_switchContext):
.cfi_startproc
@@ -102,8 +103,147 @@ CSYM(fiber_switchContext):
// 'return' to complete switch
ret
.cfi_endproc
-#if defined(__ELF__)
+# if defined(__ELF__)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
-#endif
+# endif
+# endif
+
+#elif !defined(__CET__) /* Mach-O / Darwin without CET. */
+
+# if defined(__i386__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // save current stack state
+ push %ebp
+ mov %esp, %ebp
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
+
+ // store oldp again with more accurate address
+ mov 8(%ebp), %eax
+ mov %esp, (%eax)
+ // load newp to begin context switch
+ mov 12(%ebp), %esp
+
+ // load saved state from new stack
+ pop %eax
+ pop %ebx
+ pop %esi
+ pop %edi
+ pop %ebp
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x7c # sleb128 -4; CIE Data Alignment Factor
+ .byte 0x8 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x5 # uleb128 0x5
+ .byte 0x4 # uleb128 0x4
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .byte 0x1 # uleb128 0x1
+ .p2align 2,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .long LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .long L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 2,0
+LEFDE1:
+
+# elif defined(__x86_64__) && !defined(__ILP32__)
+
+ .text
+ .globl CSYM(fiber_switchContext)
+ .p2align 4
+CSYM(fiber_switchContext):
+LFB0:
+ // Save current stack state.save current stack state
+ push %rbp
+ mov %rsp, %rbp
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %rbx
+
+ // store oldp again with more accurate address
+ mov %rsp, (%rdi)
+ // load newp to begin context switch
+ mov %rsi, %rsp
+
+ // load saved state from new stack
+ pop %rbx
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+ pop %rbp
+
+ // 'return' to complete switch
+ ret
+LFE0:
+
+/* CFI */
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 # Length of Common Information Entry
+LSCIE1:
+ .long 0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 0x10 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte 0x10 # FDE Encoding (pcrel)
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 0x7 # uleb128 0x7
+ .byte 0x8 # uleb128 0x8
+ .byte 0x90 # DW_CFA_offset, column 0x10
+ .byte 0x1 # uleb128 0x1
+ .p2align 3,0
+LECIE1:
+
+/* minimal FDE - does not record the stack frame changes. */
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 # FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 # FDE CIE offset
+ .quad LFB0-. # FDE initial location
+ .set L$set$2,LFE0-LFB0
+ .quad L$set$2 # FDE address range
+ .byte 0 # uleb128 0; Augmentation size
+ .p2align 3,0
+LEFDE1:
+
+# endif
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-10 17:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-10 17:01 [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : OS-specific version of fibre_switchContext Iain Buclaw
-- strict thread matches above, loose matches on Subject: below --
2021-04-10 15:05 Iain Buclaw
2021-03-14 22:01 Iain Buclaw
2021-03-07 17:02 Iain Buclaw
2021-01-30 19:09 Iain Buclaw
2021-01-28 17:32 Iain Buclaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).