Skip to content

Commit

Permalink
runtime: use NOFRAME on mips and mips64
Browse files Browse the repository at this point in the history
This replaces frame size -4/-8 with the NOFRAME flag in mips and
mips64 assembly.

This was automated with:

sed -i -e 's/\(^TEXT.*[A-Z]\),\( *\)\$-[84]/\1|NOFRAME,\2$0/' $(find -name '*_mips*.s')

Plus a manual fix to mkduff.go.

The go binary is identical on both architectures before and after this
change.

Change-Id: I0310384d1a584118c41d1cd3a042bb8ea7227efb
Reviewed-on: https://go-review.googlesource.com/92044
Run-TryBot: Austin Clements <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Cherry Zhang <[email protected]>
  • Loading branch information
aclements committed Feb 12, 2018
1 parent beeabbc commit dfbf568
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion misc/cgo/test/issue9400/asm_mipsx.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "textflag.h"

TEXT ·RewindAndSetgid(SB),NOSPLIT,$-4-0
TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
// Rewind stack pointer so anything that happens on the stack
// will clobber the test pattern created by the caller
ADDU $(1024*8), R29
Expand Down
34 changes: 17 additions & 17 deletions src/runtime/asm_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ nocgo:
DATA runtime·mainPC+0(SB)/8,$runtime·main(SB)
GLOBL runtime·mainPC(SB),RODATA,$8

TEXT runtime·breakpoint(SB),NOSPLIT,$-8-0
TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0
MOVV R0, 2(R0) // TODO: TD
RET

TEXT runtime·asminit(SB),NOSPLIT,$-8-0
TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0
RET

