mirror of
https://github.com/golang/go
synced 2024-11-20 02:44:39 -07:00
runtime: start new darwin/amd64 threads on correct stack,
then enable stack check. R=r https://golang.org/cl/165100
This commit is contained in:
parent
aacb515668
commit
0400a7f8b1
@ -11,7 +11,7 @@
|
|||||||
#include "amd64/asm.h"
|
#include "amd64/asm.h"
|
||||||
|
|
||||||
// Exit the entire program (like C exit)
|
// Exit the entire program (like C exit)
|
||||||
TEXT exit(SB),7,$-8
|
TEXT exit(SB),7,$0
|
||||||
MOVL 8(SP), DI // arg 1 exit status
|
MOVL 8(SP), DI // arg 1 exit status
|
||||||
MOVL $(0x2000000+1), AX // syscall entry
|
MOVL $(0x2000000+1), AX // syscall entry
|
||||||
SYSCALL
|
SYSCALL
|
||||||
@ -20,14 +20,14 @@ TEXT exit(SB),7,$-8
|
|||||||
|
|
||||||
// Exit this OS thread (like pthread_exit, which eventually
|
// Exit this OS thread (like pthread_exit, which eventually
|
||||||
// calls __bsdthread_terminate).
|
// calls __bsdthread_terminate).
|
||||||
TEXT exit1(SB),7,$-8
|
TEXT exit1(SB),7,$0
|
||||||
MOVL 8(SP), DI // arg 1 exit status
|
MOVL 8(SP), DI // arg 1 exit status
|
||||||
MOVL $(0x2000000+361), AX // syscall entry
|
MOVL $(0x2000000+361), AX // syscall entry
|
||||||
SYSCALL
|
SYSCALL
|
||||||
CALL notok(SB)
|
CALL notok(SB)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT write(SB),7,$-8
|
TEXT write(SB),7,$0
|
||||||
MOVL 8(SP), DI // arg 1 fd
|
MOVL 8(SP), DI // arg 1 fd
|
||||||
MOVQ 16(SP), SI // arg 2 buf
|
MOVQ 16(SP), SI // arg 2 buf
|
||||||
MOVL 24(SP), DX // arg 3 count
|
MOVL 24(SP), DX // arg 3 count
|
||||||
@ -37,7 +37,7 @@ TEXT write(SB),7,$-8
|
|||||||
CALL notok(SB)
|
CALL notok(SB)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT sigaction(SB),7,$-8
|
TEXT sigaction(SB),7,$0
|
||||||
MOVL 8(SP), DI // arg 1 sig
|
MOVL 8(SP), DI // arg 1 sig
|
||||||
MOVQ 16(SP), SI // arg 2 act
|
MOVQ 16(SP), SI // arg 2 act
|
||||||
MOVQ 24(SP), DX // arg 3 oact
|
MOVQ 24(SP), DX // arg 3 oact
|
||||||
@ -63,7 +63,7 @@ TEXT sigtramp(SB),7,$40
|
|||||||
SYSCALL
|
SYSCALL
|
||||||
INT $3 // not reached
|
INT $3 // not reached
|
||||||
|
|
||||||
TEXT runtime·mmap(SB),7,$-8
|
TEXT runtime·mmap(SB),7,$0
|
||||||
MOVQ 8(SP), DI // arg 1 addr
|
MOVQ 8(SP), DI // arg 1 addr
|
||||||
MOVL 16(SP), SI // arg 2 len
|
MOVL 16(SP), SI // arg 2 len
|
||||||
MOVL 20(SP), DX // arg 3 prot
|
MOVL 20(SP), DX // arg 3 prot
|
||||||
@ -76,12 +76,12 @@ TEXT runtime·mmap(SB),7,$-8
|
|||||||
CALL notok(SB)
|
CALL notok(SB)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT notok(SB),7,$-8
|
TEXT notok(SB),7,$0
|
||||||
MOVL $0xf1, BP
|
MOVL $0xf1, BP
|
||||||
MOVQ BP, (BP)
|
MOVQ BP, (BP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT runtime·memclr(SB),7,$-8
|
TEXT runtime·memclr(SB),7,$0
|
||||||
MOVQ 8(SP), DI // arg 1 addr
|
MOVQ 8(SP), DI // arg 1 addr
|
||||||
MOVL 16(SP), CX // arg 2 count
|
MOVL 16(SP), CX // arg 2 count
|
||||||
ADDL $7, CX
|
ADDL $7, CX
|
||||||
@ -103,7 +103,7 @@ TEXT runtime·setcallerpc+0(SB),7,$0
|
|||||||
MOVQ BX, -8(AX) // set calling pc
|
MOVQ BX, -8(AX) // set calling pc
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT sigaltstack(SB),7,$-8
|
TEXT sigaltstack(SB),7,$0
|
||||||
MOVQ new+8(SP), DI
|
MOVQ new+8(SP), DI
|
||||||
MOVQ old+16(SP), SI
|
MOVQ old+16(SP), SI
|
||||||
MOVQ $(0x2000000+53), AX
|
MOVQ $(0x2000000+53), AX
|
||||||
@ -113,7 +113,7 @@ TEXT sigaltstack(SB),7,$-8
|
|||||||
RET
|
RET
|
||||||
|
|
||||||
// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
|
// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
|
||||||
TEXT bsdthread_create(SB),7,$-8
|
TEXT bsdthread_create(SB),7,$0
|
||||||
// Set up arguments to bsdthread_create system call.
|
// Set up arguments to bsdthread_create system call.
|
||||||
// The ones in quotes pass through to the thread callback
|
// The ones in quotes pass through to the thread callback
|
||||||
// uninterpreted, so we can put whatever we want there.
|
// uninterpreted, so we can put whatever we want there.
|
||||||
@ -139,9 +139,11 @@ TEXT bsdthread_create(SB),7,$-8
|
|||||||
// R8 = stack
|
// R8 = stack
|
||||||
// R9 = flags (= 0)
|
// R9 = flags (= 0)
|
||||||
// SP = stack - C_64_REDZONE_LEN (= stack - 128)
|
// SP = stack - C_64_REDZONE_LEN (= stack - 128)
|
||||||
TEXT bsdthread_start(SB),7,$-8
|
TEXT bsdthread_start(SB),7,$0
|
||||||
|
MOVQ R8, SP // empirically, SP is very wrong but R8 is right
|
||||||
MOVQ CX, m
|
MOVQ CX, m
|
||||||
MOVQ m_g0(m), g
|
MOVQ m_g0(m), g
|
||||||
|
CALL stackcheck(SB)
|
||||||
MOVQ SI, m_procid(m) // thread port is m->procid
|
MOVQ SI, m_procid(m) // thread port is m->procid
|
||||||
CALL DX // fn
|
CALL DX // fn
|
||||||
CALL exit1(SB)
|
CALL exit1(SB)
|
||||||
@ -150,7 +152,7 @@ TEXT bsdthread_start(SB),7,$-8
|
|||||||
// void bsdthread_register(void)
|
// void bsdthread_register(void)
|
||||||
// registers callbacks for threadstart (see bsdthread_create above
|
// registers callbacks for threadstart (see bsdthread_create above
|
||||||
// and wqthread and pthsize (not used). returns 0 on success.
|
// and wqthread and pthsize (not used). returns 0 on success.
|
||||||
TEXT bsdthread_register(SB),7,$-8
|
TEXT bsdthread_register(SB),7,$0
|
||||||
MOVQ $bsdthread_start(SB), DI // threadstart
|
MOVQ $bsdthread_start(SB), DI // threadstart
|
||||||
MOVQ $0, SI // wqthread, not used by us
|
MOVQ $0, SI // wqthread, not used by us
|
||||||
MOVQ $0, DX // pthsize, not used by us
|
MOVQ $0, DX // pthsize, not used by us
|
||||||
|
Loading…
Reference in New Issue
Block a user