aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_linux_amd64.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/sys_linux_amd64.s')
-rw-r--r--src/runtime/sys_linux_amd64.s47
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