1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:10:04 -07:00

runtime: unify C->Go ABI transitions on arm64

There are several of places that save and restore the C callee-saved registers,
the operation is the same everywhere, so this CL defines several macros
to do this, which will help reduce code redundancy and unify the operation.

This CL also replaced consecutive MOVD instructions with STP and LDP instructions
in several places where these macros do not apply.

Change-Id: I815f39fe484a9ab9b6bd157dfcbc8ad99c1420fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/374397
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
eric fang 2021-12-23 06:53:50 +00:00 committed by Eric Fang
parent 63169c8bdf
commit eee6f9f825
15 changed files with 205 additions and 708 deletions

View File

@ -311,74 +311,42 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
// spillArgs stores return values from registers to a *internal/abi.RegArgs in R20. // spillArgs stores return values from registers to a *internal/abi.RegArgs in R20.
TEXT ·spillArgs(SB),NOSPLIT,$0-0 TEXT ·spillArgs(SB),NOSPLIT,$0-0
MOVD R0, (0*8)(R20) STP (R0, R1), (0*8)(R20)
MOVD R1, (1*8)(R20) STP (R2, R3), (2*8)(R20)
MOVD R2, (2*8)(R20) STP (R4, R5), (4*8)(R20)
MOVD R3, (3*8)(R20) STP (R6, R7), (6*8)(R20)
MOVD R4, (4*8)(R20) STP (R8, R9), (8*8)(R20)
MOVD R5, (5*8)(R20) STP (R10, R11), (10*8)(R20)
MOVD R6, (6*8)(R20) STP (R12, R13), (12*8)(R20)
MOVD R7, (7*8)(R20) STP (R14, R15), (14*8)(R20)
MOVD R8, (8*8)(R20) FSTPD (F0, F1), (16*8)(R20)
MOVD R9, (9*8)(R20) FSTPD (F2, F3), (18*8)(R20)
MOVD R10, (10*8)(R20) FSTPD (F4, F5), (20*8)(R20)
MOVD R11, (11*8)(R20) FSTPD (F6, F7), (22*8)(R20)
MOVD R12, (12*8)(R20) FSTPD (F8, F9), (24*8)(R20)
MOVD R13, (13*8)(R20) FSTPD (F10, F11), (26*8)(R20)
MOVD R14, (14*8)(R20) FSTPD (F12, F13), (28*8)(R20)
MOVD R15, (15*8)(R20) FSTPD (F14, F15), (30*8)(R20)
FMOVD F0, (16*8)(R20)
FMOVD F1, (17*8)(R20)
FMOVD F2, (18*8)(R20)
FMOVD F3, (19*8)(R20)
FMOVD F4, (20*8)(R20)
FMOVD F5, (21*8)(R20)
FMOVD F6, (22*8)(R20)
FMOVD F7, (23*8)(R20)
FMOVD F8, (24*8)(R20)
FMOVD F9, (25*8)(R20)
FMOVD F10, (26*8)(R20)
FMOVD F11, (27*8)(R20)
FMOVD F12, (28*8)(R20)
FMOVD F13, (29*8)(R20)
FMOVD F14, (30*8)(R20)
FMOVD F15, (31*8)(R20)
RET RET
// unspillArgs loads args into registers from a *internal/abi.RegArgs in R20. // unspillArgs loads args into registers from a *internal/abi.RegArgs in R20.
TEXT ·unspillArgs(SB),NOSPLIT,$0-0 TEXT ·unspillArgs(SB),NOSPLIT,$0-0
MOVD (0*8)(R20), R0 LDP (0*8)(R20), (R0, R1)
MOVD (1*8)(R20), R1 LDP (2*8)(R20), (R2, R3)
MOVD (2*8)(R20), R2 LDP (4*8)(R20), (R4, R5)
MOVD (3*8)(R20), R3 LDP (6*8)(R20), (R6, R7)
MOVD (4*8)(R20), R4 LDP (8*8)(R20), (R8, R9)
MOVD (5*8)(R20), R5 LDP (10*8)(R20), (R10, R11)
MOVD (6*8)(R20), R6 LDP (12*8)(R20), (R12, R13)
MOVD (7*8)(R20), R7 LDP (14*8)(R20), (R14, R15)
MOVD (8*8)(R20), R8 FLDPD (16*8)(R20), (F0, F1)
MOVD (9*8)(R20), R9 FLDPD (18*8)(R20), (F2, F3)
MOVD (10*8)(R20), R10 FLDPD (20*8)(R20), (F4, F5)
MOVD (11*8)(R20), R11 FLDPD (22*8)(R20), (F6, F7)
MOVD (12*8)(R20), R12 FLDPD (24*8)(R20), (F8, F9)
MOVD (13*8)(R20), R13 FLDPD (26*8)(R20), (F10, F11)
MOVD (14*8)(R20), R14 FLDPD (28*8)(R20), (F12, F13)
MOVD (15*8)(R20), R15 FLDPD (30*8)(R20), (F14, F15)
FMOVD (16*8)(R20), F0
FMOVD (17*8)(R20), F1
FMOVD (18*8)(R20), F2
FMOVD (19*8)(R20), F3
FMOVD (20*8)(R20), F4
FMOVD (21*8)(R20), F5
FMOVD (22*8)(R20), F6
FMOVD (23*8)(R20), F7
FMOVD (24*8)(R20), F8
FMOVD (25*8)(R20), F9
FMOVD (26*8)(R20), F10
FMOVD (27*8)(R20), F11
FMOVD (28*8)(R20), F12
FMOVD (29*8)(R20), F13
FMOVD (30*8)(R20), F14
FMOVD (31*8)(R20), F15
RET RET
// reflectcall: call a function with the given argument list // reflectcall: call a function with the given argument list
@ -480,10 +448,8 @@ TEXT NAME(SB), WRAPPER, $MAXSIZE-48; \
// arguments in registers. // arguments in registers.
TEXT callRet<>(SB), NOSPLIT, $48-0 TEXT callRet<>(SB), NOSPLIT, $48-0
NO_LOCAL_POINTERS NO_LOCAL_POINTERS
MOVD R7, 8(RSP) STP (R7, R3), 8(RSP)
MOVD R3, 16(RSP) STP (R5, R4), 24(RSP)
MOVD R5, 24(RSP)
MOVD R4, 32(RSP)
MOVD R20, 40(RSP) MOVD R20, 40(RSP)
BL runtime·reflectcallmove(SB) BL runtime·reflectcallmove(SB)
RET RET
@ -1215,8 +1181,7 @@ TEXT ·checkASM(SB),NOSPLIT,$0-1
// calls to it directly and it does not use the stack-based Go ABI. // calls to it directly and it does not use the stack-based Go ABI.
TEXT runtime·gcWriteBarrier<ABIInternal>(SB),NOSPLIT,$200 TEXT runtime·gcWriteBarrier<ABIInternal>(SB),NOSPLIT,$200
// Save the registers clobbered by the fast path. // Save the registers clobbered by the fast path.
MOVD R0, 184(RSP) STP (R0, R1), 184(RSP)
MOVD R1, 192(RSP)
MOVD g_m(g), R0 MOVD g_m(g), R0
MOVD m_p(R0), R0 MOVD m_p(R0), R0
MOVD (p_wbBuf+wbBuf_next)(R0), R1 MOVD (p_wbBuf+wbBuf_next)(R0), R1
@ -1232,8 +1197,7 @@ TEXT runtime·gcWriteBarrier<ABIInternal>(SB),NOSPLIT,$200
// Is the buffer full? (flags set in CMP above) // Is the buffer full? (flags set in CMP above)
BEQ flush BEQ flush
ret: ret:
MOVD 184(RSP), R0 LDP 184(RSP), (R0, R1)
MOVD 192(RSP), R1
// Do the write. // Do the write.
MOVD R3, (R2) MOVD R3, (R2)
RET RET
@ -1241,32 +1205,20 @@ ret:
flush: flush:
// Save all general purpose registers since these could be // Save all general purpose registers since these could be
// clobbered by wbBufFlush and were not saved by the caller. // clobbered by wbBufFlush and were not saved by the caller.
MOVD R2, 8(RSP) // Also first argument to wbBufFlush // R0 and R1 already saved
MOVD R3, 16(RSP) // Also second argument to wbBufFlush STP (R2, R3), 1*8(RSP) // Also first and second arguments to wbBufFlush
// R0 already saved STP (R4, R5), 3*8(RSP)
// R1 already saved STP (R6, R7), 5*8(RSP)
MOVD R4, 24(RSP) STP (R8, R9), 7*8(RSP)
MOVD R5, 32(RSP) STP (R10, R11), 9*8(RSP)
MOVD R6, 40(RSP) STP (R12, R13), 11*8(RSP)
MOVD R7, 48(RSP) STP (R14, R15), 13*8(RSP)
MOVD R8, 56(RSP)
MOVD R9, 64(RSP)
MOVD R10, 72(RSP)
MOVD R11, 80(RSP)
MOVD R12, 88(RSP)
MOVD R13, 96(RSP)
MOVD R14, 104(RSP)
MOVD R15, 112(RSP)
// R16, R17 may be clobbered by linker trampoline // R16, R17 may be clobbered by linker trampoline
// R18 is unused. // R18 is unused.
MOVD R19, 120(RSP) STP (R19, R20), 15*8(RSP)
MOVD R20, 128(RSP) STP (R21, R22), 17*8(RSP)
MOVD R21, 136(RSP) STP (R23, R24), 19*8(RSP)
MOVD R22, 144(RSP) STP (R25, R26), 21*8(RSP)
MOVD R23, 152(RSP)
MOVD R24, 160(RSP)
MOVD R25, 168(RSP)
MOVD R26, 176(RSP)
// R27 is temp register. // R27 is temp register.
// R28 is g. // R28 is g.
// R29 is frame pointer (unused). // R29 is frame pointer (unused).
@ -1275,29 +1227,17 @@ flush:
// This takes arguments R2 and R3. // This takes arguments R2 and R3.
CALL runtime·wbBufFlush(SB) CALL runtime·wbBufFlush(SB)
LDP 1*8(RSP), (R2, R3)
MOVD 8(RSP), R2 LDP 3*8(RSP), (R4, R5)
MOVD 16(RSP), R3 LDP 5*8(RSP), (R6, R7)
MOVD 24(RSP), R4 LDP 7*8(RSP), (R8, R9)
MOVD 32(RSP), R5 LDP 9*8(RSP), (R10, R11)
MOVD 40(RSP), R6 LDP 11*8(RSP), (R12, R13)
MOVD 48(RSP), R7 LDP 13*8(RSP), (R14, R15)
MOVD 56(RSP), R8 LDP 15*8(RSP), (R19, R20)
MOVD 64(RSP), R9 LDP 17*8(RSP), (R21, R22)
MOVD 72(RSP), R10 LDP 19*8(RSP), (R23, R24)
MOVD 80(RSP), R11 LDP 21*8(RSP), (R25, R26)
MOVD 88(RSP), R12
MOVD 96(RSP), R13
MOVD 104(RSP), R14
MOVD 112(RSP), R15
MOVD 120(RSP), R19
MOVD 128(RSP), R20
MOVD 136(RSP), R21
MOVD 144(RSP), R22
MOVD 152(RSP), R23
MOVD 160(RSP), R24
MOVD 168(RSP), R25
MOVD 176(RSP), R26
JMP ret JMP ret
// Note: these functions use a special calling convention to save generated code space. // Note: these functions use a special calling convention to save generated code space.