/*
Expand All @@ -91,7 +91,7 @@ TEXT runtime·asminit(SB),NOSPLIT,$-8-0

// void gosave(Gobuf*)
// save state in Gobuf; setjmp
TEXT runtime·gosave(SB), NOSPLIT, $-8-8
TEXT runtime·gosave(SB), NOSPLIT|NOFRAME, $0-8
MOVV buf+0(FP), R1
MOVV R29, gobuf_sp(R1)
MOVV R31, gobuf_pc(R1)
Expand Down Expand Up @@ -127,7 +127,7 @@ TEXT runtime·gogo(SB), NOSPLIT, $16-8
// Switch to m->g0's stack, call fn(g).
// Fn must never return. It should gogo(&g->sched)
// to keep running g.
TEXT runtime·mcall(SB), NOSPLIT, $-8-8
TEXT runtime·mcall(SB), NOSPLIT|NOFRAME, $0-8
// Save caller state in g->sched
MOVV R29, (g_sched+gobuf_sp)(g)
MOVV R31, (g_sched+gobuf_pc)(g)
Expand Down Expand Up @@ -233,7 +233,7 @@ noswitch:
// the top of a stack (for example, morestack calling newstack
// calling the scheduler calling newm calling gc), so we must
// record an argument size. For that purpose, it has no arguments.
TEXT runtime·morestack(SB),NOSPLIT,$-8-0
TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
// Cannot grow scheduler stack (m->g0).
MOVV g_m(g), R7
MOVV m_g0(R7), R8
Expand Down Expand Up @@ -273,7 +273,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$-8-0
// is still in this function, and not the beginning of the next.
UNDEF

TEXT runtime·morestack_noctxt(SB),NOSPLIT,$-8-0
TEXT runtime·morestack_noctxt(SB),NOSPLIT|NOFRAME,$0-0
MOVV R0, REGCTXT
JMP runtime·morestack(SB)

Expand All @@ -294,7 +294,7 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$-8-0
TEXT reflect·call(SB), NOSPLIT, $0-0
JMP ·reflectcall(SB)

TEXT ·reflectcall(SB), NOSPLIT, $-8-32
TEXT ·reflectcall(SB), NOSPLIT|NOFRAME, $0-32
MOVWU argsize+24(FP), R1
DISPATCH(runtime·call32, 32)
DISPATCH(runtime·call64, 64)
Expand Down Expand Up @@ -405,7 +405,7 @@ TEXT runtime·procyield(SB),NOSPLIT,$0-0
// 1. grab stored LR for caller
// 2. sub 8 bytes to get back to JAL deferreturn
// 3. JMP to fn
TEXT runtime·jmpdefer(SB), NOSPLIT, $-8-16
TEXT runtime·jmpdefer(SB), NOSPLIT|NOFRAME, $0-16
MOVV 0(R29), R31
ADDV $-8, R31

Expand All @@ -417,7 +417,7 @@ TEXT runtime·jmpdefer(SB), NOSPLIT, $-8-16
JMP (R4)

// Save state of caller into g->sched. Smashes R1.
TEXT gosave<>(SB),NOSPLIT,$-8
TEXT gosave<>(SB),NOSPLIT|NOFRAME,$0
MOVV R31, (g_sched+gobuf_pc)(g)
MOVV R29, (g_sched+gobuf_sp)(g)
MOVV R0, (g_sched+gobuf_lr)(g)
Expand Down Expand Up @@ -607,27 +607,27 @@ TEXT setg_gcc<>(SB),NOSPLIT,$0-0
JAL runtime·save_g(SB)
RET

TEXT runtime·getcallerpc(SB),NOSPLIT,$-8-8
TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-8
MOVV 0(R29), R1 // LR saved by caller
MOVV R1, ret+0(FP)
RET

TEXT runtime·abort(SB),NOSPLIT,$-8-0
TEXT runtime·abort(SB),NOSPLIT|NOFRAME,$0-0
MOVW (R0), R0
UNDEF

// AES hashing not implemented for mips64
TEXT runtime·aeshash(SB),NOSPLIT,$-8-0
TEXT runtime·aeshash(SB),NOSPLIT|NOFRAME,$0-0
MOVW (R0), R1
TEXT runtime·aeshash32(SB),NOSPLIT,$-8-0
TEXT runtime·aeshash32(SB),NOSPLIT|NOFRAME,$0-0
MOVW (R0), R1
TEXT runtime·aeshash64(SB),NOSPLIT,$-8-0
TEXT runtime·aeshash64(SB),NOSPLIT|NOFRAME,$0-0
MOVW (R0), R1
TEXT runtime·aeshashstr(SB),NOSPLIT,$-8-0
TEXT runtime·aeshashstr(SB),NOSPLIT|NOFRAME,$0-0
MOVW (R0), R1

// memequal(p, q unsafe.Pointer, size uintptr) bool
TEXT runtime·memequal(SB),NOSPLIT,$-8-25
TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25
MOVV a+0(FP), R1
MOVV b+8(FP), R2
BEQ R1, R2, eq
Expand Down Expand Up @@ -766,7 +766,7 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$16

// The top-most function running on a goroutine
// returns to goexit+PCQuantum.
TEXT runtime·goexit(SB),NOSPLIT,$-8-0
TEXT runtime·goexit(SB),NOSPLIT|NOFRAME,$0-0
NOR R0, R0 // NOP
JAL runtime·goexit1(SB) // does not return
// traceback from goexit1 must hit code range of goexit
Expand Down
16 changes: 8 additions & 8 deletions src/runtime/asm_mipsx.s
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEXT runtime·asminit(SB),NOSPLIT,$0-0

// void gosave(Gobuf*)
// save state in Gobuf; setjmp
TEXT runtime·gosave(SB),NOSPLIT,$-4-4
TEXT runtime·gosave(SB),NOSPLIT|NOFRAME,$0-4
MOVW buf+0(FP), R1
MOVW R29, gobuf_sp(R1)
MOVW R31, gobuf_pc(R1)
Expand Down Expand Up @@ -128,7 +128,7 @@ TEXT runtime·gogo(SB),NOSPLIT,$8-4
// Switch to m->g0's stack, call fn(g).
// Fn must never return. It should gogo(&g->sched)
// to keep running g.
TEXT runtime·mcall(SB),NOSPLIT,$-4-4
TEXT runtime·mcall(SB),NOSPLIT|NOFRAME,$0-4
// Save caller state in g->sched
MOVW R29, (g_sched+gobuf_sp)(g)
MOVW R31, (g_sched+gobuf_pc)(g)
Expand Down Expand Up @@ -234,7 +234,7 @@ noswitch:
// the top of a stack (for example, morestack calling newstack
// calling the scheduler calling newm calling gc), so we must
// record an argument size. For that purpose, it has no arguments.
TEXT runtime·morestack(SB),NOSPLIT,$-4-0
TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
// Cannot grow scheduler stack (m->g0).
MOVW g_m(g), R7
MOVW m_g0(R7), R8
Expand Down Expand Up @@ -293,7 +293,7 @@ TEXT runtime·morestack_noctxt(SB),NOSPLIT,$0-0
TEXT reflect·call(SB),NOSPLIT,$0-20
JMP ·reflectcall(SB)

TEXT ·reflectcall(SB),NOSPLIT,$-4-20
TEXT ·reflectcall(SB),NOSPLIT|NOFRAME,$0-20
MOVW argsize+12(FP), R1

DISPATCH(runtime·call16, 16)
Expand Down Expand Up @@ -418,7 +418,7 @@ TEXT runtime·jmpdefer(SB),NOSPLIT,$0-8
JMP (R4)

// Save state of caller into g->sched. Smashes R1.
TEXT gosave<>(SB),NOSPLIT,$-4
TEXT gosave<>(SB),NOSPLIT|NOFRAME,$0
MOVW R31, (g_sched+gobuf_pc)(g)
MOVW R29, (g_sched+gobuf_sp)(g)
MOVW R0, (g_sched+gobuf_lr)(g)
Expand Down Expand Up @@ -610,7 +610,7 @@ TEXT setg_gcc<>(SB),NOSPLIT,$0
JAL runtime·save_g(SB)
RET

TEXT runtime·getcallerpc(SB),NOSPLIT,$-4-4
TEXT runtime·getcallerpc(SB),NOSPLIT|NOFRAME,$0-4
MOVW 0(R29), R1 // LR saved by caller
MOVW R1, ret+0(FP)
RET
Expand Down Expand Up @@ -826,7 +826,7 @@ TEXT runtime·return0(SB),NOSPLIT,$0

// Called from cgo wrappers, this function returns g->m->curg.stack.hi.
// Must obey the gcc calling convention.
TEXT _cgo_topofstack(SB),NOSPLIT,$-4
TEXT _cgo_topofstack(SB),NOSPLIT|NOFRAME,$0
// g (R30), R3 and REGTMP (R23) might be clobbered by load_g. R30 and R23
// are callee-save in the gcc calling convention, so save them.
MOVW R23, R8
Expand All @@ -846,7 +846,7 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$-4

// The top-most function running on a goroutine
// returns to goexit+PCQuantum.
TEXT runtime·goexit(SB),NOSPLIT,$-4-0
TEXT runtime·goexit(SB),NOSPLIT|NOFRAME,$0-0
NOR R0, R0 // NOP
JAL runtime·goexit1(SB) // does not return
// traceback from goexit1 must hit code range of goexit
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/atomic_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

#define SYNC WORD $0xf

TEXT ·publicationBarrier(SB),NOSPLIT,$-8-0
TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
SYNC
RET
2 changes: 1 addition & 1 deletion src/runtime/cgo/asm_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* void crosscall2(void (*fn)(void*, int32, uintptr), void*, int32, uintptr)
* Save registers and call fn with two arguments.
*/
TEXT crosscall2(SB),NOSPLIT,$-8
TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
/*
* We still need to save all callee save register as before, and then
* push 3 args for fn (R5, R6, R7).
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgo/asm_mipsx.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* void crosscall2(void (*fn)(void*, int32, uintptr), void*, int32, uintptr)
* Save registers and call fn with two arguments.
*/
TEXT crosscall2(SB),NOSPLIT,$-4
TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
/*
* We still need to save all callee save register as before, and then
* push 3 args for fn (R5, R6, R7).
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/duff_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "textflag.h"

TEXT runtime·duffzero(SB), NOSPLIT, $-8-0
TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0
MOVV R0, 8(R1)
ADDV $8, R1
MOVV R0, 8(R1)
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/internal/atomic/atomic_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define SYNC WORD $0xf

// uint32 runtime∕internal∕atomic·Load(uint32 volatile* ptr)
TEXT ·Load(SB),NOSPLIT,$-8-12
TEXT ·Load(SB),NOSPLIT|NOFRAME,$0-12
MOVV ptr+0(FP), R1
SYNC
MOVWU 0(R1), R1
Expand All @@ -18,7 +18,7 @@ TEXT ·Load(SB),NOSPLIT,$-8-12
RET

// uint64 runtime∕internal∕atomic·Load64(uint64 volatile* ptr)
TEXT ·Load64(SB),NOSPLIT,$-8-16
TEXT ·Load64(SB),NOSPLIT|NOFRAME,$0-16
MOVV ptr+0(FP), R1
SYNC
MOVV 0(R1), R1
Expand All @@ -27,7 +27,7 @@ TEXT ·Load64(SB),NOSPLIT,$-8-16
RET

// void *runtime∕internal∕atomic·Loadp(void *volatile *ptr)
TEXT ·Loadp(SB),NOSPLIT,$-8-16
TEXT ·Loadp(SB),NOSPLIT|NOFRAME,$0-16
MOVV ptr+0(FP), R1
SYNC
MOVV 0(R1), R1
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/memmove_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "textflag.h"

// void runtime·memmove(void*, void*, uintptr)
TEXT runtime·memmove(SB), NOSPLIT, $-8-24
TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24
MOVV to+0(FP), R1
MOVV from+8(FP), R2
MOVV n+16(FP), R3
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mkduff.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func zeroMIPS64x(w io.Writer) {
// R0: always zero
// R1 (aka REGRT1): ptr to memory to be zeroed - 8
// On return, R1 points to the last zeroed dword.
fmt.Fprintln(w, "TEXT runtime·duffzero(SB), NOSPLIT, $-8-0")
fmt.Fprintln(w, "TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0")
for i := 0; i < 128; i++ {
fmt.Fprintln(w, "\tMOVV\tR0, 8(R1)")
fmt.Fprintln(w, "\tADDV\t$8, R1")
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/rt0_linux_mips64x.s
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEXT _rt0_mips64_linux(SB),NOSPLIT,$0
TEXT _rt0_mips64le_linux(SB),NOSPLIT,$0
JMP _main<>(SB)

TEXT _main<>(SB),NOSPLIT,$-8
TEXT _main<>(SB),NOSPLIT|NOFRAME,$0
// In a statically linked binary, the stack contains argc,
// argv as argc string pointers followed by a NULL, envv as a
// sequence of string pointers followed by a NULL, and auxv.
Expand All @@ -26,7 +26,7 @@ TEXT _main<>(SB),NOSPLIT,$-8
ADDV $8, R29, R5 // argv
JMP main(SB)

TEXT main(SB),NOSPLIT,$-8
TEXT main(SB),NOSPLIT|NOFRAME,$0
// in external linking, glibc jumps to main with argc in R4
// and argv in R5

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/rt0_linux_mipsx.s
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEXT _rt0_mips_linux(SB),NOSPLIT,$0
TEXT _rt0_mipsle_linux(SB),NOSPLIT,$0
JMP _main<>(SB)

TEXT _main<>(SB),NOSPLIT,$-4
TEXT _main<>(SB),NOSPLIT|NOFRAME,$0
// In a statically linked binary, the stack contains argc,
// argv as argc string pointers followed by a NULL, envv as a
// sequence of string pointers followed by a NULL, and auxv.
Expand All @@ -22,7 +22,7 @@ TEXT _main<>(SB),NOSPLIT,$-4
ADD $4, R29, R5 // argv
JMP main(SB)

TEXT main(SB),NOSPLIT,$-4
TEXT main(SB),NOSPLIT|NOFRAME,$0
// In external linking, libc jumps to main with argc in R4, argv in R5
MOVW $runtime·rt0_go(SB), R1
JMP (R1)
Loading

0 comments on commit dfbf568

Please sign in to comment.