aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/asm_arm64.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_arm64.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_arm64.s')
-rw-r--r--src/runtime/asm_arm64.s25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s
index 32c06d5c37..4a68b4ab23 100644
--- a/src/runtime/asm_arm64.s
+++ b/src/runtime/asm_arm64.s
@@ -806,31 +806,6 @@ samebytes:
MOVD R4, (R7)
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
- MOVD s1_base+0(FP), R0
- MOVD s1_len+8(FP), R1
- MOVD s2_base+16(FP), R2
- ADD R0, R1 // end
-loop:
- CMP R0, R1
- BEQ equal // reaches the end
- MOVBU.P 1(R0), R4
- MOVBU.P 1(R2), R5
- CMP R4, R5
- BEQ loop
-notequal:
- MOVB ZR, ret+32(FP)
- RET
-equal:
- MOVD $1, R0
- MOVB R0, ret+32(FP)
- RET
-
//
// functions for other packages
//