diff options
| author | Srdjan Petrovic <spetrovic@google.com> | 2015-04-17 17:27:07 -0700 |
|---|---|---|
| committer | David Crawshaw <crawshaw@golang.org> | 2015-04-22 16:28:57 +0000 |
| commit | ca9128f18fe75878ba2d5e0df09ae755c085f72a (patch) | |
| tree | 14dc3f65d05c3425c251282b91b1fe1be2079895 /src/runtime/sys_linux_amd64.s | |
| parent | 3f91a017f8f67cb9a744cf5d0a8b5db34a95808d (diff) | |
| download | go-ca9128f18fe75878ba2d5e0df09ae755c085f72a.tar.xz | |
runtime: merge clone0 and clone
We initially added clone0 to handle the case when G or M don't exist, but
it turns out that we could have just modified clone. (It also helps that
the function we're invoking in clone0 no longer needs arguments.)
As a side-effect, newosproc0 is now supported on all linux archs.
Change-Id: Ie603af75d8f164310fc16446052d83743961f3ca
Reviewed-on: https://go-review.googlesource.com/9164
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Diffstat (limited to 'src/runtime/sys_linux_amd64.s')
| -rw-r--r-- | src/runtime/sys_linux_amd64.s | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s index 43a65b7ccd..3a0c47fb63 100644 --- a/src/runtime/sys_linux_amd64.s +++ b/src/runtime/sys_linux_amd64.s @@ -302,14 +302,16 @@ TEXT runtime·futex(SB),NOSPLIT,$0 // int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void)); TEXT runtime·clone(SB),NOSPLIT,$0 - MOVL flags+8(SP), DI - MOVQ stack+16(SP), SI + MOVL flags+0(FP), DI + MOVQ stack+8(FP), SI + MOVQ $0, DX + MOVQ $0, R10 // Copy mp, gp, fn off parent stack for use by child. // Careful: Linux system call clobbers CX and R11. - MOVQ mm+24(SP), R8 - MOVQ gg+32(SP), R9 - MOVQ fn+40(SP), R12 + MOVQ mp+16(FP), R8 + MOVQ gp+24(FP), R9 + MOVQ fn+32(FP), R12 MOVL $56, AX SYSCALL @@ -323,6 +325,12 @@ TEXT runtime·clone(SB),NOSPLIT,$0 // In child, on new stack. MOVQ SI, SP + // If g or m are nil, skip Go-related setup. + CMPQ R8, $0 // m + JEQ nog + CMPQ R9, $0 // g + JEQ nog + // Initialize m->procid to Linux tid MOVL $186, AX // gettid SYSCALL @@ -338,6 +346,7 @@ TEXT runtime·clone(SB),NOSPLIT,$0 MOVQ R9, g(CX) CALL runtime·stackcheck(SB) +nog: // Call fn CALL R12 @@ -347,34 +356,6 @@ TEXT runtime·clone(SB),NOSPLIT,$0 SYSCALL JMP -3(PC) // keep exiting -// int32 clone0(int32 flags, void *stack, void* fn, void* fnarg); -TEXT runtime·clone0(SB),NOSPLIT,$16-36 - MOVL flags+0(FP), DI - MOVQ stack+8(FP), SI - MOVQ fn+16(FP), R12 // used by the child - MOVQ fnarg+24(FP), R13 // used by the child - MOVL $0, DX - MOVL $0, R10 - MOVL $56, AX - SYSCALL - - CMPQ AX, $0 - JEQ child - // In parent, return. - MOVL AX, ret+32(FP) - RET -child: - MOVQ SI, SP - MOVQ R12, AX // fn - MOVQ R13, DI // fnarg - CALL AX - - // fn shouldn't return; if it does, exit. - MOVL $111, DI - MOVL $60, AX - SYSCALL - JMP -3(PC) // keep exiting - TEXT runtime·sigaltstack(SB),NOSPLIT,$-8 MOVQ new+8(SP), DI MOVQ old+16(SP), SI |