View File

@ -0,0 +1,43 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Macros for transitioning from the host ABI to Go ABI0.
//
// These macros save and restore the callee-saved registers
// from the stack, but they don't adjust stack pointer, so
// the user should prepare stack space in advance.
// SAVE_R19_TO_R28(offset) saves R19 ~ R28 to the stack space
// of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP).
//
// SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space
// of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP).
//
// R29 is not saved because Go will save and restore it.
#define SAVE_R19_TO_R28(offset) \
STP (R19, R20), ((offset)+0*8)(RSP) \
STP (R21, R22), ((offset)+2*8)(RSP) \
STP (R23, R24), ((offset)+4*8)(RSP) \
STP (R25, R26), ((offset)+6*8)(RSP) \
STP (R27, g), ((offset)+8*8)(RSP)
#define RESTORE_R19_TO_R28(offset) \
LDP ((offset)+0*8)(RSP), (R19, R20) \
LDP ((offset)+2*8)(RSP), (R21, R22) \
LDP ((offset)+4*8)(RSP), (R23, R24) \
LDP ((offset)+6*8)(RSP), (R25, R26) \
LDP ((offset)+8*8)(RSP), (R27, g) /* R28 */
#define SAVE_F8_TO_F15(offset) \
FSTPD (F8, F9), ((offset)+0*8)(RSP) \
FSTPD (F10, F11), ((offset)+2*8)(RSP) \
FSTPD (F12, F13), ((offset)+4*8)(RSP) \
FSTPD (F14, F15), ((offset)+6*8)(RSP)
#define RESTORE_F8_TO_F15(offset) \
FLDPD ((offset)+0*8)(RSP), (F8, F9) \
FLDPD ((offset)+2*8)(RSP), (F10, F11) \
FLDPD ((offset)+4*8)(RSP), (F12, F13) \
FLDPD ((offset)+6*8)(RSP), (F14, F15)

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
#include "textflag.h" #include "textflag.h"
#include "abi_arm64.h"
// Called by C code generated by cmd/cgo. // Called by C code generated by cmd/cgo.
// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
@ -14,57 +15,23 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
* push 3 args for fn (R0, R1, R3), skipping R2. * push 3 args for fn (R0, R1, R3), skipping R2.
* Also note that at procedure entry in gc world, 8(RSP) will be the * Also note that at procedure entry in gc world, 8(RSP) will be the
* first arg. * first arg.
* TODO(minux): use LDP/STP here if it matters.
*/ */
SUB $(8*24), RSP SUB $(8*24), RSP
MOVD R0, (8*1)(RSP) STP (R0, R1), (8*1)(RSP)
MOVD R1, (8*2)(RSP)
MOVD R3, (8*3)(RSP) MOVD R3, (8*3)(RSP)
MOVD R19, (8*4)(RSP)
MOVD R20, (8*5)(RSP) SAVE_R19_TO_R28(8*4)
MOVD R21, (8*6)(RSP) SAVE_F8_TO_F15(8*14)
MOVD R22, (8*7)(RSP) STP (R29, R30), (8*22)(RSP)
MOVD R23, (8*8)(RSP)
MOVD R24, (8*9)(RSP)
MOVD R25, (8*10)(RSP)
MOVD R26, (8*11)(RSP)
MOVD R27, (8*12)(RSP)
MOVD g, (8*13)(RSP)
MOVD R29, (8*14)(RSP)
MOVD R30, (8*15)(RSP)
FMOVD F8, (8*16)(RSP)
FMOVD F9, (8*17)(RSP)
FMOVD F10, (8*18)(RSP)
FMOVD F11, (8*19)(RSP)
FMOVD F12, (8*20)(RSP)
FMOVD F13, (8*21)(RSP)
FMOVD F14, (8*22)(RSP)
FMOVD F15, (8*23)(RSP)
// Initialize Go ABI environment // Initialize Go ABI environment
BL runtime·load_g(SB) BL runtime·load_g(SB)
BL runtime·cgocallback(SB) BL runtime·cgocallback(SB)
MOVD (8*4)(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD (8*5)(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD (8*6)(RSP), R21 LDP (8*22)(RSP), (R29, R30)
MOVD (8*7)(RSP), R22
MOVD (8*8)(RSP), R23
MOVD (8*9)(RSP), R24
MOVD (8*10)(RSP), R25
MOVD (8*11)(RSP), R26
MOVD (8*12)(RSP), R27
MOVD (8*13)(RSP), g
MOVD (8*14)(RSP), R29
MOVD (8*15)(RSP), R30
FMOVD (8*16)(RSP), F8
FMOVD (8*17)(RSP), F9
FMOVD (8*18)(RSP), F10
FMOVD (8*19)(RSP), F11
FMOVD (8*20)(RSP), F12
FMOVD (8*21)(RSP), F13
FMOVD (8*22)(RSP), F14
FMOVD (8*23)(RSP), F15
ADD $(8*24), RSP ADD $(8*24), RSP
RET RET

View File

@ -8,6 +8,7 @@
#include "funcdata.h" #include "funcdata.h"
#include "textflag.h" #include "textflag.h"
#include "tls_arm64.h" #include "tls_arm64.h"
#include "cgo/abi_arm64.h"
// The following thunks allow calling the gcc-compiled race runtime directly // The following thunks allow calling the gcc-compiled race runtime directly
// from Go code without going all the way through cgo. // from Go code without going all the way through cgo.
@ -450,13 +451,12 @@ TEXT runtime·racecallbackthunk(SB), NOSPLIT|NOFRAME, $0
rest: rest:
// Save callee-saved registers (Go code won't respect that). // Save callee-saved registers (Go code won't respect that).
// 8(RSP) and 16(RSP) are for args passed through racecallback // 8(RSP) and 16(RSP) are for args passed through racecallback
SUB $112, RSP SUB $176, RSP
MOVD LR, 0(RSP) MOVD LR, 0(RSP)
STP (R19, R20), 24(RSP)
STP (R21, R22), 40(RSP) SAVE_R19_TO_R28(8*3)
STP (R23, R24), 56(RSP) SAVE_F8_TO_F15(8*13)
STP (R25, R26), 72(RSP) MOVD R29, (8*21)(RSP)
STP (R27, g), 88(RSP)
// Set g = g0. // Set g = g0.
// load_g will clobber R0, Save R0 // load_g will clobber R0, Save R0
MOVD R0, R13 MOVD R0, R13
@ -479,12 +479,10 @@ rest:
ret: ret:
// Restore callee-saved registers. // Restore callee-saved registers.
MOVD 0(RSP), LR MOVD 0(RSP), LR
LDP 24(RSP), (R19, R20) MOVD (8*21)(RSP), R29
LDP 40(RSP), (R21, R22) RESTORE_F8_TO_F15(8*13)
LDP 56(RSP), (R23, R24) RESTORE_R19_TO_R28(8*3)
LDP 72(RSP), (R25, R26) ADD $176, RSP
LDP 88(RSP), (R27, g)
ADD $112, RSP
JMP (LR) JMP (LR)
noswitch: noswitch:

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
TEXT _rt0_arm64_darwin(SB),NOSPLIT|NOFRAME,$0 TEXT _rt0_arm64_darwin(SB),NOSPLIT|NOFRAME,$0
MOVD $runtime·rt0_go(SB), R2 MOVD $runtime·rt0_go(SB), R2
@ -18,26 +19,10 @@ exit:
// //
// Note that all currently shipping darwin/arm64 platforms require // Note that all currently shipping darwin/arm64 platforms require
// cgo and do not support c-shared. // cgo and do not support c-shared.
TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$168 TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$152
// Preserve callee-save registers. // Preserve callee-save registers.
MOVD R19, 24(RSP) SAVE_R19_TO_R28(8)
MOVD R20, 32(RSP) SAVE_F8_TO_F15(88)
MOVD R21, 40(RSP)
MOVD R22, 48(RSP)
MOVD R23, 56(RSP)
MOVD R24, 64(RSP)
MOVD R25, 72(RSP)
MOVD R26, 80(RSP)
MOVD R27, 88(RSP)
MOVD g, 96(RSP)
FMOVD F8, 104(RSP)
FMOVD F9, 112(RSP)
FMOVD F10, 120(RSP)
FMOVD F11, 128(RSP)
FMOVD F12, 136(RSP)
FMOVD F13, 144(RSP)
FMOVD F14, 152(RSP)
FMOVD F15, 160(RSP)
MOVD R0, _rt0_arm64_darwin_lib_argc<>(SB) MOVD R0, _rt0_arm64_darwin_lib_argc<>(SB)
MOVD R1, _rt0_arm64_darwin_lib_argv<>(SB) MOVD R1, _rt0_arm64_darwin_lib_argv<>(SB)
@ -57,24 +42,8 @@ TEXT _rt0_arm64_darwin_lib(SB),NOSPLIT,$168
ADD $16, RSP ADD $16, RSP
// Restore callee-save registers. // Restore callee-save registers.
MOVD 24(RSP), R19 RESTORE_R19_TO_R28(8)
MOVD 32(RSP), R20 RESTORE_F8_TO_F15(88)
MOVD 40(RSP), R21
MOVD 48(RSP), R22
MOVD 56(RSP), R23
MOVD 64(RSP), R24
MOVD 72(RSP), R25
MOVD 80(RSP), R26
MOVD 88(RSP), R27
MOVD 96(RSP), g
FMOVD 104(RSP), F8
FMOVD 112(RSP), F9
FMOVD 120(RSP), F10
FMOVD 128(RSP), F11
FMOVD 136(RSP), F12
FMOVD 144(RSP), F13
FMOVD 152(RSP), F14
FMOVD 160(RSP), F15
RET RET

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
// On FreeBSD argc/argv are passed in R0, not RSP // On FreeBSD argc/argv are passed in R0, not RSP
TEXT _rt0_arm64_freebsd(SB),NOSPLIT|NOFRAME,$0 TEXT _rt0_arm64_freebsd(SB),NOSPLIT|NOFRAME,$0
@ -14,24 +15,8 @@ TEXT _rt0_arm64_freebsd(SB),NOSPLIT|NOFRAME,$0
// library is loaded. // library is loaded.
TEXT _rt0_arm64_freebsd_lib(SB),NOSPLIT,$184 TEXT _rt0_arm64_freebsd_lib(SB),NOSPLIT,$184
// Preserve callee-save registers. // Preserve callee-save registers.
MOVD R19, 24(RSP) SAVE_R19_TO_R28(24)
MOVD R20, 32(RSP) SAVE_F8_TO_F15(104)
MOVD R21, 40(RSP)
MOVD R22, 48(RSP)
MOVD R23, 56(RSP)
MOVD R24, 64(RSP)
MOVD R25, 72(RSP)
MOVD R26, 80(RSP)
MOVD R27, 88(RSP)
FMOVD F8, 96(RSP)
FMOVD F9, 104(RSP)
FMOVD F10, 112(RSP)
FMOVD F11, 120(RSP)
FMOVD F12, 128(RSP)
FMOVD F13, 136(RSP)
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
MOVD g, 160(RSP)
// Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
MOVD ZR, g MOVD ZR, g
@ -63,24 +48,8 @@ nocgo:
restore: restore:
// Restore callee-save registers. // Restore callee-save registers.
MOVD 24(RSP), R19 RESTORE_R19_TO_R28(24)
MOVD 32(RSP), R20 RESTORE_F8_TO_F15(104)
MOVD 40(RSP), R21
MOVD 48(RSP), R22
MOVD 56(RSP), R23
MOVD 64(RSP), R24
MOVD 72(RSP), R25
MOVD 80(RSP), R26
MOVD 88(RSP), R27
FMOVD 96(RSP), F8
FMOVD 104(RSP), F9
FMOVD 112(RSP), F10
FMOVD 120(RSP), F11
FMOVD 128(RSP), F12
FMOVD 136(RSP), F13
FMOVD 144(RSP), F14
FMOVD 152(RSP), F15
MOVD 160(RSP), g
RET RET
TEXT _rt0_arm64_freebsd_lib_go(SB),NOSPLIT,$0 TEXT _rt0_arm64_freebsd_lib_go(SB),NOSPLIT,$0

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
TEXT _rt0_arm64_linux(SB),NOSPLIT|NOFRAME,$0 TEXT _rt0_arm64_linux(SB),NOSPLIT|NOFRAME,$0
MOVD 0(RSP), R0 // argc MOVD 0(RSP), R0 // argc
@ -13,24 +14,8 @@ TEXT _rt0_arm64_linux(SB),NOSPLIT|NOFRAME,$0
// library is loaded. // library is loaded.
TEXT _rt0_arm64_linux_lib(SB),NOSPLIT,$184 TEXT _rt0_arm64_linux_lib(SB),NOSPLIT,$184
// Preserve callee-save registers. // Preserve callee-save registers.
MOVD R19, 24(RSP) SAVE_R19_TO_R28(24)
MOVD R20, 32(RSP) SAVE_F8_TO_F15(104)
MOVD R21, 40(RSP)
MOVD R22, 48(RSP)
MOVD R23, 56(RSP)
MOVD R24, 64(RSP)
MOVD R25, 72(RSP)
MOVD R26, 80(RSP)
MOVD R27, 88(RSP)
FMOVD F8, 96(RSP)
FMOVD F9, 104(RSP)
FMOVD F10, 112(RSP)
FMOVD F11, 120(RSP)
FMOVD F12, 128(RSP)
FMOVD F13, 136(RSP)
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
MOVD g, 160(RSP)
// Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
MOVD ZR, g MOVD ZR, g
@ -62,24 +47,8 @@ nocgo:
restore: restore:
// Restore callee-save registers. // Restore callee-save registers.
MOVD 24(RSP), R19 RESTORE_R19_TO_R28(24)
MOVD 32(RSP), R20 RESTORE_F8_TO_F15(104)
MOVD 40(RSP), R21
MOVD 48(RSP), R22
MOVD 56(RSP), R23
MOVD 64(RSP), R24
MOVD 72(RSP), R25
MOVD 80(RSP), R26
MOVD 88(RSP), R27
FMOVD 96(RSP), F8
FMOVD 104(RSP), F9
FMOVD 112(RSP), F10
FMOVD 120(RSP), F11
FMOVD 128(RSP), F12
FMOVD 136(RSP), F13
FMOVD 144(RSP), F14
FMOVD 152(RSP), F15
MOVD 160(RSP), g
RET RET
TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0 TEXT _rt0_arm64_linux_lib_go(SB),NOSPLIT,$0

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
TEXT _rt0_arm64_netbsd(SB),NOSPLIT|NOFRAME,$0 TEXT _rt0_arm64_netbsd(SB),NOSPLIT|NOFRAME,$0
MOVD 0(RSP), R0 // argc MOVD 0(RSP), R0 // argc
@ -13,24 +14,8 @@ TEXT _rt0_arm64_netbsd(SB),NOSPLIT|NOFRAME,$0
// library is loaded. // library is loaded.
TEXT _rt0_arm64_netbsd_lib(SB),NOSPLIT,$184 TEXT _rt0_arm64_netbsd_lib(SB),NOSPLIT,$184
// Preserve callee-save registers. // Preserve callee-save registers.
MOVD R19, 24(RSP) SAVE_R19_TO_R28(24)
MOVD R20, 32(RSP) SAVE_F8_TO_F15(104)
MOVD R21, 40(RSP)
MOVD R22, 48(RSP)
MOVD R23, 56(RSP)
MOVD R24, 64(RSP)
MOVD R25, 72(RSP)
MOVD R26, 80(RSP)
MOVD R27, 88(RSP)
FMOVD F8, 96(RSP)
FMOVD F9, 104(RSP)
FMOVD F10, 112(RSP)
FMOVD F11, 120(RSP)
FMOVD F12, 128(RSP)
FMOVD F13, 136(RSP)
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
MOVD g, 160(RSP)
// Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
MOVD ZR, g MOVD ZR, g
@ -62,24 +47,8 @@ nocgo:
restore: restore:
// Restore callee-save registers. // Restore callee-save registers.
MOVD 24(RSP), R19 RESTORE_R19_TO_R28(24)
MOVD 32(RSP), R20 RESTORE_F8_TO_F15(104)
MOVD 40(RSP), R21
MOVD 48(RSP), R22
MOVD 56(RSP), R23
MOVD 64(RSP), R24
MOVD 72(RSP), R25
MOVD 80(RSP), R26
MOVD 88(RSP), R27
FMOVD 96(RSP), F8
FMOVD 104(RSP), F9
FMOVD 112(RSP), F10
FMOVD 120(RSP), F11
FMOVD 128(RSP), F12
FMOVD 136(RSP), F13
FMOVD 144(RSP), F14
FMOVD 152(RSP), F15
MOVD 160(RSP), g
RET RET
TEXT _rt0_arm64_netbsd_lib_go(SB),NOSPLIT,$0 TEXT _rt0_arm64_netbsd_lib_go(SB),NOSPLIT,$0

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
// See comment in runtime/sys_openbsd_arm64.s re this construction. // See comment in runtime/sys_openbsd_arm64.s re this construction.
#define INVOKE_SYSCALL \ #define INVOKE_SYSCALL \
@ -19,24 +20,8 @@ TEXT _rt0_arm64_openbsd(SB),NOSPLIT|NOFRAME,$0
// library is loaded. // library is loaded.
TEXT _rt0_arm64_openbsd_lib(SB),NOSPLIT,$184 TEXT _rt0_arm64_openbsd_lib(SB),NOSPLIT,$184
// Preserve callee-save registers. // Preserve callee-save registers.
MOVD R19, 24(RSP) SAVE_R19_TO_R28(24)
MOVD R20, 32(RSP) SAVE_F8_TO_F15(104)
MOVD R21, 40(RSP)
MOVD R22, 48(RSP)
MOVD R23, 56(RSP)
MOVD R24, 64(RSP)
MOVD R25, 72(RSP)
MOVD R26, 80(RSP)
MOVD R27, 88(RSP)
FMOVD F8, 96(RSP)
FMOVD F9, 104(RSP)
FMOVD F10, 112(RSP)
FMOVD F11, 120(RSP)
FMOVD F12, 128(RSP)
FMOVD F13, 136(RSP)
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
MOVD g, 160(RSP)
// Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go // Initialize g as null in case of using g later e.g. sigaction in cgo_sigaction.go
MOVD ZR, g MOVD ZR, g
@ -68,24 +53,8 @@ nocgo:
restore: restore:
// Restore callee-save registers. // Restore callee-save registers.
MOVD 24(RSP), R19 RESTORE_R19_TO_R28(24)
MOVD 32(RSP), R20 RESTORE_F8_TO_F15(104)
MOVD 40(RSP), R21
MOVD 48(RSP), R22
MOVD 56(RSP), R23
MOVD 64(RSP), R24
MOVD 72(RSP), R25
MOVD 80(RSP), R26
MOVD 88(RSP), R27
FMOVD 96(RSP), F8
FMOVD 104(RSP), F9
FMOVD 112(RSP), F10
FMOVD 120(RSP), F11
FMOVD 128(RSP), F12
FMOVD 136(RSP), F13
FMOVD 144(RSP), F14
FMOVD 152(RSP), F15
MOVD 160(RSP), g
RET RET
TEXT _rt0_arm64_openbsd_lib_go(SB),NOSPLIT,$0 TEXT _rt0_arm64_openbsd_lib_go(SB),NOSPLIT,$0

View File

@ -9,6 +9,7 @@
#include "go_asm.h" #include "go_asm.h"
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME 0
@ -175,28 +176,11 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
BL (R11) BL (R11)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$192 TEXT runtime·sigtramp(SB),NOSPLIT,$176
// Save callee-save registers in the case of signal forwarding. // Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 . // Please refer to https://golang.org/issue/31827 .
MOVD R19, 8*4(RSP) SAVE_R19_TO_R28(8*4)
MOVD R20, 8*5(RSP) SAVE_F8_TO_F15(8*14)
MOVD R21, 8*6(RSP)
MOVD R22, 8*7(RSP)
MOVD R23, 8*8(RSP)
MOVD R24, 8*9(RSP)
MOVD R25, 8*10(RSP)
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)
FMOVD F10, 8*17(RSP)
FMOVD F11, 8*18(RSP)
FMOVD F12, 8*19(RSP)
FMOVD F13, 8*20(RSP)
FMOVD F14, 8*21(RSP)
FMOVD F15, 8*22(RSP)
// Save arguments. // Save arguments.
MOVW R0, (8*1)(RSP) // sig MOVW R0, (8*1)(RSP) // sig
@ -249,25 +233,8 @@ nog:
#endif #endif
// Restore callee-save registers. // Restore callee-save registers.
MOVD (8*4)(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD (8*5)(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD (8*6)(RSP), R21
MOVD (8*7)(RSP), R22
MOVD (8*8)(RSP), R23
MOVD (8*9)(RSP), R24
MOVD (8*10)(RSP), R25
MOVD (8*11)(RSP), R26
MOVD (8*12)(RSP), R27
MOVD (8*13)(RSP), g
MOVD (8*14)(RSP), R29
FMOVD (8*15)(RSP), F8
FMOVD (8*16)(RSP), F9
FMOVD (8*17)(RSP), F10
FMOVD (8*18)(RSP), F11
FMOVD (8*19)(RSP), F12
FMOVD (8*20)(RSP), F13
FMOVD (8*21)(RSP), F14
FMOVD (8*22)(RSP), F15
RET RET
@ -376,25 +343,8 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$160
// We are already on m's g0 stack. // We are already on m's g0 stack.
// Save callee-save registers. // Save callee-save registers.
MOVD R19, 8(RSP) SAVE_R19_TO_R28(8)
MOVD R20, 16(RSP) SAVE_F8_TO_F15(88)
MOVD R21, 24(RSP)
MOVD R22, 32(RSP)
MOVD R23, 40(RSP)
MOVD R24, 48(RSP)
MOVD R25, 56(RSP)
MOVD R26, 64(RSP)
MOVD R27, 72(RSP)
MOVD g, 80(RSP)
MOVD R29, 88(RSP)
FMOVD F8, 96(RSP)
FMOVD F9, 104(RSP)
FMOVD F10, 112(RSP)
FMOVD F11, 120(RSP)
FMOVD F12, 128(RSP)
FMOVD F13, 136(RSP)
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
MOVD m_g0(R0), g MOVD m_g0(R0), g
BL ·save_g(SB) BL ·save_g(SB)
@ -402,25 +352,8 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$160
BL runtime·mstart(SB) BL runtime·mstart(SB)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8(RSP), R19 RESTORE_R19_TO_R28(8)
MOVD 16(RSP), R20 RESTORE_F8_TO_F15(88)
MOVD 24(RSP), R21
MOVD 32(RSP), R22
MOVD 40(RSP), R23
MOVD 48(RSP), R24
MOVD 56(RSP), R25
MOVD 64(RSP), R26
MOVD 72(RSP), R27
MOVD 80(RSP), g
MOVD 88(RSP), R29
FMOVD 96(RSP), F8
FMOVD 104(RSP), F9
FMOVD 112(RSP), F10
FMOVD 120(RSP), F11
FMOVD 128(RSP), F12
FMOVD 136(RSP), F13
FMOVD 144(RSP), F14
FMOVD 152(RSP), F15
// Go is all done with this OS thread. // Go is all done with this OS thread.
// Tell pthread everything is ok (we never join with this thread, so // Tell pthread everything is ok (we never join with this thread, so

View File

@ -10,6 +10,7 @@
#include "go_asm.h" #include "go_asm.h"
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 4 #define CLOCK_MONOTONIC 4
@ -279,28 +280,11 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
RET RET
// func sigtramp() // func sigtramp()
TEXT runtime·sigtramp(SB),NOSPLIT,$192 TEXT runtime·sigtramp(SB),NOSPLIT,$176
// Save callee-save registers in the case of signal forwarding. // Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 . // Please refer to https://golang.org/issue/31827 .
MOVD R19, 8*4(RSP) SAVE_R19_TO_R28(8*4)
MOVD R20, 8*5(RSP) SAVE_F8_TO_F15(8*14)
MOVD R21, 8*6(RSP)
MOVD R22, 8*7(RSP)
MOVD R23, 8*8(RSP)
MOVD R24, 8*9(RSP)
MOVD R25, 8*10(RSP)
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)
FMOVD F10, 8*17(RSP)
FMOVD F11, 8*18(RSP)
FMOVD F12, 8*19(RSP)
FMOVD F13, 8*20(RSP)
FMOVD F14, 8*21(RSP)
FMOVD F15, 8*22(RSP)
// this might be called in external code context, // this might be called in external code context,
// where g is not set. // where g is not set.
@ -317,25 +301,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
BL (R0) BL (R0)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8*4(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD 8*5(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD 8*6(RSP), R21
MOVD 8*7(RSP), R22
MOVD 8*8(RSP), R23
MOVD 8*9(RSP), R24
MOVD 8*10(RSP), R25
MOVD 8*11(RSP), R26
MOVD 8*12(RSP), R27
MOVD 8*13(RSP), g
MOVD 8*14(RSP), R29
FMOVD 8*15(RSP), F8
FMOVD 8*16(RSP), F9
FMOVD 8*17(RSP), F10
FMOVD 8*18(RSP), F11
FMOVD 8*19(RSP), F12
FMOVD 8*20(RSP), F13
FMOVD 8*21(RSP), F14
FMOVD 8*22(RSP), F15
RET RET

View File

@ -9,6 +9,7 @@
#include "go_asm.h" #include "go_asm.h"
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
#define AT_FDCWD -100 #define AT_FDCWD -100
@ -444,28 +445,11 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
RET RET
// Called from c-abi, R0: sig, R1: info, R2: cxt // Called from c-abi, R0: sig, R1: info, R2: cxt
TEXT runtime·sigtramp(SB),NOSPLIT,$192 TEXT runtime·sigtramp(SB),NOSPLIT,$176
// Save callee-save registers in the case of signal forwarding. // Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 . // Please refer to https://golang.org/issue/31827 .
MOVD R19, 8*4(RSP) SAVE_R19_TO_R28(8*4)
MOVD R20, 8*5(RSP) SAVE_F8_TO_F15(8*14)
MOVD R21, 8*6(RSP)
MOVD R22, 8*7(RSP)
MOVD R23, 8*8(RSP)
MOVD R24, 8*9(RSP)
MOVD R25, 8*10(RSP)
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)
FMOVD F10, 8*17(RSP)
FMOVD F11, 8*18(RSP)
FMOVD F12, 8*19(RSP)
FMOVD F13, 8*20(RSP)
FMOVD F14, 8*21(RSP)
FMOVD F15, 8*22(RSP)
// this might be called in external code context, // this might be called in external code context,
// where g is not set. // where g is not set.
@ -481,52 +465,16 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
BL (R0) BL (R0)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8*4(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD 8*5(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD 8*6(RSP), R21
MOVD 8*7(RSP), R22
MOVD 8*8(RSP), R23
MOVD 8*9(RSP), R24
MOVD 8*10(RSP), R25
MOVD 8*11(RSP), R26
MOVD 8*12(RSP), R27
MOVD 8*13(RSP), g
MOVD 8*14(RSP), R29
FMOVD 8*15(RSP), F8
FMOVD 8*16(RSP), F9
FMOVD 8*17(RSP), F10
FMOVD 8*18(RSP), F11
FMOVD 8*19(RSP), F12
FMOVD 8*20(RSP), F13
FMOVD 8*21(RSP), F14
FMOVD 8*22(RSP), F15
RET RET
// Called from c-abi, R0: sig, R1: info, R2: cxt // Called from c-abi, R0: sig, R1: info, R2: cxt
TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$192 TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$176
// TODO(eric): In multiple places we need to save and restore the
// callee-saved registers, we can define a macro for this.
// Save callee-save registers because it's a callback from c code. // Save callee-save registers because it's a callback from c code.
MOVD R19, 8*4(RSP) SAVE_R19_TO_R28(8*4)
MOVD R20, 8*5(RSP) SAVE_F8_TO_F15(8*14)
MOVD R21, 8*6(RSP)
MOVD R22, 8*7(RSP)
MOVD R23, 8*8(RSP)
MOVD R24, 8*9(RSP)
MOVD R25, 8*10(RSP)
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)
FMOVD F10, 8*17(RSP)
FMOVD F11, 8*18(RSP)
FMOVD F12, 8*19(RSP)
FMOVD F13, 8*20(RSP)
FMOVD F14, 8*21(RSP)
FMOVD F15, 8*22(RSP)
MOVW R0, 8(RSP) // sig MOVW R0, 8(RSP) // sig
MOVD R1, 16(RSP) // info MOVD R1, 16(RSP) // info
@ -534,25 +482,8 @@ TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT,$192
CALL runtime·sigprofNonGo(SB) CALL runtime·sigprofNonGo(SB)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8*4(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD 8*5(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD 8*6(RSP), R21
MOVD 8*7(RSP), R22
MOVD 8*8(RSP), R23
MOVD 8*9(RSP), R24
MOVD 8*10(RSP), R25
MOVD 8*11(RSP), R26
MOVD 8*12(RSP), R27
MOVD 8*13(RSP), g
MOVD 8*14(RSP), R29
FMOVD 8*15(RSP), F8
FMOVD 8*16(RSP), F9
FMOVD 8*17(RSP), F10
FMOVD 8*18(RSP), F11
FMOVD 8*19(RSP), F12
FMOVD 8*20(RSP), F13
FMOVD 8*21(RSP), F14
FMOVD 8*22(RSP), F15
RET RET
// Called from c-abi, R0: sig, R1: info, R2: cxt // Called from c-abi, R0: sig, R1: info, R2: cxt

View File

@ -9,6 +9,7 @@
#include "go_asm.h" #include "go_asm.h"
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 3 #define CLOCK_MONOTONIC 3
@ -294,34 +295,17 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
BL (R11) BL (R11)
RET RET
TEXT runtime·sigtramp(SB),NOSPLIT,$192 TEXT runtime·sigtramp(SB),NOSPLIT,$176
// Save callee-save registers in the case of signal forwarding. // Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 . // Please refer to https://golang.org/issue/31827 .
MOVD R19, 8*4(RSP) SAVE_R19_TO_R28(8*4)
MOVD R20, 8*5(RSP) SAVE_F8_TO_F15(8*14)
MOVD R21, 8*6(RSP)
MOVD R22, 8*7(RSP)
MOVD R23, 8*8(RSP)
MOVD R24, 8*9(RSP)
MOVD R25, 8*10(RSP)
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
// Unclobber g for now (kernel uses it as ucontext ptr) // Unclobber g for now (kernel uses it as ucontext ptr)
// See https://github.com/golang/go/issues/30824#issuecomment-492772426 // See https://github.com/golang/go/issues/30824#issuecomment-492772426
// This is only correct in the non-cgo case. // This is only correct in the non-cgo case.
// XXX should use lwp_getprivate as suggested. // XXX should use lwp_getprivate as suggested.
// 8*36 is ucontext.uc_mcontext.__gregs[_REG_X28] // 8*36 is ucontext.uc_mcontext.__gregs[_REG_X28]
MOVD 8*36(g), g MOVD 8*36(g), g
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)
FMOVD F10, 8*17(RSP)
FMOVD F11, 8*18(RSP)
FMOVD F12, 8*19(RSP)
FMOVD F13, 8*20(RSP)
FMOVD F14, 8*21(RSP)
FMOVD F15, 8*22(RSP)
// this might be called in external code context, // this might be called in external code context,
// where g is not set. // where g is not set.
@ -338,25 +322,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
BL runtime·sigtrampgo(SB) BL runtime·sigtrampgo(SB)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8*4(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD 8*5(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD 8*6(RSP), R21
MOVD 8*7(RSP), R22
MOVD 8*8(RSP), R23
MOVD 8*9(RSP), R24
MOVD 8*10(RSP), R25
MOVD 8*11(RSP), R26
MOVD 8*12(RSP), R27
MOVD 8*13(RSP), g
MOVD 8*14(RSP), R29
FMOVD 8*15(RSP), F8
FMOVD 8*16(RSP), F9
FMOVD 8*17(RSP), F10
FMOVD 8*18(RSP), F11
FMOVD 8*19(RSP), F12
FMOVD 8*20(RSP), F13
FMOVD 8*21(RSP), F14
FMOVD 8*22(RSP), F15
RET RET

View File

@ -11,6 +11,7 @@
#include "go_asm.h" #include "go_asm.h"
#include "go_tls.h" #include "go_tls.h"
#include "textflag.h" #include "textflag.h"
#include "cgo/abi_arm64.h"
#define CLOCK_REALTIME $0 #define CLOCK_REALTIME $0
#define CLOCK_MONOTONIC $3 #define CLOCK_MONOTONIC $3
@ -18,30 +19,13 @@
// mstart_stub is the first function executed on a new thread started by pthread_create. // mstart_stub is the first function executed on a new thread started by pthread_create.
// It just does some low-level setup and then calls mstart. // It just does some low-level setup and then calls mstart.
// Note: called with the C calling convention. // Note: called with the C calling convention.
TEXT runtime·mstart_stub(SB),NOSPLIT,$160 TEXT runtime·mstart_stub(SB),NOSPLIT,$144
// R0 points to the m. // R0 points to the m.
// We are already on m's g0 stack. // We are already on m's g0 stack.
// Save callee-save registers. // Save callee-save registers.
MOVD R19, 8(RSP) SAVE_R19_TO_R28(8)
MOVD R20, 16(RSP) SAVE_F8_TO_F15(88)
MOVD R21, 24(RSP)
MOVD R22, 32(RSP)
MOVD R23, 40(RSP)
MOVD R24, 48(RSP)
MOVD R25, 56(RSP)
MOVD R26, 64(RSP)
MOVD R27, 72(RSP)
MOVD g, 80(RSP)
MOVD R29, 88(RSP)
FMOVD F8, 96(RSP)
FMOVD F9, 104(RSP)
FMOVD F10, 112(RSP)
FMOVD F11, 120(RSP)
FMOVD F12, 128(RSP)
FMOVD F13, 136(RSP)
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
MOVD m_g0(R0), g MOVD m_g0(R0), g
BL runtime·save_g(SB) BL runtime·save_g(SB)
@ -49,25 +33,8 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$160
BL runtime·mstart(SB) BL runtime·mstart(SB)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8(RSP), R19 RESTORE_R19_TO_R28(8)
MOVD 16(RSP), R20 RESTORE_F8_TO_F15(88)
MOVD 24(RSP), R21
MOVD 32(RSP), R22
MOVD 40(RSP), R23
MOVD 48(RSP), R24
MOVD 56(RSP), R25
MOVD 64(RSP), R26
MOVD 72(RSP), R27
MOVD 80(RSP), g
MOVD 88(RSP), R29
FMOVD 96(RSP), F8
FMOVD 104(RSP), F9
FMOVD 112(RSP), F10
FMOVD 120(RSP), F11
FMOVD 128(RSP), F12
FMOVD 136(RSP), F13
FMOVD 144(RSP), F14
FMOVD 152(RSP), F15
// Go is all done with this OS thread. // Go is all done with this OS thread.
// Tell pthread everything is ok (we never join with this thread, so // Tell pthread everything is ok (we never join with this thread, so
@ -87,25 +54,8 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
TEXT runtime·sigtramp(SB),NOSPLIT,$192 TEXT runtime·sigtramp(SB),NOSPLIT,$192
// Save callee-save registers in the case of signal forwarding. // Save callee-save registers in the case of signal forwarding.
// Please refer to https://golang.org/issue/31827 . // Please refer to https://golang.org/issue/31827 .
MOVD R19, 8*4(RSP) SAVE_R19_TO_R28(8*4)
MOVD R20, 8*5(RSP) SAVE_F8_TO_F15(8*14)
MOVD R21, 8*6(RSP)
MOVD R22, 8*7(RSP)
MOVD R23, 8*8(RSP)
MOVD R24, 8*9(RSP)
MOVD R25, 8*10(RSP)
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)
FMOVD F10, 8*17(RSP)
FMOVD F11, 8*18(RSP)
FMOVD F12, 8*19(RSP)
FMOVD F13, 8*20(RSP)
FMOVD F14, 8*21(RSP)
FMOVD F15, 8*22(RSP)
// If called from an external code context, g will not be set. // If called from an external code context, g will not be set.
// Save R0, since runtime·load_g will clobber it. // Save R0, since runtime·load_g will clobber it.
@ -117,25 +67,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
BL runtime·sigtrampgo(SB) BL runtime·sigtrampgo(SB)
// Restore callee-save registers. // Restore callee-save registers.
MOVD 8*4(RSP), R19 RESTORE_R19_TO_R28(8*4)
MOVD 8*5(RSP), R20 RESTORE_F8_TO_F15(8*14)
MOVD 8*6(RSP), R21
MOVD 8*7(RSP), R22
MOVD 8*8(RSP), R23
MOVD 8*9(RSP), R24
MOVD 8*10(RSP), R25
MOVD 8*11(RSP), R26
MOVD 8*12(RSP), R27
MOVD 8*13(RSP), g
MOVD 8*14(RSP), R29
FMOVD 8*15(RSP), F8
FMOVD 8*16(RSP), F9
FMOVD 8*17(RSP), F10
FMOVD 8*18(RSP), F11
FMOVD 8*19(RSP), F12
FMOVD 8*20(RSP), F13
FMOVD 8*21(RSP), F14
FMOVD 8*22(RSP), F15
RET RET

View File

@ -7,6 +7,7 @@
#include "textflag.h" #include "textflag.h"
#include "funcdata.h" #include "funcdata.h"
#include "time_windows.h" #include "time_windows.h"
#include "cgo/abi_arm64.h"
// Offsets into Thread Environment Block (pointer in R18) // Offsets into Thread Environment Block (pointer in R18)
#define TEB_error 0x68 #define TEB_error 0x68
@ -128,30 +129,6 @@ TEXT runtime·getlasterror(SB),NOSPLIT|NOFRAME,$0
MOVD R0, ret+0(FP) MOVD R0, ret+0(FP)
RET RET
#define SAVE_R19_TO_R28(offset) \
MOVD R19, savedR19+((offset)+0*8)(SP); \
MOVD R20, savedR20+((offset)+1*8)(SP); \
MOVD R21, savedR21+((offset)+2*8)(SP); \
MOVD R22, savedR22+((offset)+3*8)(SP); \
MOVD R23, savedR23+((offset)+4*8)(SP); \
MOVD R24, savedR24+((offset)+5*8)(SP); \
MOVD R25, savedR25+((offset)+6*8)(SP); \
MOVD R26, savedR26+((offset)+7*8)(SP); \
MOVD R27, savedR27+((offset)+8*8)(SP); \
MOVD g, savedR28+((offset)+9*8)(SP);
#define RESTORE_R19_TO_R28(offset) \
MOVD savedR19+((offset)+0*8)(SP), R19; \
MOVD savedR20+((offset)+1*8)(SP), R20; \
MOVD savedR21+((offset)+2*8)(SP), R21; \
MOVD savedR22+((offset)+3*8)(SP), R22; \
MOVD savedR23+((offset)+4*8)(SP), R23; \
MOVD savedR24+((offset)+5*8)(SP), R24; \
MOVD savedR25+((offset)+6*8)(SP), R25; \
MOVD savedR26+((offset)+7*8)(SP), R26; \
MOVD savedR27+((offset)+8*8)(SP), R27; \
MOVD savedR28+((offset)+9*8)(SP), g; /* R28 */
// Called by Windows as a Vectored Exception Handler (VEH). // Called by Windows as a Vectored Exception Handler (VEH).
// First argument is pointer to struct containing // First argument is pointer to struct containing
// exception record and context pointers. // exception record and context pointers.
@ -221,7 +198,8 @@ TEXT sigtramp_g0<>(SB),NOSPLIT,$128
NO_LOCAL_POINTERS NO_LOCAL_POINTERS
// Push C callee-save registers R19-R28. LR, FP already saved. // Push C callee-save registers R19-R28. LR, FP already saved.
SAVE_R19_TO_R28(-10*8) // These registers will occupy the upper 10 words of the frame.
SAVE_R19_TO_R28(8*7)
MOVD 0(R0), R5 // R5 = ExceptionPointers->ExceptionRecord MOVD 0(R0), R5 // R5 = ExceptionPointers->ExceptionRecord
MOVD 8(R0), R6 // R6 = ExceptionPointers->ContextRecord MOVD 8(R0), R6 // R6 = ExceptionPointers->ContextRecord
@ -275,7 +253,7 @@ TEXT sigtramp_g0<>(SB),NOSPLIT,$128
MOVD R2, context_pc(R6) MOVD R2, context_pc(R6)
return: return:
RESTORE_R19_TO_R28(-10*8) // smashes g RESTORE_R19_TO_R28(8*7) // smashes g
RET RET
// Trampoline to resume execution from exception handler. // Trampoline to resume execution from exception handler.
@ -317,18 +295,14 @@ TEXT runtime·callbackasm1(SB),NOSPLIT,$208-0
// but we are not called from Go so that space is ours to use, // but we are not called from Go so that space is ours to use,
// and we must to be contiguous with the stack arguments. // and we must to be contiguous with the stack arguments.
MOVD $arg0-(7*8)(SP), R14 MOVD $arg0-(7*8)(SP), R14
MOVD R0, (0*8)(R14) STP (R0, R1), (0*8)(R14)
MOVD R1, (1*8)(R14) STP (R2, R3), (2*8)(R14)
MOVD R2, (2*8)(R14) STP (R4, R5), (4*8)(R14)
MOVD R3, (3*8)(R14) STP (R6, R7), (6*8)(R14)
MOVD R4, (4*8)(R14)
MOVD R5, (5*8)(R14)
MOVD R6, (6*8)(R14)
MOVD R7, (7*8)(R14)
// Push C callee-save registers R19-R28. // Push C callee-save registers R19-R28.
// LR, FP already saved. // LR, FP already saved.
SAVE_R19_TO_R28(-18*8) SAVE_R19_TO_R28(8*9)
// Create a struct callbackArgs on our stack. // Create a struct callbackArgs on our stack.
MOVD $cbargs-(18*8+callbackArgs__size)(SP), R13 MOVD $cbargs-(18*8+callbackArgs__size)(SP), R13
@ -342,8 +316,7 @@ TEXT runtime·callbackasm1(SB),NOSPLIT,$208-0
MOVD $·callbackWrap<ABIInternal>(SB), R0 // PC of function to call, cgocallback takes an ABIInternal entry-point MOVD $·callbackWrap<ABIInternal>(SB), R0 // PC of function to call, cgocallback takes an ABIInternal entry-point
MOVD R13, R1 // frame (&callbackArgs{...}) MOVD R13, R1 // frame (&callbackArgs{...})
MOVD $0, R2 // context MOVD $0, R2 // context
MOVD R0, (1*8)(RSP) STP (R0, R1), (1*8)(RSP)
MOVD R1, (2*8)(RSP)
MOVD R2, (3*8)(RSP) MOVD R2, (3*8)(RSP)
BL runtime·cgocallback(SB) BL runtime·cgocallback(SB)
@ -351,13 +324,13 @@ TEXT runtime·callbackasm1(SB),NOSPLIT,$208-0
MOVD $cbargs-(18*8+callbackArgs__size)(SP), R13 MOVD $cbargs-(18*8+callbackArgs__size)(SP), R13
MOVD callbackArgs_result(R13), R0 MOVD callbackArgs_result(R13), R0
RESTORE_R19_TO_R28(-18*8) RESTORE_R19_TO_R28(8*9)
RET RET
// uint32 tstart_stdcall(M *newm); // uint32 tstart_stdcall(M *newm);
TEXT runtime·tstart_stdcall(SB),NOSPLIT,$96-0 TEXT runtime·tstart_stdcall(SB),NOSPLIT,$96-0
SAVE_R19_TO_R28(-10*8) SAVE_R19_TO_R28(8*3)
MOVD m_g0(R0), g MOVD m_g0(R0), g
MOVD R0, g_m(g) MOVD R0, g_m(g)
@ -374,7 +347,7 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT,$96-0
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)
RESTORE_R19_TO_R28(-10*8) RESTORE_R19_TO_R28(8*3)
// Exit the thread. // Exit the thread.
MOVD $0, R0 MOVD $0, R0