mirror of
https://github.com/golang/go
synced 2024-11-23 22:40:04 -07:00
runtime: reduce syscall when call runtime.clone
Change-Id: I3ea398fd86aae4c86557dd6fff65d90a6f756890
GitHub-Last-Rev: 4c295388f7
GitHub-Pull-Request: golang/go#40392
Reviewed-on: https://go-review.googlesource.com/c/go/+/244626
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
84a62453e5
commit
0941fc3f9f
@ -592,13 +592,25 @@ TEXT runtime·clone(SB),NOSPLIT,$0
|
|||||||
MOVQ stk+8(FP), SI
|
MOVQ stk+8(FP), SI
|
||||||
MOVQ $0, DX
|
MOVQ $0, DX
|
||||||
MOVQ $0, R10
|
MOVQ $0, R10
|
||||||
|
MOVQ $0, R8
|
||||||
// Copy mp, gp, fn off parent stack for use by child.
|
// Copy mp, gp, fn off parent stack for use by child.
|
||||||
// Careful: Linux system call clobbers CX and R11.
|
// Careful: Linux system call clobbers CX and R11.
|
||||||
MOVQ mp+16(FP), R8
|
MOVQ mp+16(FP), R13
|
||||||
MOVQ gp+24(FP), R9
|
MOVQ gp+24(FP), R9
|
||||||
MOVQ fn+32(FP), R12
|
MOVQ fn+32(FP), R12
|
||||||
|
CMPQ R13, $0 // m
|
||||||
|
JEQ nog1
|
||||||
|
CMPQ R9, $0 // g
|
||||||
|
JEQ nog1
|
||||||
|
LEAQ m_tls(R13), R8
|
||||||
|
#ifdef GOOS_android
|
||||||
|
// Android stores the TLS offset in runtime·tls_g.
|
||||||
|
SUBQ runtime·tls_g(SB), R8
|
||||||
|
#else
|
||||||
|
ADDQ $8, R8 // ELF wants to use -8(FS)
|
||||||
|
#endif
|
||||||
|
ORQ $0x00080000, DI //add flag CLONE_SETTLS(0x00080000) to call clone
|
||||||
|
nog1:
|
||||||
MOVL $SYS_clone, AX
|
MOVL $SYS_clone, AX
|
||||||
SYSCALL
|
SYSCALL
|
||||||
|
|
||||||
@ -612,27 +624,23 @@ TEXT runtime·clone(SB),NOSPLIT,$0
|
|||||||
MOVQ SI, SP
|
MOVQ SI, SP
|
||||||
|
|
||||||
// If g or m are nil, skip Go-related setup.
|
// If g or m are nil, skip Go-related setup.
|
||||||
CMPQ R8, $0 // m
|
CMPQ R13, $0 // m
|
||||||
JEQ nog
|
JEQ nog2
|
||||||
CMPQ R9, $0 // g
|
CMPQ R9, $0 // g
|
||||||
JEQ nog
|
JEQ nog2
|
||||||
|
|
||||||
// Initialize m->procid to Linux tid
|
// Initialize m->procid to Linux tid
|
||||||
MOVL $SYS_gettid, AX
|
MOVL $SYS_gettid, AX
|
||||||
SYSCALL
|
SYSCALL
|
||||||
MOVQ AX, m_procid(R8)
|
MOVQ AX, m_procid(R13)
|
||||||
|
|
||||||
// Set FS to point at m->tls.
|
|
||||||
LEAQ m_tls(R8), DI
|
|
||||||
CALL runtime·settls(SB)
|
|
||||||
|
|
||||||
// In child, set up new stack
|
// In child, set up new stack
|
||||||
get_tls(CX)
|
get_tls(CX)
|
||||||
MOVQ R8, g_m(R9)
|
MOVQ R13, g_m(R9)
|
||||||
MOVQ R9, g(CX)
|
MOVQ R9, g(CX)
|
||||||
CALL runtime·stackcheck(SB)
|
CALL runtime·stackcheck(SB)
|
||||||
|
|
||||||
nog:
|
nog2:
|
||||||
// Call fn
|
// Call fn
|
||||||
CALL R12
|
CALL R12
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user