public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : Re-implement callWithStackShell for X86 Darwin.
@ 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:48bdd96265011e76dc6905df969124c364d5fff3

commit 48bdd96265011e76dc6905df969124c364d5fff3
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 10 14:13:55 2020 +0000

    D, Darwin : Re-implement callWithStackShell for X86 Darwin.
    
    At present, Darwin is using a generic solution to exposing the
    callee-saved registers to the GC.  This uses __builtin_unwind_init ().
    followed by an assignment to an address-taken variable to mark the
    stack bottom.
    
    This has two issues:
    1) On some archs it stores a huge amount of FP and Vector state which
        is not the subject of the scan - and, indeed might produce false hits.
    
    2) Even on archs like X86, without callee-saved FPRs/VRs there tend to
        be 'holes' in the frame allocations (to deal with alignment) which also
       will  contain random data which could produce false positives.
    
    The replacement solution stores only the integer callee-saved registers and
    then arranges a pointer to those.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index 880836e3a25..282e7b8ac90 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1396,8 +1396,44 @@ in (fn)
     void *sp = void;
     version (GNU)
     {
-        __builtin_unwind_init();
-        sp = &sp;
+        // The generic solution below using a call to __builtin_unwind_init ()
+        // followed by an assignment to sp has two issues:
+        // 1) On some archs it stores a huge amount of FP and Vector state which
+        //    is not the subject of the scan - and, indeed might produce false
+        //    hits.
+        // 2) Even on archs like X86, where there are no callee-saved FPRs/VRs there
+        //    tend to be 'holes' in the frame allocations (to deal with alignment) which
+        //    also will  contain random data which could produce false positives.
+        // This solution stores only the integer callee-saved registers.
+        version (X86)
+        {
+            void*[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movl   %%ebx, %0" : "=m" (regs[0]);
+                "movl   %%esi, %0" : "=m" (regs[1]);
+                "movl   %%edi, %0" : "=m" (regs[2]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else version (X86_64)
+        {
+            void*[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movq   %%rbx, %0" : "=m" (regs[0]);
+                "movq   %%r12, %0" : "=m" (regs[1]);
+                "movq   %%r13, %0" : "=m" (regs[2]);
+                "movq   %%r14, %0" : "=m" (regs[3]);
+                "movq   %%r15, %0" : "=m" (regs[4]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
     }
     else version (AsmX86_Posix)
     {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : Re-implement callWithStackShell for X86 Darwin.
@ 2021-04-10 15:04 Iain Buclaw
  0 siblings, 0 replies; 6+ messages in thread
From: Iain Buclaw @ 2021-04-10 15:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d3cc4211d6f5a72ecc0206c79a6bf06d1d252e98

commit d3cc4211d6f5a72ecc0206c79a6bf06d1d252e98
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 10 14:13:55 2020 +0000

    D, Darwin : Re-implement callWithStackShell for X86 Darwin.
    
    At present, Darwin is using a generic solution to exposing the
    callee-saved registers to the GC.  This uses __builtin_unwind_init ().
    followed by an assignment to an address-taken variable to mark the
    stack bottom.
    
    This has two issues:
    1) On some archs it stores a huge amount of FP and Vector state which
        is not the subject of the scan - and, indeed might produce false hits.
    
    2) Even on archs like X86, without callee-saved FPRs/VRs there tend to
        be 'holes' in the frame allocations (to deal with alignment) which also
       will  contain random data which could produce false positives.
    
    The replacement solution stores only the integer callee-saved registers and
    then arranges a pointer to those.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index 880836e3a25..282e7b8ac90 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1396,8 +1396,44 @@ in (fn)
     void *sp = void;
     version (GNU)
     {
-        __builtin_unwind_init();
-        sp = &sp;
+        // The generic solution below using a call to __builtin_unwind_init ()
+        // followed by an assignment to sp has two issues:
+        // 1) On some archs it stores a huge amount of FP and Vector state which
+        //    is not the subject of the scan - and, indeed might produce false
+        //    hits.
+        // 2) Even on archs like X86, where there are no callee-saved FPRs/VRs there
+        //    tend to be 'holes' in the frame allocations (to deal with alignment) which
+        //    also will  contain random data which could produce false positives.
+        // This solution stores only the integer callee-saved registers.
+        version (X86)
+        {
+            void*[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movl   %%ebx, %0" : "=m" (regs[0]);
+                "movl   %%esi, %0" : "=m" (regs[1]);
+                "movl   %%edi, %0" : "=m" (regs[2]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else version (X86_64)
+        {
+            void*[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movq   %%rbx, %0" : "=m" (regs[0]);
+                "movq   %%r12, %0" : "=m" (regs[1]);
+                "movq   %%r13, %0" : "=m" (regs[2]);
+                "movq   %%r14, %0" : "=m" (regs[3]);
+                "movq   %%r15, %0" : "=m" (regs[4]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
     }
     else version (AsmX86_Posix)
     {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : Re-implement callWithStackShell for X86 Darwin.
@ 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:f3c6f4487e648ed3a748d00f111dfc3bbfc64ba0

commit f3c6f4487e648ed3a748d00f111dfc3bbfc64ba0
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 10 14:13:55 2020 +0000

    D, Darwin : Re-implement callWithStackShell for X86 Darwin.
    
    At present, Darwin is using a generic solution to exposing the
    callee-saved registers to the GC.  This uses __builtin_unwind_init ().
    followed by an assignment to an address-taken variable to mark the
    stack bottom.
    
    This has two issues:
    1) On some archs it stores a huge amount of FP and Vector state which
        is not the subject of the scan - and, indeed might produce false hits.
    
    2) Even on archs like X86, without callee-saved FPRs/VRs there tend to
        be 'holes' in the frame allocations (to deal with alignment) which also
       will  contain random data which could produce false positives.
    
    The replacement solution stores only the integer callee-saved registers and
    then arranges a pointer to those.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index defdc9586f1..316ba92c391 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1396,8 +1396,44 @@ in (fn)
     void *sp = void;
     version (GNU)
     {
-        __builtin_unwind_init();
-        sp = &sp;
+        // The generic solution below using a call to __builtin_unwind_init ()
+        // followed by an assignment to sp has two issues:
+        // 1) On some archs it stores a huge amount of FP and Vector state which
+        //    is not the subject of the scan - and, indeed might produce false
+        //    hits.
+        // 2) Even on archs like X86, where there are no callee-saved FPRs/VRs there
+        //    tend to be 'holes' in the frame allocations (to deal with alignment) which
+        //    also will  contain random data which could produce false positives.
+        // This solution stores only the integer callee-saved registers.
+        version (X86)
+        {
+            void*[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movl   %%ebx, %0" : "=m" (regs[0]);
+                "movl   %%esi, %0" : "=m" (regs[1]);
+                "movl   %%edi, %0" : "=m" (regs[2]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else version (X86_64)
+        {
+            void*[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movq   %%rbx, %0" : "=m" (regs[0]);
+                "movq   %%r12, %0" : "=m" (regs[1]);
+                "movq   %%r13, %0" : "=m" (regs[2]);
+                "movq   %%r14, %0" : "=m" (regs[3]);
+                "movq   %%r15, %0" : "=m" (regs[4]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
     }
     else version (AsmX86_Posix)
     {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : Re-implement callWithStackShell for X86 Darwin.
@ 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:ed8478260482a8d0ddb4b1a33179026d1c60cc18

commit ed8478260482a8d0ddb4b1a33179026d1c60cc18
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 10 14:13:55 2020 +0000

    D, Darwin : Re-implement callWithStackShell for X86 Darwin.
    
    At present, Darwin is using a generic solution to exposing the
    callee-saved registers to the GC.  This uses __builtin_unwind_init ().
    followed by an assignment to an address-taken variable to mark the
    stack bottom.
    
    This has two issues:
    1) On some archs it stores a huge amount of FP and Vector state which
        is not the subject of the scan - and, indeed might produce false hits.
    
    2) Even on archs like X86, without callee-saved FPRs/VRs there tend to
        be 'holes' in the frame allocations (to deal with alignment) which also
       will  contain random data which could produce false positives.
    
    The replacement solution stores only the integer callee-saved registers and
    then arranges a pointer to those.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index defdc9586f1..316ba92c391 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1396,8 +1396,44 @@ in (fn)
     void *sp = void;
     version (GNU)
     {
-        __builtin_unwind_init();
-        sp = &sp;
+        // The generic solution below using a call to __builtin_unwind_init ()
+        // followed by an assignment to sp has two issues:
+        // 1) On some archs it stores a huge amount of FP and Vector state which
+        //    is not the subject of the scan - and, indeed might produce false
+        //    hits.
+        // 2) Even on archs like X86, where there are no callee-saved FPRs/VRs there
+        //    tend to be 'holes' in the frame allocations (to deal with alignment) which
+        //    also will  contain random data which could produce false positives.
+        // This solution stores only the integer callee-saved registers.
+        version (X86)
+        {
+            void*[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movl   %%ebx, %0" : "=m" (regs[0]);
+                "movl   %%esi, %0" : "=m" (regs[1]);
+                "movl   %%edi, %0" : "=m" (regs[2]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else version (X86_64)
+        {
+            void*[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movq   %%rbx, %0" : "=m" (regs[0]);
+                "movq   %%r12, %0" : "=m" (regs[1]);
+                "movq   %%r13, %0" : "=m" (regs[2]);
+                "movq   %%r14, %0" : "=m" (regs[3]);
+                "movq   %%r15, %0" : "=m" (regs[4]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
     }
     else version (AsmX86_Posix)
     {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : Re-implement callWithStackShell for X86 Darwin.
@ 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:a42330e5264b71aaf778e9481ac3f21e8a0ea53f

commit a42330e5264b71aaf778e9481ac3f21e8a0ea53f
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 10 14:13:55 2020 +0000

    D, Darwin : Re-implement callWithStackShell for X86 Darwin.
    
    At present, Darwin is using a generic solution to exposing the
    callee-saved registers to the GC.  This uses __builtin_unwind_init ().
    followed by an assignment to an address-taken variable to mark the
    stack bottom.
    
    This has two issues:
    1) On some archs it stores a huge amount of FP and Vector state which
        is not the subject of the scan - and, indeed might produce false hits.
    
    2) Even on archs like X86, without callee-saved FPRs/VRs there tend to
        be 'holes' in the frame allocations (to deal with alignment) which also
       will  contain random data which could produce false positives.
    
    The replacement solution stores only the integer callee-saved registers and
    then arranges a pointer to those.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index d81e0aa0607..1fb4af34414 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1396,8 +1396,44 @@ in (fn)
     void *sp = void;
     version (GNU)
     {
-        __builtin_unwind_init();
-        sp = &sp;
+        // The generic solution below using a call to __builtin_unwind_init ()
+        // followed by an assignment to sp has two issues:
+        // 1) On some archs it stores a huge amount of FP and Vector state which
+        //    is not the subject of the scan - and, indeed might produce false
+        //    hits.
+        // 2) Even on archs like X86, where there are no callee-saved FPRs/VRs there
+        //    tend to be 'holes' in the frame allocations (to deal with alignment) which
+        //    also will  contain random data which could produce false positives.
+        // This solution stores only the integer callee-saved registers.
+        version (X86)
+        {
+            void*[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movl   %%ebx, %0" : "=m" (regs[0]);
+                "movl   %%esi, %0" : "=m" (regs[1]);
+                "movl   %%edi, %0" : "=m" (regs[2]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else version (X86_64)
+        {
+            void*[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movq   %%rbx, %0" : "=m" (regs[0]);
+                "movq   %%r12, %0" : "=m" (regs[1]);
+                "movq   %%r13, %0" : "=m" (regs[2]);
+                "movq   %%r14, %0" : "=m" (regs[3]);
+                "movq   %%r15, %0" : "=m" (regs[4]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
     }
     else version (AsmX86_Posix)
     {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] D, Darwin : Re-implement callWithStackShell for X86 Darwin.
@ 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:5b4be371de8d9614b67ffc8e9dbebe18517bf023

commit 5b4be371de8d9614b67ffc8e9dbebe18517bf023
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 10 14:13:55 2020 +0000

    D, Darwin : Re-implement callWithStackShell for X86 Darwin.
    
    At present, Darwin is using a generic solution to exposing the
    callee-saved registers to the GC.  This uses __builtin_unwind_init ().
    followed by an assignment to an address-taken variable to mark the
    stack bottom.
    
    This has two issues:
    1) On some archs it stores a huge amount of FP and Vector state which
        is not the subject of the scan - and, indeed might produce false hits.
    
    2) Even on archs like X86, without callee-saved FPRs/VRs there tend to
        be 'holes' in the frame allocations (to deal with alignment) which also
       will  contain random data which could produce false positives.
    
    The replacement solution stores only the integer callee-saved registers and
    then arranges a pointer to those.

Diff:
---
 libphobos/libdruntime/core/thread/osthread.d | 40 ++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index d81e0aa0607..1fb4af34414 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1396,8 +1396,44 @@ in (fn)
     void *sp = void;
     version (GNU)
     {
-        __builtin_unwind_init();
-        sp = &sp;
+        // The generic solution below using a call to __builtin_unwind_init ()
+        // followed by an assignment to sp has two issues:
+        // 1) On some archs it stores a huge amount of FP and Vector state which
+        //    is not the subject of the scan - and, indeed might produce false
+        //    hits.
+        // 2) Even on archs like X86, where there are no callee-saved FPRs/VRs there
+        //    tend to be 'holes' in the frame allocations (to deal with alignment) which
+        //    also will  contain random data which could produce false positives.
+        // This solution stores only the integer callee-saved registers.
+        version (X86)
+        {
+            void*[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movl   %%ebx, %0" : "=m" (regs[0]);
+                "movl   %%esi, %0" : "=m" (regs[1]);
+                "movl   %%edi, %0" : "=m" (regs[2]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else version (X86_64)
+        {
+            void*[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                "movq   %%rbx, %0" : "=m" (regs[0]);
+                "movq   %%r12, %0" : "=m" (regs[1]);
+                "movq   %%r13, %0" : "=m" (regs[2]);
+                "movq   %%r14, %0" : "=m" (regs[3]);
+                "movq   %%r15, %0" : "=m" (regs[4]);
+            }
+            sp = cast(void*)&regs[0];
+        }
+        else
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
     }
     else version (AsmX86_Posix)
     {


^ 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 : Re-implement callWithStackShell for X86 Darwin Iain Buclaw
  -- strict thread matches above, loose matches on Subject: below --
2021-04-10 15:04 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).