Commit c844bf4c authored by David Crawshaw's avatar David Crawshaw

runtime: fix darwin/386, darwin/arm builds

In cl/8652 I broke darwin/arm and darwin/386 because I removed the *g
parameter, which they both expect and use. This CL adjusts both ports
to look for g0 in m, just as darwin/amd64 does.

Tested on darwin{386,arm,amd64}.

Change-Id: Ia56f3d97e126b40d8bbd2e8f677b008e4a1badad
Reviewed-on: https://go-review.googlesource.com/8666Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent e0d9342d
...@@ -327,33 +327,32 @@ TEXT runtime·usleep(SB),NOSPLIT,$32 ...@@ -327,33 +327,32 @@ TEXT runtime·usleep(SB),NOSPLIT,$32
INT $0x80 INT $0x80
RET RET
// func bsdthread_create(stk unsafe.Pointer, mm *m, gg *g, fn uintptr) int32 // func bsdthread_create(stk, arg unsafe.Pointer, fn uintptr) int32
// System call args are: func arg stack pthread flags. // System call args are: func arg stack pthread flags.
TEXT runtime·bsdthread_create(SB),NOSPLIT,$32 TEXT runtime·bsdthread_create(SB),NOSPLIT,$32
MOVL $360, AX MOVL $360, AX
// 0(SP) is where the caller PC would be; kernel skips it // 0(SP) is where the caller PC would be; kernel skips it
MOVL fn+12(FP), BX MOVL fn+8(FP), BX
MOVL BX, 4(SP) // func MOVL BX, 4(SP) // func
MOVL mm+4(FP), BX MOVL arg+4(FP), BX
MOVL BX, 8(SP) // arg MOVL BX, 8(SP) // arg
MOVL stk+0(FP), BX MOVL stk+0(FP), BX
MOVL BX, 12(SP) // stack MOVL BX, 12(SP) // stack
MOVL gg+8(FP), BX MOVL $0, 16(SP) // pthread
MOVL BX, 16(SP) // pthread
MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM
INT $0x80 INT $0x80
JAE 4(PC) JAE 4(PC)
NEGL AX NEGL AX
MOVL AX, ret+16(FP) MOVL AX, ret+12(FP)
RET RET
MOVL $0, AX MOVL $0, AX
MOVL AX, ret+16(FP) MOVL AX, ret+12(FP)
RET RET
// The thread that bsdthread_create creates starts executing here, // The thread that bsdthread_create creates starts executing here,
// because we registered this function using bsdthread_register // because we registered this function using bsdthread_register
// at startup. // at startup.
// AX = "pthread" (= g) // AX = "pthread" (= 0x0)
// BX = mach thread port // BX = mach thread port
// CX = "func" (= fn) // CX = "func" (= fn)
// DX = "arg" (= m) // DX = "arg" (= m)
...@@ -380,6 +379,7 @@ TEXT runtime·bsdthread_start(SB),NOSPLIT,$0 ...@@ -380,6 +379,7 @@ TEXT runtime·bsdthread_start(SB),NOSPLIT,$0
// Now segment is established. Initialize m, g. // Now segment is established. Initialize m, g.
get_tls(BP) get_tls(BP)
MOVL m_g0(DX), AX
MOVL AX, g(BP) MOVL AX, g(BP)
MOVL DX, g_m(AX) MOVL DX, g_m(AX)
MOVL BX, m_procid(DX) // m->procid = thread port (for debuggers) MOVL BX, m_procid(DX) // m->procid = thread port (for debuggers)
......
...@@ -308,12 +308,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$0 ...@@ -308,12 +308,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$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.
MOVQ fn+24(SP), DI // "func" MOVQ fn+24(SP), DI
MOVQ arg+16(SP), SI // "arg" MOVQ arg+16(SP), SI
MOVQ stk+8(SP), DX // stack MOVQ stk+8(SP), DX
MOVQ $0, R10 // "pthread", paranoia MOVQ $0x01000000, R8 // flags = PTHREAD_START_CUSTOM
MOVQ $0x01000000, R8 // flags = PTHREAD_START_CUSTOM MOVQ $0, R9 // paranoia
MOVQ $0, R9 // paranoia MOVQ $0, R10 // paranoia, "pthread"
MOVQ $(0x2000000+360), AX // bsdthread_create MOVQ $(0x2000000+360), AX // bsdthread_create
SYSCALL SYSCALL
JCC 4(PC) JCC 4(PC)
......
...@@ -320,26 +320,25 @@ sysctl_ret: ...@@ -320,26 +320,25 @@ sysctl_ret:
RET RET
// Thread related functions // Thread related functions
// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void)) // func bsdthread_create(stk, arg unsafe.Pointer, fn uintptr) int32
TEXT runtime·bsdthread_create(SB),NOSPLIT,$0 TEXT runtime·bsdthread_create(SB),NOSPLIT,$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.
MOVW fn+12(FP), R0 // "func" MOVW fn+8(FP), R0 // "func"
MOVW mm+4(FP), R1 // "arg" MOVW arg+4(FP), R1 // "arg"
MOVW stk+0(FP), R2 // stack MOVW stk+0(FP), R2 // stack
MOVW gg+8(FP), R3 // "pthread"
MOVW $0x01000000, R4 // flags = PTHREAD_START_CUSTOM MOVW $0x01000000, R4 // flags = PTHREAD_START_CUSTOM
MOVW $0, R5 // paranoia MOVW $0, R5 // paranoia
MOVW $SYS_bsdthread_create, R12 MOVW $SYS_bsdthread_create, R12
SWI $0x80 SWI $0x80
BCC create_ret BCC create_ret
RSB $0, R0, R0 RSB $0, R0, R0
MOVW R0, ret+16(FP) MOVW R0, ret+12(FP)
RET RET
create_ret: create_ret:
MOVW $0, R0 MOVW $0, R0
MOVW R0, ret+16(FP) MOVW R0, ret+12(FP)
RET RET
// The thread that bsdthread_create creates starts executing here, // The thread that bsdthread_create creates starts executing here,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment