]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: speed up eqstring
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 5 Feb 2015 16:23:14 +0000 (08:23 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 6 Feb 2015 18:51:14 +0000 (18:51 +0000)
eqstring does not need to check the length of the strings.
Other architectures were done in a separate commit.

While we're here, add a pointer equality check.

Change-Id: Id2c8616a03a7da7037c1e9ccd56a549fc952bd98
Reviewed-on: https://go-review.googlesource.com/3956
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/asm_ppc64x.s

index 660c7cdfe5c0172769e3e2963bef35cc4d6179de..694dfcc24e76fb7d36708a7043a77e76011486d3 100644 (file)
@@ -969,30 +969,30 @@ eq:
        RETURN
 
 // 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    s1len+8(FP), R4
-       MOVD    s2len+24(FP), R5
-       CMP     R4, R5
-       BNE     noteq
-
        MOVD    s1str+0(FP), R3
        MOVD    s2str+16(FP), R4
+       MOVD    $1, R5
+       MOVB    R5, ret+32(FP)
+       CMP     R3, R4
+       BNE     2(PC)
+       RETURN
+       MOVD    s1len+8(FP), R5
        SUB     $1, R3
        SUB     $1, R4
        ADD     R3, R5, R8
 loop:
        CMP     R3, R8
-       BNE     4(PC)
-       MOVD    $1, R3
-       MOVB    R3, ret+32(FP)
+       BNE     2(PC)
        RETURN
        MOVBZU  1(R3), R6
        MOVBZU  1(R4), R7
        CMP     R6, R7
        BEQ     loop
-noteq:
        MOVB    R0, ret+32(FP)
        RETURN