]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: prevent pointless jmp in amd64 and 386 memmove
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 1 Aug 2014 13:21:08 +0000 (06:21 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 1 Aug 2014 13:21:08 +0000 (06:21 -0700)
6a and 8a rearrange memmove such that the fallthrough from move_1or2 to move_0 ends up being a JMP to a RET. Insert an explicit RET to prevent such silliness.

Do the same for memclr as prophylaxis.

benchmark                old ns/op     new ns/op     delta
BenchmarkMemmove1        4.59          4.13          -10.02%
BenchmarkMemmove2        4.58          4.13          -9.83%

LGTM=khr
R=golang-codereviews, dvyukov, minux, ruiu, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/120930043

src/pkg/runtime/memclr_386.s
src/pkg/runtime/memclr_amd64.s
src/pkg/runtime/memclr_plan9_386.s
src/pkg/runtime/memmove_386.s
src/pkg/runtime/memmove_amd64.s
src/pkg/runtime/memmove_plan9_386.s
src/pkg/runtime/memmove_plan9_amd64.s

index 4b7580cb49f4d1837026d68f867c3617403c0fe9..aeabad413e3d89a168c6266f55b43bc8578bc15a 100644 (file)
@@ -63,6 +63,7 @@ clr_loop:
 clr_1or2:
        MOVB    AX, (DI)
        MOVB    AX, -1(DI)(BX*1)
+       RET
 clr_0:
        RET
 clr_3or4:
index 6b79363b2496486149a7fa7b782cfb731bec18ff..01c6a415c0ce688dce7bf2015e214fe42204596e 100644 (file)
@@ -62,6 +62,7 @@ clr_loop:
 clr_1or2:
        MOVB    AX, (DI)
        MOVB    AX, -1(DI)(BX*1)
+       RET
 clr_0:
        RET
 clr_3or4:
index 9b496785a210adadb3a30a82382ededeab82d9f5..ed5dbbd3c63c97fa871b00a6fecbe9d6e3f4cf9c 100644 (file)
@@ -32,6 +32,7 @@ clr_tail:
 clr_1or2:
        MOVB    AX, (DI)
        MOVB    AX, -1(DI)(BX*1)
+       RET
 clr_0:
        RET
 clr_3or4:
index 1fd9ba2bcc467c4f48cbf3957a8ff0f0fdcfb197..51b08d56d3384297b036c3333419654499db9fa1 100644 (file)
@@ -115,6 +115,7 @@ move_1or2:
        MOVB    -1(SI)(BX*1), CX
        MOVB    AX, (DI)
        MOVB    CX, -1(DI)(BX*1)
+       RET
 move_0:
        RET
 move_3or4:
index 672fce90b3850e67899a88e8e7af440c54f81da8..339c5dd4104eb76fe03403020bd77d9a022631db 100644 (file)
@@ -122,6 +122,7 @@ move_1or2:
        MOVB    -1(SI)(BX*1), CX
        MOVB    AX, (DI)
        MOVB    CX, -1(DI)(BX*1)
+       RET
 move_0:
        RET
 move_3or4:
index 187616cd0af0d06cd0b90aea0d6026239b9093e1..5ac5c27d40be4f21294d599fd28a63a63c15b6ed 100644 (file)
@@ -101,6 +101,7 @@ move_1or2:
        MOVB    -1(SI)(BX*1), CX
        MOVB    AX, (DI)
        MOVB    CX, -1(DI)(BX*1)
+       RET
 move_0:
        RET
 move_3or4:
index 60108273cf03c81873749ddb8765843d1c71035f..3664e45ae2de78ff00612c0e0f6931e3177345b1 100644 (file)
@@ -104,6 +104,7 @@ move_1or2:
        MOVB    -1(SI)(BX*1), CX
        MOVB    AX, (DI)
        MOVB    CX, -1(DI)(BX*1)
+       RET
 move_0:
        RET
 move_3or4: