]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix/improve exitThread on openbsd
authorJoel Sing <joel@sing.id.au>
Thu, 5 Apr 2018 19:00:25 +0000 (05:00 +1000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 5 Apr 2018 19:29:35 +0000 (19:29 +0000)
OpenBSD's __threxit syscall takes a pointer to a 32-bit value that will be
zeroed immediately before the thread exits. Make use of this instead of
zeroing freeWait from the exitThread assembly and using hacks like switching
to a static stack, so this works on 386.

Change-Id: I3ec5ead82b6496404834d148f713794d5d9da723
Reviewed-on: https://go-review.googlesource.com/105055
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/sys_openbsd_386.s
src/runtime/sys_openbsd_amd64.s
src/runtime/sys_openbsd_arm.s

index 475a93779897bb1b26e1d6e17900d301e863cca6..21f13c806e6351f1920c605af0a325d3c6438079 100644 (file)
@@ -19,17 +19,8 @@ TEXT runtime·exit(SB),NOSPLIT,$-4
        MOVL    $0xf1, 0xf1             // crash
        RET
 
-GLOBL exitStack<>(SB),RODATA,$8
-DATA exitStack<>+0x00(SB)/4, $0
-DATA exitStack<>+0x04(SB)/4, $0
-
 // func exitThread(wait *uint32)
 TEXT runtime·exitThread(SB),NOSPLIT,$0-4
-       MOVL    wait+0(FP), AX
-       // We're done using the stack.
-       MOVL    $0, (AX)
-       // sys__lwp_exit takes 1 argument, which it expects on the stack.
-       MOVL    $exitStack<>(SB), SP
        MOVL    $302, AX                // sys___threxit
        INT     $0x80
        MOVL    $0xf1, 0xf1             // crash
index 658f2c49dc15dec7aae567d7ca3f71ba3510c56b..38ac38d9bf1824fb35ec0e489baf1d3c735e76a8 100644 (file)
@@ -90,10 +90,7 @@ TEXT runtime·exit(SB),NOSPLIT,$-8
 
 // func exitThread(wait *uint32)
 TEXT runtime·exitThread(SB),NOSPLIT,$0-8
-       MOVQ    wait+0(FP), AX
-       // We're done using the stack.
-       MOVL    $0, (AX)
-       MOVQ    $0, DI                  // arg 1 - notdead
+       MOVQ    wait+0(FP), DI          // arg 1 - notdead
        MOVL    $302, AX                // sys___threxit
        SYSCALL
        MOVL    $0xf1, 0xf1             // crash
index 76a3fe8d91e9f685dc8d536c182a15d6a3199b1b..ff1c1da9b97ee0c71979421a94bb1b48e714cd4d 100644 (file)
@@ -24,15 +24,7 @@ TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0
 
 // func exitThread(wait *uint32)
 TEXT runtime·exitThread(SB),NOSPLIT,$0-4
-       MOVW    wait+0(FP), R0
-       // We're done using the stack.
-       MOVW    $0, R2
-storeloop:
-       LDREX   (R0), R4          // loads R4
-       STREX   R2, (R0), R1      // stores R2
-       CMP     $0, R1
-       BNE     storeloop
-       MOVW    $0, R0                  // arg 1 - notdead
+       MOVW    wait+0(FP), R0          // arg 1 - notdead
        MOVW    $302, R12               // sys___threxit
        SWI     $0
        MOVW.CS $1, R8                  // crash on syscall failure