• Josh Bleecher Snyder's avatar
    runtime, cmd/internal/obj/arm: improve arm function prologue · 5353cde0
    Josh Bleecher Snyder authored
    When stack growth is not needed, as it usually is not,
    execute only a single conditional branch
    rather than three conditional instructions.
    This adds 4 bytes to every function,
    but might speed up execution in the common case.
    
    Sample disassembly for
    
    func f() {
    	_ = [128]byte{}
    }
    
    Before:
    
    TEXT main.f(SB) x.go
    	x.go:3	0x2000	e59a1008	MOVW 0x8(R10), R1
    	x.go:3	0x2004	e59fb028	MOVW 0x28(R15), R11
    	x.go:3	0x2008	e08d200b	ADD R11, R13, R2
    	x.go:3	0x200c	e1520001	CMP R1, R2
    	x.go:3	0x2010	91a0300e	MOVW.LS R14, R3
    	x.go:3	0x2014	9b0118a9	BL.LS runtime.morestack_noctxt(SB)
    	x.go:3	0x2018	9afffff8	B.LS main.f(SB)
    	x.go:3	0x201c	e52de084	MOVW.W R14, -0x84(R13)
    	x.go:4	0x2020	e28d1004	ADD $4, R13, R1
    	x.go:4	0x2024	e3a00000	MOVW $0, R0
    	x.go:4	0x2028	eb012255	BL 0x4a984
    	x.go:5	0x202c	e49df084	RET #132
    	x.go:5	0x2030	eafffffe	B 0x2030
    	x.go:5	0x2034	ffffff7c	?
    
    After:
    
    TEXT main.f(SB) x.go
    	x.go:3	0x2000	e59a1008	MOVW 0x8(R10), R1
    	x.go:3	0x2004	e59fb02c	MOVW 0x2c(R15), R11
    	x.go:3	0x2008	e08d200b	ADD R11, R13, R2
    	x.go:3	0x200c	e1520001	CMP R1, R2
    	x.go:3	0x2010	9a000004	B.LS 0x2028
    	x.go:3	0x2014	e52de084	MOVW.W R14, -0x84(R13)
    	x.go:4	0x2018	e28d1004	ADD $4, R13, R1
    	x.go:4	0x201c	e3a00000	MOVW $0, R0
    	x.go:4	0x2020	eb0124dc	BL 0x4b398
    	x.go:5	0x2024	e49df084	RET #132
    	x.go:5	0x2028	e1a0300e	MOVW R14, R3
    	x.go:5	0x202c	eb011b0d	BL runtime.morestack_noctxt(SB)
    	x.go:5	0x2030	eafffff2	B main.f(SB)
    	x.go:5	0x2034	eafffffe	B 0x2034
    	x.go:5	0x2038	ffffff7c	?
    
    Updates #10587.
    
    package sort benchmarks on an iPhone 6:
    
    name            old time/op  new time/op  delta
    SortString1K     569µs ± 0%   565µs ± 1%  -0.75%  (p=0.000 n=23+24)
    StableString1K   872µs ± 1%   870µs ± 1%  -0.16%  (p=0.009 n=23+24)
    SortInt1K        317µs ± 2%   316µs ± 2%    ~     (p=0.410 n=26+26)
    StableInt1K      343µs ± 1%   339µs ± 1%  -1.07%  (p=0.000 n=22+23)
    SortInt64K      30.0ms ± 1%  30.0ms ± 1%    ~     (p=0.091 n=25+24)
    StableInt64K    30.2ms ± 0%  30.0ms ± 0%  -0.69%  (p=0.000 n=22+22)
    Sort1e2          147µs ± 1%   146µs ± 0%  -0.48%  (p=0.000 n=25+24)
    Stable1e2        290µs ± 1%   286µs ± 1%  -1.30%  (p=0.000 n=23+24)
    Sort1e4         29.5ms ± 2%  29.7ms ± 1%  +0.71%  (p=0.000 n=23+23)
    Stable1e4       88.7ms ± 4%  88.6ms ± 8%  -0.07%  (p=0.022 n=26+26)
    Sort1e6          4.81s ± 7%   4.83s ± 7%    ~     (p=0.192 n=26+26)
    Stable1e6        18.3s ± 1%   18.1s ± 1%  -0.76%  (p=0.000 n=25+23)
    SearchWrappers   318ns ± 1%   344ns ± 1%  +8.14%  (p=0.000 n=23+26)
    
    package sort benchmarks on a first generation rpi:
    
    name            old time/op  new time/op  delta
    SearchWrappers  4.13µs ± 0%  3.95µs ± 0%   -4.42%  (p=0.000 n=15+13)
    SortString1K    5.81ms ± 1%  5.82ms ± 2%     ~     (p=0.400 n=14+15)
    StableString1K  9.69ms ± 1%  9.73ms ± 0%     ~     (p=0.121 n=15+11)
    SortInt1K       3.30ms ± 2%  3.66ms ±19%  +10.82%  (p=0.000 n=15+14)
    StableInt1K     5.97ms ±15%  4.17ms ± 8%  -30.05%  (p=0.000 n=15+15)
    SortInt64K       319ms ± 1%   295ms ± 1%   -7.65%  (p=0.000 n=15+15)
    StableInt64K     343ms ± 0%   332ms ± 0%   -3.26%  (p=0.000 n=12+13)
    Sort1e2         3.36ms ± 2%  3.22ms ± 4%   -4.10%  (p=0.000 n=15+15)
    Stable1e2       6.74ms ± 1%  6.43ms ± 2%   -4.67%  (p=0.000 n=15+15)
    Sort1e4          247ms ± 1%   247ms ± 1%     ~     (p=0.331 n=15+14)
    Stable1e4        864ms ± 0%   820ms ± 0%   -5.15%  (p=0.000 n=14+15)
    Sort1e6          41.2s ± 0%   41.2s ± 0%   +0.15%  (p=0.000 n=13+14)
    Stable1e6         192s ± 0%    182s ± 0%   -5.07%  (p=0.000 n=14+14)
    
    Change-Id: I8a9db77e1d4ea1956575895893bc9d04bd81204b
    Reviewed-on: https://go-review.googlesource.com/10497Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    5353cde0
