Commit d8fd8d89 authored by Shenghou Ma's avatar Shenghou Ma

runtime: use m and g, instead of R9 and R10, in ARM assembly files

also don't clobber R9 if it is about to crash.

In response to https://golang.org/cl/9251043/#msg2.

R=golang-dev, khr, khr, dave
CC=golang-dev
https://golang.org/cl/9778046
parent 828c68f8
...@@ -26,32 +26,30 @@ TEXT runtime·thr_new(SB),7,$0 ...@@ -26,32 +26,30 @@ TEXT runtime·thr_new(SB),7,$0
RET RET
TEXT runtime·thr_start(SB),7,$0 TEXT runtime·thr_start(SB),7,$0
MOVW R0, R9 // m MOVW R0, m
// TODO(minux): set up TLS?
// set up g // set up g
MOVW m_g0(R9), R10 MOVW m_g0(m), g
BL runtime·emptyfunc(SB) // fault if stack check is wrong BL runtime·emptyfunc(SB) // fault if stack check is wrong
BL runtime·mstart(SB) BL runtime·mstart(SB)
MOVW $2, R9 // crash (not reached) MOVW $2, R8 // crash (not reached)
MOVW R9, (R9) MOVW R8, (R8)
RET RET
// Exit the entire program (like C exit) // Exit the entire program (like C exit)
TEXT runtime·exit(SB),7,$-8 TEXT runtime·exit(SB),7,$-8
MOVW 0(FP), R0 // arg 1 exit status MOVW 0(FP), R0 // arg 1 exit status
SWI $1 SWI $1
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·exit1(SB),7,$-8 TEXT runtime·exit1(SB),7,$-8
MOVW 0(FP), R0 // arg 1 exit status MOVW 0(FP), R0 // arg 1 exit status
SWI $431 SWI $431
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·open(SB),7,$-8 TEXT runtime·open(SB),7,$-8
...@@ -146,8 +144,8 @@ TEXT runtime·sigaction(SB),7,$-8 ...@@ -146,8 +144,8 @@ TEXT runtime·sigaction(SB),7,$-8
MOVW 4(FP), R1 // arg 2 act MOVW 4(FP), R1 // arg 2 act
MOVW 8(FP), R2 // arg 3 oact MOVW 8(FP), R2 // arg 3 oact
SWI $416 SWI $416
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·sigtramp(SB),7,$24 TEXT runtime·sigtramp(SB),7,$24
...@@ -166,11 +164,11 @@ TEXT runtime·sigtramp(SB),7,$24 ...@@ -166,11 +164,11 @@ TEXT runtime·sigtramp(SB),7,$24
RET RET
// save g // save g
MOVW R10, R4 MOVW g, R4
MOVW R10, 20(R13) MOVW g, 20(R13)
// g = m->signal // g = m->signal
MOVW m_gsignal(R9), R10 MOVW m_gsignal(m), g
// R0 is already saved // R0 is already saved
MOVW R1, 8(R13) // info MOVW R1, 8(R13) // info
...@@ -180,7 +178,7 @@ TEXT runtime·sigtramp(SB),7,$24 ...@@ -180,7 +178,7 @@ TEXT runtime·sigtramp(SB),7,$24
BL runtime·sighandler(SB) BL runtime·sighandler(SB)
// restore g // restore g
MOVW 20(R13), R10 MOVW 20(R13), g
RET RET
TEXT runtime·mmap(SB),7,$12 TEXT runtime·mmap(SB),7,$12
...@@ -205,8 +203,8 @@ TEXT runtime·munmap(SB),7,$0 ...@@ -205,8 +203,8 @@ TEXT runtime·munmap(SB),7,$0
MOVW 0(FP), R0 // arg 1 addr MOVW 0(FP), R0 // arg 1 addr
MOVW 4(FP), R1 // arg 2 len MOVW 4(FP), R1 // arg 2 len
SWI $73 SWI $73
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·madvise(SB),7,$0 TEXT runtime·madvise(SB),7,$0
...@@ -221,8 +219,8 @@ TEXT runtime·sigaltstack(SB),7,$-8 ...@@ -221,8 +219,8 @@ TEXT runtime·sigaltstack(SB),7,$-8
MOVW new+0(FP), R0 MOVW new+0(FP), R0
MOVW old+4(FP), R1 MOVW old+4(FP), R1
SWI $53 SWI $53
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·usleep(SB),7,$16 TEXT runtime·usleep(SB),7,$16
...@@ -265,8 +263,8 @@ TEXT runtime·sigprocmask(SB),7,$0 ...@@ -265,8 +263,8 @@ TEXT runtime·sigprocmask(SB),7,$0
MOVW 0(FP), R1 // arg 2 - set MOVW 0(FP), R1 // arg 2 - set
MOVW 4(FP), R2 // arg 3 - oset MOVW 4(FP), R2 // arg 3 - oset
SWI $340 // sys_sigprocmask SWI $340 // sys_sigprocmask
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·casp(SB),7,$0 TEXT runtime·casp(SB),7,$0
......
...@@ -127,8 +127,8 @@ TEXT runtime·munmap(SB),7,$0 ...@@ -127,8 +127,8 @@ TEXT runtime·munmap(SB),7,$0
SWI $0 SWI $0
MOVW $0xfffff001, R6 MOVW $0xfffff001, R6
CMP R6, R0 CMP R6, R0
MOVW.HI $0, R9 // crash on syscall failure MOVW.HI $0, R8 // crash on syscall failure
MOVW.HI R9, (R9) MOVW.HI R8, (R8)
RET RET
TEXT runtime·madvise(SB),7,$0 TEXT runtime·madvise(SB),7,$0
...@@ -278,8 +278,8 @@ TEXT runtime·sigaltstack(SB),7,$0 ...@@ -278,8 +278,8 @@ TEXT runtime·sigaltstack(SB),7,$0
SWI $0 SWI $0
MOVW $0xfffff001, R6 MOVW $0xfffff001, R6
CMP R6, R0 CMP R6, R0
MOVW.HI $0, R9 // crash on syscall failure MOVW.HI $0, R8 // crash on syscall failure
MOVW.HI R9, (R9) MOVW.HI R8, (R8)
RET RET
TEXT runtime·sigtramp(SB),7,$24 TEXT runtime·sigtramp(SB),7,$24
......
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
TEXT runtime·exit(SB),7,$-4 TEXT runtime·exit(SB),7,$-4
MOVW 0(FP), R0 // arg 1 exit status MOVW 0(FP), R0 // arg 1 exit status
SWI $0xa00001 SWI $0xa00001
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·exit1(SB),7,$-4 TEXT runtime·exit1(SB),7,$-4
SWI $0xa00136 // sys__lwp_exit SWI $0xa00136 // sys__lwp_exit
MOVW $1, R9 // crash MOVW $1, R8 // crash
MOVW R9, (R9) MOVW R8, (R8)
RET RET
TEXT runtime·open(SB),7,$-8 TEXT runtime·open(SB),7,$-8
...@@ -79,13 +79,13 @@ TEXT runtime·lwp_self(SB),7,$0 ...@@ -79,13 +79,13 @@ TEXT runtime·lwp_self(SB),7,$0
RET RET
TEXT runtime·lwp_tramp(SB),7,$0 TEXT runtime·lwp_tramp(SB),7,$0
MOVW R0, R9 // m MOVW R0, m
MOVW R1, R10 // g MOVW R1, g
BL runtime·emptyfunc(SB) // fault if stack check is wrong BL runtime·emptyfunc(SB) // fault if stack check is wrong
BL (R2) BL (R2)
MOVW $2, R9 // crash (not reached) MOVW $2, R8 // crash (not reached)
MOVW R9, (R9) MOVW R8, (R8)
RET RET
TEXT runtime·usleep(SB),7,$16 TEXT runtime·usleep(SB),7,$16
...@@ -160,8 +160,8 @@ TEXT runtime·nanotime(SB), 7, $32 ...@@ -160,8 +160,8 @@ TEXT runtime·nanotime(SB), 7, $32
TEXT runtime·getcontext(SB),7,$-4 TEXT runtime·getcontext(SB),7,$-4
MOVW 0(FP), R0 // arg 1 - context MOVW 0(FP), R0 // arg 1 - context
SWI $0xa00133 // sys_getcontext SWI $0xa00133 // sys_getcontext
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·sigprocmask(SB),7,$0 TEXT runtime·sigprocmask(SB),7,$0
...@@ -169,8 +169,8 @@ TEXT runtime·sigprocmask(SB),7,$0 ...@@ -169,8 +169,8 @@ TEXT runtime·sigprocmask(SB),7,$0
MOVW 4(FP), R1 // arg 2 - set MOVW 4(FP), R1 // arg 2 - set
MOVW 8(FP), R2 // arg 3 - oset MOVW 8(FP), R2 // arg 3 - oset
SWI $0xa00125 // sys_sigprocmask SWI $0xa00125 // sys_sigprocmask
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·sigreturn_tramp(SB),7,$-4 TEXT runtime·sigreturn_tramp(SB),7,$-4
...@@ -193,8 +193,8 @@ TEXT runtime·sigaction(SB),7,$4 ...@@ -193,8 +193,8 @@ TEXT runtime·sigaction(SB),7,$4
ADD $4, R13 // pass arg 5 on stack ADD $4, R13 // pass arg 5 on stack
SWI $0xa00154 // sys___sigaction_sigtramp SWI $0xa00154 // sys___sigaction_sigtramp
SUB $4, R13 SUB $4, R13
MOVW.CS $3, R9 // crash on syscall failure MOVW.CS $3, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·sigtramp(SB),7,$24 TEXT runtime·sigtramp(SB),7,$24
...@@ -213,11 +213,11 @@ TEXT runtime·sigtramp(SB),7,$24 ...@@ -213,11 +213,11 @@ TEXT runtime·sigtramp(SB),7,$24
RET RET
// save g // save g
MOVW R10, R4 MOVW g, R4
MOVW R10, 20(R13) MOVW g, 20(R13)
// g = m->signal // g = m->signal
MOVW m_gsignal(R9), R10 MOVW m_gsignal(m), g
// R0 is already saved // R0 is already saved
MOVW R1, 8(R13) // info MOVW R1, 8(R13) // info
...@@ -230,7 +230,7 @@ TEXT runtime·sigtramp(SB),7,$24 ...@@ -230,7 +230,7 @@ TEXT runtime·sigtramp(SB),7,$24
BL runtime·sighandler(SB) BL runtime·sighandler(SB)
// restore g // restore g
MOVW 20(R13), R10 MOVW 20(R13), g
RET RET
TEXT runtime·mmap(SB),7,$12 TEXT runtime·mmap(SB),7,$12
...@@ -255,8 +255,8 @@ TEXT runtime·munmap(SB),7,$0 ...@@ -255,8 +255,8 @@ TEXT runtime·munmap(SB),7,$0
MOVW 0(FP), R0 // arg 1 - addr MOVW 0(FP), R0 // arg 1 - addr
MOVW 4(FP), R1 // arg 2 - len MOVW 4(FP), R1 // arg 2 - len
SWI $0xa00049 // sys_munmap SWI $0xa00049 // sys_munmap
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·madvise(SB),7,$0 TEXT runtime·madvise(SB),7,$0
...@@ -271,8 +271,8 @@ TEXT runtime·sigaltstack(SB),7,$-4 ...@@ -271,8 +271,8 @@ TEXT runtime·sigaltstack(SB),7,$-4
MOVW 0(FP), R0 // arg 1 - nss MOVW 0(FP), R0 // arg 1 - nss
MOVW 4(FP), R1 // arg 2 - oss MOVW 4(FP), R1 // arg 2 - oss
SWI $0xa00119 // sys___sigaltstack14 SWI $0xa00119 // sys___sigaltstack14
MOVW.CS $0, R9 // crash on syscall failure MOVW.CS $0, R8 // crash on syscall failure
MOVW.CS R9, (R9) MOVW.CS R8, (R8)
RET RET
TEXT runtime·sysctl(SB),7,$8 TEXT runtime·sysctl(SB),7,$8
......
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