Commit 42122057 authored by Russ Cox's avatar Russ Cox

runtime, reflect: use correctly aligned stack frame sizes on arm64

arm64 requires either no stack frame or a frame with a size that is 8 mod 16
(adding the saved LR will make it 16-aligned).

The cmd/internal/obj/arm64 has been silently aligning frames, but it led to
a terrible bug when the compiler and obj disagreed on the frame size,
and it's just generally confusing, so we're going to make misaligned frames
an error instead of something that is silently changed.

This CL prepares by updating assembly files.
Note that the changes in this CL are already being done silently by
cmd/internal/obj/arm64, so there is no semantic effect here,
just a clarity effect.

For #9880.

Change-Id: Ibd6928dc5fdcd896c2bacd0291bf26b364591e28
Reviewed-on: https://go-review.googlesource.com/12845Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 3952057c
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
// See the comment on the declaration of makeFuncStub in makefunc.go // See the comment on the declaration of makeFuncStub in makefunc.go
// for more details. // for more details.
// No arg size here, runtime pulls arg map out of the func value. // No arg size here, runtime pulls arg map out of the func value.
TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$16 TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$24
NO_LOCAL_POINTERS NO_LOCAL_POINTERS
MOVD R26, 8(RSP) MOVD R26, 8(RSP)
MOVD $argframe+0(FP), R3 MOVD $argframe+0(FP), R3
...@@ -21,7 +21,7 @@ TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$16 ...@@ -21,7 +21,7 @@ TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$16
// See the comment on the declaration of methodValueCall in makefunc.go // See the comment on the declaration of methodValueCall in makefunc.go
// for more details. // for more details.
// No arg size here; runtime pulls arg map out of the func value. // No arg size here; runtime pulls arg map out of the func value.
TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$16 TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$24
NO_LOCAL_POINTERS NO_LOCAL_POINTERS
MOVD R26, 8(RSP) MOVD R26, 8(RSP)
MOVD $argframe+0(FP), R3 MOVD $argframe+0(FP), R3
......
...@@ -424,33 +424,35 @@ end: \ ...@@ -424,33 +424,35 @@ end: \
BL runtime·callwritebarrier(SB); \ BL runtime·callwritebarrier(SB); \
RET RET
CALLFNcall16, 16) // These have 8 added to make the overall frame size a multiple of 16,
CALLFNcall32, 32) // as required by the ABI. (There is another +8 for the saved LR.)
CALLFNcall64, 64) CALLFNcall16, 24 )
CALLFNcall128, 128) CALLFNcall32, 40 )
CALLFNcall256, 256) CALLFNcall64, 72 )
CALLFNcall512, 512) CALLFNcall128, 136 )
CALLFNcall1024, 1024) CALLFNcall256, 264 )
CALLFNcall2048, 2048) CALLFNcall512, 520 )
CALLFNcall4096, 4096) CALLFNcall1024, 1032 )
CALLFNcall8192, 8192) CALLFNcall2048, 2056 )
CALLFNcall16384, 16384) CALLFNcall4096, 4104 )
CALLFNcall32768, 32768) CALLFNcall8192, 8200 )
CALLFNcall65536, 65536) CALLFNcall16384, 16392 )
CALLFNcall131072, 131072) CALLFNcall32768, 32776 )
CALLFNcall262144, 262144) CALLFNcall65536, 65544 )
CALLFNcall524288, 524288) CALLFNcall131072, 131080 )
CALLFNcall1048576, 1048576) CALLFNcall262144, 262152 )
CALLFNcall2097152, 2097152) CALLFNcall524288, 524296 )
CALLFNcall4194304, 4194304) CALLFNcall1048576, 1048584 )
CALLFNcall8388608, 8388608) CALLFNcall2097152, 2097160 )
CALLFNcall16777216, 16777216) CALLFNcall4194304, 4194312 )
CALLFNcall33554432, 33554432) CALLFNcall8388608, 8388616 )
CALLFNcall67108864, 67108864) CALLFNcall16777216, 16777224 )
CALLFNcall134217728, 134217728) CALLFNcall33554432, 33554440 )
CALLFNcall268435456, 268435456) CALLFNcall67108864, 67108872 )
CALLFNcall536870912, 536870912) CALLFNcall134217728, 134217736 )
CALLFNcall1073741824, 1073741824) CALLFNcall268435456, 268435464 )
CALLFNcall536870912, 536870920 )
CALLFNcall1073741824, 1073741832 )
// bool cas(uint32 *ptr, uint32 old, uint32 new) // bool cas(uint32 *ptr, uint32 old, uint32 new)
// Atomically: // Atomically:
...@@ -613,7 +615,7 @@ TEXT runtime·cgocallback(SB),NOSPLIT,$24-24 ...@@ -613,7 +615,7 @@ TEXT runtime·cgocallback(SB),NOSPLIT,$24-24
// cgocallback_gofunc(FuncVal*, void *frame, uintptr framesize) // cgocallback_gofunc(FuncVal*, void *frame, uintptr framesize)
// See cgocall.go for more details. // See cgocall.go for more details.
TEXT ·cgocallback_gofunc(SB),NOSPLIT,$16-24 TEXT ·cgocallback_gofunc(SB),NOSPLIT,$24-24
NO_LOCAL_POINTERS NO_LOCAL_POINTERS
// Load g from thread-local storage. // Load g from thread-local storage.
...@@ -721,7 +723,7 @@ droppedm: ...@@ -721,7 +723,7 @@ droppedm:
// Called from cgo wrappers, this function returns g->m->curg.stack.hi. // Called from cgo wrappers, this function returns g->m->curg.stack.hi.
// Must obey the gcc calling convention. // Must obey the gcc calling convention.
TEXT _cgo_topofstack(SB),NOSPLIT,$16 TEXT _cgo_topofstack(SB),NOSPLIT,$24
// g (R28) and REGTMP (R27) might be clobbered by load_g. They // g (R28) and REGTMP (R27) might be clobbered by load_g. They
// are callee-save in the gcc calling convention, so save them. // are callee-save in the gcc calling convention, so save them.
MOVD R27, savedR27-8(SP) MOVD R27, savedR27-8(SP)
......
...@@ -115,7 +115,7 @@ TEXT runtime·getrlimit(SB),NOSPLIT,$-8-20 ...@@ -115,7 +115,7 @@ TEXT runtime·getrlimit(SB),NOSPLIT,$-8-20
MOVW R0, ret+16(FP) MOVW R0, ret+16(FP)
RET RET
TEXT runtime·usleep(SB),NOSPLIT,$16-4 TEXT runtime·usleep(SB),NOSPLIT,$24-4
MOVWU usec+0(FP), R3 MOVWU usec+0(FP), R3
MOVD R3, R5 MOVD R3, R5
MOVW $1000000, R4 MOVW $1000000, R4
...@@ -180,7 +180,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$-8-28 ...@@ -180,7 +180,7 @@ TEXT runtime·mincore(SB),NOSPLIT,$-8-28
RET RET
// func now() (sec int64, nsec int32) // func now() (sec int64, nsec int32)
TEXT time·now(SB),NOSPLIT,$16-12 TEXT time·now(SB),NOSPLIT,$24-12
MOVD RSP, R0 MOVD RSP, R0
MOVD $0, R1 MOVD $0, R1
MOVD $SYS_gettimeofday, R8 MOVD $SYS_gettimeofday, R8
...@@ -193,7 +193,7 @@ TEXT time·now(SB),NOSPLIT,$16-12 ...@@ -193,7 +193,7 @@ TEXT time·now(SB),NOSPLIT,$16-12
MOVW R5, nsec+8(FP) MOVW R5, nsec+8(FP)
RET RET
TEXT runtime·nanotime(SB),NOSPLIT,$16-8 TEXT runtime·nanotime(SB),NOSPLIT,$24-8
MOVW $1, R0 // CLOCK_MONOTONIC MOVW $1, R0 // CLOCK_MONOTONIC
MOVD RSP, R1 MOVD RSP, R1
MOVD $SYS_clock_gettime, R8 MOVD $SYS_clock_gettime, R8
......
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