Name
Last commit
Last update
..
cgo Loading commit data...
debug Loading commit data...
pprof Loading commit data...
race Loading commit data...
Makefile Loading commit data...
alg.go Loading commit data...
append_test.go Loading commit data...
arch1_386.go Loading commit data...
arch1_amd64.go Loading commit data...
arch1_amd64p32.go Loading commit data...
arch1_arm.go Loading commit data...
arch1_arm64.go Loading commit data...
arch1_ppc64.go Loading commit data...
arch1_ppc64le.go Loading commit data...
arch_386.go Loading commit data...
arch_amd64.go Loading commit data...
arch_amd64p32.go Loading commit data...
arch_arm.go Loading commit data...
arch_arm64.go Loading commit data...
arch_ppc64.go Loading commit data...
arch_ppc64le.go Loading commit data...
asm.s Loading commit data...
asm_386.s Loading commit data...
asm_amd64.s Loading commit data...
asm_amd64p32.s Loading commit data...
asm_arm.s Loading commit data...
asm_arm64.s Loading commit data...
asm_ppc64x.s Loading commit data...
atomic_386.go Loading commit data...
atomic_amd64x.go Loading commit data...
atomic_arm.go Loading commit data...
atomic_arm64.go Loading commit data...
atomic_arm64.s Loading commit data...
atomic_pointer.go Loading commit data...
atomic_ppc64x.go Loading commit data...
atomic_ppc64x.s Loading commit data...
atomic_test.go Loading commit data...
cgo.go Loading commit data...
cgocall.go Loading commit data...
cgocallback.go Loading commit data...
chan.go Loading commit data...
chan_test.go Loading commit data...
closure_test.go Loading commit data...
compiler.go Loading commit data...
complex.go Loading commit data...
complex_test.go Loading commit data...
cpuprof.go Loading commit data...
cputicks.go Loading commit data...
crash_cgo_test.go Loading commit data...
crash_test.go Loading commit data...
debug.go Loading commit data...
defs1_linux.go Loading commit data...
defs1_netbsd_386.go Loading commit data...
defs1_netbsd_amd64.go Loading commit data...
defs1_netbsd_arm.go Loading commit data...
defs1_solaris_amd64.go Loading commit data...
defs2_linux.go Loading commit data...
defs3_linux.go Loading commit data...
defs_arm_linux.go Loading commit data...
defs_darwin.go Loading commit data...
defs_darwin_386.go Loading commit data...
defs_darwin_amd64.go Loading commit data...
defs_darwin_arm.go Loading commit data...
defs_darwin_arm64.go Loading commit data...
defs_dragonfly.go Loading commit data...
defs_dragonfly_amd64.go Loading commit data...
defs_freebsd.go Loading commit data...
defs_freebsd_386.go Loading commit data...
defs_freebsd_amd64.go Loading commit data...
defs_freebsd_arm.go Loading commit data...
defs_linux.go Loading commit data...
defs_linux_386.go Loading commit data...
defs_linux_amd64.go Loading commit data...
defs_linux_arm.go Loading commit data...
defs_linux_arm64.go Loading commit data...
defs_linux_ppc64.go Loading commit data...
defs_linux_ppc64le.go Loading commit data...
defs_nacl_386.go Loading commit data...
defs_nacl_amd64p32.go Loading commit data...
defs_nacl_arm.go Loading commit data...
defs_netbsd.go Loading commit data...
defs_netbsd_386.go Loading commit data...
defs_netbsd_amd64.go Loading commit data...
defs_netbsd_arm.go Loading commit data...
defs_openbsd.go Loading commit data...
defs_openbsd_386.go Loading commit data...
defs_openbsd_amd64.go Loading commit data...
defs_openbsd_arm.go Loading commit data...
defs_plan9_386.go Loading commit data...
defs_plan9_amd64.go Loading commit data...
defs_solaris.go Loading commit data...
defs_solaris_amd64.go Loading commit data...
defs_windows.go Loading commit data...
defs_windows_386.go Loading commit data...
defs_windows_amd64.go Loading commit data...
duff_386.s Loading commit data...
duff_amd64.s Loading commit data...
duff_arm.s Loading commit data...
duff_arm64.s Loading commit data...
duff_ppc64x.s Loading commit data...
env_plan9.go Loading commit data...
env_posix.go Loading commit data...
env_test.go Loading commit data...
error.go Loading commit data...
export_futex_test.go Loading commit data...
export_linux_test.go Loading commit data...
export_test.go Loading commit data...
export_windows_test.go Loading commit data...
extern.go Loading commit data...
funcdata.h Loading commit data...
futex_test.go Loading commit data...
gc_test.go Loading commit data...
gcinfo_test.go Loading commit data...
gengoos.go Loading commit data...
go_tls.h Loading commit data...
hash32.go Loading commit data...
hash64.go Loading commit data...
hash_test.go Loading commit data...
hashmap.go Loading commit data...
hashmap_fast.go Loading commit data...
heapdump.go Loading commit data...
iface.go Loading commit data...
iface_test.go Loading commit data...
lfstack.go Loading commit data...
lfstack_32bit.go Loading commit data...
lfstack_amd64.go Loading commit data...
lfstack_darwin_arm64.go Loading commit data...
lfstack_linux_arm64.go Loading commit data...
lfstack_linux_ppc64x.go Loading commit data...
lfstack_test.go Loading commit data...
lock_futex.go Loading commit data...
lock_sema.go Loading commit data...
malloc.go Loading commit data...
malloc_test.go Loading commit data...
map_test.go Loading commit data...
mapspeed_test.go Loading commit data...
mbarrier.go Loading commit data...
mbitmap.go Loading commit data...
mcache.go Loading commit data...
mcentral.go Loading commit data...
mem_bsd.go Loading commit data...
mem_darwin.go Loading commit data...
mem_linux.go Loading commit data...
mem_plan9.go Loading commit data...
mem_windows.go Loading commit data...
memclr_386.s Loading commit data...
memclr_amd64.s Loading commit data...
memclr_arm.s Loading commit data...
memclr_arm64.s Loading commit data...
memclr_plan9_386.s Loading commit data...
memclr_plan9_amd64.s Loading commit data...
memclr_ppc64x.s Loading commit data...
memmove_386.s Loading commit data...
memmove_amd64.s Loading commit data...
memmove_arm.s Loading commit data...
memmove_arm64.s Loading commit data...
memmove_linux_amd64_test.go Loading commit data...
memmove_nacl_amd64p32.s Loading commit data...
memmove_plan9_386.s Loading commit data...
memmove_plan9_amd64.s Loading commit data...
memmove_ppc64x.s Loading commit data...
memmove_test.go Loading commit data...
mfinal.go Loading commit data...
mfinal_test.go Loading commit data...
mfixalloc.go Loading commit data...
mgc.go Loading commit data...
mgcmark.go Loading commit data...
mgcsweep.go Loading commit data...
mgcwork.go Loading commit data...
mheap.go Loading commit data...
mkduff.go Loading commit data...
mknacl.sh Loading commit data...
mprof.go Loading commit data...
msize.go Loading commit data...
mstats.go Loading commit data...
netpoll.go Loading commit data...
netpoll_epoll.go Loading commit data...
netpoll_kqueue.go Loading commit data...
netpoll_nacl.go Loading commit data...
netpoll_solaris.go Loading commit data...
netpoll_stub.go Loading commit data...
netpoll_windows.go Loading commit data...
noasm.go Loading commit data...
norace_linux_test.go Loading commit data...
norace_test.go Loading commit data...
os1_darwin.go Loading commit data...
os1_dragonfly.go Loading commit data...
os1_freebsd.go Loading commit data...
os1_linux.go Loading commit data...
os1_nacl.go Loading commit data...
os1_netbsd.go Loading commit data...
os1_netbsd_386.go Loading commit data...
os1_netbsd_amd64.go Loading commit data...
os1_openbsd.go Loading commit data...
os1_plan9.go Loading commit data...
os1_windows.go Loading commit data...
os2_darwin.go Loading commit data...
os2_dragonfly.go Loading commit data...
os2_freebsd.go Loading commit data...
os2_linux.go Loading commit data...
os2_nacl.go Loading commit data...
os2_netbsd.go Loading commit data...
os2_openbsd.go Loading commit data...
os2_plan9.go Loading commit data...
os2_solaris.go Loading commit data...
os2_windows.go Loading commit data...
os3_plan9.go Loading commit data...
os3_solaris.go Loading commit data...
os_android_arm.go Loading commit data...
os_darwin.go Loading commit data...
os_darwin_arm.go Loading commit data...
os_darwin_arm64.go Loading commit data...
os_dragonfly.go Loading commit data...
os_freebsd.go Loading commit data...
os_freebsd_arm.go Loading commit data...
os_linux.go Loading commit data...
os_linux_386.go Loading commit data...
os_linux_arm.go Loading commit data...
os_linux_arm64.go Loading commit data...
os_nacl.go Loading commit data...
os_nacl_arm.go Loading commit data...
os_netbsd.go Loading commit data...
os_netbsd_arm.go Loading commit data...
os_openbsd.go Loading commit data...
os_openbsd_arm.go Loading commit data...
os_plan9.go Loading commit data...
os_solaris.go Loading commit data...
os_windows.go Loading commit data...
panic.go Loading commit data...
panic1.go Loading commit data...
parfor.go Loading commit data...
parfor_test.go Loading commit data...
print1.go Loading commit data...
print1_write.go Loading commit data...
print1_write_android.go Loading commit data...
proc.go Loading commit data...
proc1.go Loading commit data...
proc_test.go Loading commit data...
race.go Loading commit data...
race0.go Loading commit data...
race1.go Loading commit data...
race_amd64.s Loading commit data...
rdebug.go Loading commit data...
rt0_android_arm.s Loading commit data...
rt0_darwin_386.s Loading commit data...
rt0_darwin_amd64.s Loading commit data...
rt0_darwin_arm.s Loading commit data...
rt0_darwin_arm64.s Loading commit data...
rt0_dragonfly_amd64.s Loading commit data...
rt0_freebsd_386.s Loading commit data...
rt0_freebsd_amd64.s Loading commit data...
rt0_freebsd_arm.s Loading commit data...
rt0_linux_386.s Loading commit data...
rt0_linux_amd64.s Loading commit data...
rt0_linux_arm.s Loading commit data...
rt0_linux_arm64.s Loading commit data...
rt0_linux_ppc64.s Loading commit data...
rt0_linux_ppc64le.s Loading commit data...
rt0_nacl_386.s Loading commit data...
rt0_nacl_amd64p32.s Loading commit data...
rt0_nacl_arm.s Loading commit data...
rt0_netbsd_386.s Loading commit data...
rt0_netbsd_amd64.s Loading commit data...
rt0_netbsd_arm.s Loading commit data...
rt0_openbsd_386.s Loading commit data...
rt0_openbsd_amd64.s Loading commit data...
rt0_openbsd_arm.s Loading commit data...
rt0_plan9_386.s Loading commit data...
rt0_plan9_amd64.s Loading commit data...
rt0_solaris_amd64.s Loading commit data...
rt0_windows_386.s Loading commit data...
rt0_windows_amd64.s Loading commit data...
rune.go Loading commit data...
runtime-gdb.py Loading commit data...
runtime-gdb_test.go Loading commit data...
runtime.go Loading commit data...
runtime1.go Loading commit data...
runtime2.go Loading commit data...
runtime_linux_test.go Loading commit data...
runtime_test.go Loading commit data...
runtime_unix_test.go Loading commit data...
select.go Loading commit data...
sema.go Loading commit data...
signal1_unix.go Loading commit data...
signal_386.go Loading commit data...
signal_amd64x.go Loading commit data...
signal_arm.go Loading commit data...
signal_arm64.go Loading commit data...
signal_darwin.go Loading commit data...
signal_darwin_386.go Loading commit data...
signal_darwin_amd64.go Loading commit data...
signal_darwin_arm.go Loading commit data...
signal_darwin_arm64.go Loading commit data...
signal_dragonfly.go Loading commit data...
signal_dragonfly_amd64.go Loading commit data...
signal_freebsd.go Loading commit data...
signal_freebsd_386.go Loading commit data...
signal_freebsd_amd64.go Loading commit data...
signal_freebsd_arm.go Loading commit data...
signal_linux.go Loading commit data...
signal_linux_386.go Loading commit data...
signal_linux_amd64.go Loading commit data...
signal_linux_arm.go Loading commit data...
signal_linux_arm64.go Loading commit data...
signal_linux_ppc64x.go Loading commit data...
signal_nacl.go Loading commit data...
signal_nacl_386.go Loading commit data...
signal_nacl_amd64p32.go Loading commit data...
signal_nacl_arm.go Loading commit data...
signal_netbsd.go Loading commit data...
signal_netbsd_386.go Loading commit data...
signal_netbsd_amd64.go Loading commit data...
signal_netbsd_arm.go Loading commit data...
signal_openbsd.go Loading commit data...
signal_openbsd_386.go Loading commit data...
signal_openbsd_amd64.go Loading commit data...
signal_openbsd_arm.go Loading commit data...
signal_plan9.go Loading commit data...
signal_ppc64x.go Loading commit data...
signal_solaris.go Loading commit data...
signal_solaris_amd64.go Loading commit data...
signal_unix.go Loading commit data...
signal_windows.go Loading commit data...
sigpanic_unix.go Loading commit data...
sigqueue.go Loading commit data...
sigqueue_plan9.go Loading commit data...
slice.go Loading commit data...
softfloat64.go Loading commit data...
softfloat64_test.go Loading commit data...
softfloat_arm.go Loading commit data...
sqrt.go Loading commit data...
sqrt_test.go Loading commit data...
stack1.go Loading commit data...
stack2.go Loading commit data...
stack_test.go Loading commit data...
string.go Loading commit data...
string1.go Loading commit data...
string_test.go Loading commit data...
stubs.go Loading commit data...
stubs2.go Loading commit data...
stubs_android.go Loading commit data...
symtab.go Loading commit data...
symtab_test.go Loading commit data...
sys_arm.go Loading commit data...
sys_arm64.go Loading commit data...
sys_darwin_386.s Loading commit data...
sys_darwin_amd64.s Loading commit data...
sys_darwin_arm.s Loading commit data...
sys_darwin_arm64.s Loading commit data...
sys_dragonfly_amd64.s Loading commit data...
sys_freebsd_386.s Loading commit data...
sys_freebsd_amd64.s Loading commit data...
sys_freebsd_arm.s Loading commit data...
sys_linux_386.s Loading commit data...
sys_linux_amd64.s Loading commit data...
sys_linux_arm.s Loading commit data...
sys_linux_arm64.s Loading commit data...
sys_linux_ppc64x.s Loading commit data...
sys_nacl_386.s Loading commit data...
sys_nacl_amd64p32.s Loading commit data...
sys_nacl_arm.s Loading commit data...
sys_netbsd_386.s Loading commit data...
sys_netbsd_amd64.s Loading commit data...
sys_netbsd_arm.s Loading commit data...
sys_openbsd_386.s Loading commit data...
sys_openbsd_amd64.s Loading commit data...
sys_openbsd_arm.s Loading commit data...
sys_plan9_386.s Loading commit data...
sys_plan9_amd64.s Loading commit data...
sys_ppc64x.go Loading commit data...
sys_solaris_amd64.s Loading commit data...
sys_windows_386.s Loading commit data...
sys_windows_amd64.s Loading commit data...
sys_x86.go Loading commit data...
syscall2_solaris.go Loading commit data...
syscall_nacl.h Loading commit data...
syscall_solaris.go Loading commit data...
syscall_windows.go Loading commit data...
syscall_windows_test.go Loading commit data...
textflag.h Loading commit data...
time.go Loading commit data...
tls_arm.s Loading commit data...
tls_arm64.h Loading commit data...
tls_arm64.s Loading commit data...
tls_ppc64x.s Loading commit data...
trace.go Loading commit data...
traceback.go Loading commit data...
type.go Loading commit data...
typekind.go Loading commit data...
typekind1.go Loading commit data...
unaligned1.go Loading commit data...
unaligned2.go Loading commit data...
vdso_linux_amd64.go Loading commit data...
vdso_none.go Loading commit data...
vlop_386.s Loading commit data...
vlop_arm.s Loading commit data...
vlop_arm_test.go Loading commit data...
vlrt.go Loading commit data...
wbfat.go Loading commit data...
wbfat_gen.go Loading commit data...
wincallback.go Loading commit data...
zcallback_windows.go Loading commit data...
zcallback_windows.s Loading commit data...
zgoarch_386.go Loading commit data...
zgoarch_amd64.go Loading commit data...
zgoarch_amd64p32.go Loading commit data...
zgoarch_arm.go Loading commit data...
zgoarch_arm64.go Loading commit data...
zgoarch_ppc64.go Loading commit data...
zgoarch_ppc64le.go Loading commit data...
zgoos_android.go Loading commit data...
zgoos_darwin.go Loading commit data...
zgoos_dragonfly.go Loading commit data...
zgoos_freebsd.go Loading commit data...
zgoos_linux.go Loading commit data...
zgoos_nacl.go Loading commit data...
zgoos_netbsd.go Loading commit data...
zgoos_openbsd.go Loading commit data...
zgoos_plan9.go Loading commit data...
zgoos_solaris.go Loading commit data...
zgoos_windows.go Loading commit data...