aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/asm_mips64x.s
diff options
context:
space:
mode:
authorMartin Möhrmann <moehrmann@google.com>2017-08-07 22:36:22 +0200
committerMartin Möhrmann <moehrmann@google.com>2017-08-22 17:59:02 +0000
commit3216e0cefab43670c788a475237f6f4b235fc200 (patch)
tree5294f61c64a869cfe74442efcd91178c09ac3aa0 /src/runtime/asm_mips64x.s
parentd05a1238d6811aa11abf117e668cd9c4f4c15e6a (diff)
downloadgo-3216e0cefab43670c788a475237f6f4b235fc200.tar.gz
go-3216e0cefab43670c788a475237f6f4b235fc200.zip
cmd/compile: replace eqstring with memequal
eqstring is only called for strings with equal lengths. Instead of pushing a pointer and length for each argument string on the stack we can omit pushing one of the lengths on the stack. Changing eqstrings signature to eqstring(*uint8, *uint8, int) bool to implement the above optimization would make it very similar to the existing memequal(*any, *any, uintptr) bool function. Since string lengths are positive we can avoid code redundancy and use memequal instead of using eqstring with an optimized signature. go command binary size reduced by 4128 bytes on amd64. name old time/op new time/op delta CompareStringEqual 6.03ns ± 1% 5.71ns ± 1% -5.23% (p=0.000 n=19+18) CompareStringIdentical 2.88ns ± 1% 3.22ns ± 7% +11.86% (p=0.000 n=20+20) CompareStringSameLength 4.31ns ± 1% 4.01ns ± 1% -7.17% (p=0.000 n=19+19) CompareStringDifferentLength 0.29ns ± 2% 0.29ns ± 2% ~ (p=1.000 n=20+20) CompareStringBigUnaligned 64.3µs ± 2% 64.1µs ± 3% ~ (p=0.164 n=20+19) CompareStringBig 61.9µs ± 1% 61.6µs ± 2% -0.46% (p=0.033 n=20+19) Change-Id: Ice15f3b937c981f0d3bc8479a9ea0d10658ac8df Reviewed-on: https://go-review.googlesource.com/53650 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/asm_mips64x.s')
-rw-r--r--src/runtime/asm_mips64x.s25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s
index 58ee58ed5b..338f6d4487 100644
--- a/src/runtime/asm_mips64x.s
+++ b/src/runtime/asm_mips64x.s
@@ -679,31 +679,6 @@ eq:
MOVB R1, ret+16(FP)
RET
-// eqstring tests whether two strings are equal.
-// The compiler guarantees that strings passed
-// to eqstring have equal length.
-// See runtime_test.go:eqstring_generic for
-// equivalent Go code.
-TEXT runtime·eqstring(SB),NOSPLIT,$0-33
- MOVV s1_base+0(FP), R1
- MOVV s2_base+16(FP), R2
- MOVV $1, R3
- MOVB R3, ret+32(FP)
- BNE R1, R2, 2(PC)
- RET
- MOVV s1_len+8(FP), R3
- ADDV R1, R3, R4
-loop:
- BNE R1, R4, 2(PC)
- RET
- MOVBU (R1), R6
- ADDV $1, R1
- MOVBU (R2), R7
- ADDV $1, R2
- BEQ R6, R7, loop
- MOVB R0, ret+32(FP)
- RET
-
// TODO: share code with memequal?
TEXT bytes·Equal(SB),NOSPLIT,$0-49
MOVV a_len+8(FP), R3