[go] runtime: port performance-critical functions to regabi

38 views
Skip to first unread message

Austin Clements (Gerrit)

unread,
Apr 9, 2021, 10:47:54 AM4/9/21
to Michael Knyszek, Cherry Zhang, goph...@pubsubhelper.golang.org, Austin Clements, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek, Cherry Zhang.

Austin Clements would like Michael Knyszek and Cherry Zhang to review this change.

View Change

runtime: port performance-critical functions to regabi

DO NOT SUBMIT. Needs benchmarks (early results are looking good but
not perfect).

This CL ports a few performance-critical runtime assembly functions to
use register arguments directly. While using the faster ABI is nice,
the real win here is that we avoid ABI wrappers: since these are
"builtin" functions in the compiler, it can generate calls to them
without knowing that their native implementation is ABI0. Hence, it
generates ABIInternal calls that go through ABI wrappers. By porting
them to use ABIInternal natively, we avoid the overhead of the ABI
wrapper.

Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
---
M src/runtime/asm_amd64.s
M src/runtime/memclr_amd64.s
M src/runtime/memmove_amd64.s
M src/runtime/stubs.go
4 files changed, 169 insertions(+), 58 deletions(-)

diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s
index 77f4939..20b8664 100644
--- a/src/runtime/asm_amd64.s
+++ b/src/runtime/asm_amd64.s
@@ -1011,34 +1011,62 @@

// func memhash(p unsafe.Pointer, h, s uintptr) uintptr
// hash function using AES hardware instructions
-TEXT runtime·memhash(SB),NOSPLIT,$0-32
+TEXT runtime·memhash<ABIInternal>(SB),NOSPLIT,$0-32
+#ifdef GOEXPERIMENT_regabiargs
+ // AX = ptr to data
+ // BX = seed
+ // CX = size
+#endif
CMPB runtime·useAeshash(SB), $0
JEQ noaes
+#ifndef GOEXPERIMENT_regabiargs
MOVQ p+0(FP), AX // ptr to data
MOVQ s+16(FP), CX // size
LEAQ ret+24(FP), DX
+#endif
JMP aeshashbody<>(SB)
noaes:
- JMP runtime·memhashFallback(SB)
+ JMP runtime·memhashFallback<ABIInternal>(SB)

// func strhash(p unsafe.Pointer, h uintptr) uintptr
-TEXT runtime·strhash(SB),NOSPLIT,$0-24
+TEXT runtime·strhash<ABIInternal>(SB),NOSPLIT,$0-24
+#ifdef GOEXPERIMENT_regabiargs
+ // AX = ptr to string struct
+ // BX = seed
+#endif
CMPB runtime·useAeshash(SB), $0
JEQ noaes
+#ifndef GOEXPERIMENT_regabiargs
MOVQ p+0(FP), AX // ptr to string struct
+#endif
MOVQ 8(AX), CX // length of string
MOVQ (AX), AX // string data
+#ifndef GOEXPERIMENT_regabiargs
LEAQ ret+16(FP), DX
+#endif
JMP aeshashbody<>(SB)
noaes:
- JMP runtime·strhashFallback(SB)
+ JMP runtime·strhashFallback<ABIInternal>(SB)

// AX: data
+#ifdef GOEXPERIMENT_regabiargs
+// BX: hash seed
+#else
+// h+8(FP): hash seed
+#endif
// CX: length
+#ifdef GOEXPERIMENT_regabiargs
+// At return: AX = return value
+#else
// DX: address to put return value
+#endif
TEXT aeshashbody<>(SB),NOSPLIT,$0-0
// Fill an SSE register with our seeds.
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ BX, X0 // 64 bits of per-table hash seed
+#else
MOVQ h+8(FP), X0 // 64 bits of per-table hash seed
+#endif
PINSRW $4, CX, X0 // 16 bits of length
PSHUFHW $0, X0, X0 // repeat length 4 times total
MOVO X0, X1 // save unscrambled seed
@@ -1075,7 +1103,11 @@
AESENC X1, X1 // scramble combo 3 times
AESENC X1, X1
AESENC X1, X1
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ X1, AX // return X1
+#else
MOVQ X1, (DX)
+#endif
RET

endofpage:
@@ -1091,7 +1123,11 @@
aes0:
// Return scrambled input seed
AESENC X0, X0
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ X0, AX // return X0
+#else
MOVQ X0, (DX)
+#endif
RET

aes16:
@@ -1121,7 +1157,11 @@

// combine results
PXOR X3, X2
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ X2, AX // return X2
+#else
MOVQ X2, (DX)
+#endif
RET

aes33to64:
@@ -1163,7 +1203,11 @@
PXOR X6, X4
PXOR X7, X5
PXOR X5, X4
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ X4, AX // return X4
+#else
MOVQ X4, (DX)
+#endif
RET

aes65to128:
@@ -1245,7 +1289,13 @@
PXOR X10, X8
PXOR X11, X9
PXOR X9, X8
+#ifdef GOEXPERIMENT_regabiargs
+ // X15 must be zero on return
+ XORPS X15, X15
+ MOVQ X8, AX // return X8
+#else
MOVQ X8, (DX)
+#endif
RET

aes129plus:
@@ -1361,38 +1411,70 @@
PXOR X10, X8
PXOR X11, X9
PXOR X9, X8
+#ifdef GOEXPERIMENT_regabiargs
+ // X15 must be zero on return
+ XORPS X15, X15
+ MOVQ X8, AX // return X8
+#else
MOVQ X8, (DX)
+#endif
RET

// func memhash32(p unsafe.Pointer, h uintptr) uintptr
-TEXT runtime·memhash32(SB),NOSPLIT,$0-24
+// ABIInternal for performance.
+TEXT runtime·memhash32<ABIInternal>(SB),NOSPLIT,$0-24
+#ifdef GOEXPERIMENT_regabiargs
+ // AX = ptr to data
+ // BX = seed
+#endif
CMPB runtime·useAeshash(SB), $0
JEQ noaes
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ BX, X0 // X0 = seed
+#else
MOVQ p+0(FP), AX // ptr to data
MOVQ h+8(FP), X0 // seed
+#endif
PINSRD $2, (AX), X0 // data
AESENC runtime·aeskeysched+0(SB), X0
AESENC runtime·aeskeysched+16(SB), X0
AESENC runtime·aeskeysched+32(SB), X0
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ X0, AX // return X0
+#else
MOVQ X0, ret+16(FP)
+#endif
RET
noaes:
- JMP runtime·memhash32Fallback(SB)
+ JMP runtime·memhash32Fallback<ABIInternal>(SB)

// func memhash64(p unsafe.Pointer, h uintptr) uintptr
-TEXT runtime·memhash64(SB),NOSPLIT,$0-24
+// ABIInternal for performance.
+TEXT runtime·memhash64<ABIInternal>(SB),NOSPLIT,$0-24
+#ifdef GOEXPERIMENT_regabiargs
+ // AX = ptr to data
+ // BX = seed
+#endif
CMPB runtime·useAeshash(SB), $0
JEQ noaes
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ BX, X0 // X0 = seed
+#else
MOVQ p+0(FP), AX // ptr to data
MOVQ h+8(FP), X0 // seed
+#endif
PINSRQ $1, (AX), X0 // data
AESENC runtime·aeskeysched+0(SB), X0
AESENC runtime·aeskeysched+16(SB), X0
AESENC runtime·aeskeysched+32(SB), X0
+#ifdef GOEXPERIMENT_regabiargs
+ MOVQ X0, AX // return X0
+#else
MOVQ X0, ret+16(FP)
+#endif
RET
noaes:
- JMP runtime·memhash64Fallback(SB)
+ JMP runtime·memhash64Fallback<ABIInternal>(SB)

// simple mask to get rid of data in the high part of the register.
DATA masks<>+0x00(SB)/8, $0x0000000000000000
diff --git a/src/runtime/memclr_amd64.s b/src/runtime/memclr_amd64.s
index 37fe974..b4bc998 100644
--- a/src/runtime/memclr_amd64.s
+++ b/src/runtime/memclr_amd64.s
@@ -12,9 +12,16 @@
// See memclrNoHeapPointers Go doc for important implementation constraints.

// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
-TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-16
+// ABIInternal for performance.
+TEXT runtime·memclrNoHeapPointers<ABIInternal>(SB), NOSPLIT, $0-16
+#ifdef GOEXPERIMENT_regabiargs
+ // AX = ptr
+ // BX = n
+ MOVQ AX, DI // DI = ptr
+#else
MOVQ ptr+0(FP), DI
MOVQ n+8(FP), BX
+#endif
XORQ AX, AX

// MOVOU seems always faster than REP STOSQ.
@@ -31,7 +38,9 @@
JE _8
CMPQ BX, $16
JBE _9through16
- PXOR X0, X0
+#ifndef GOEXPERIMENT_regabig
+ PXOR X15, X15
+#endif
CMPQ BX, $32
JBE _17through32
CMPQ BX, $64
@@ -45,22 +54,22 @@
// TODO: for really big clears, use MOVNTDQ, even without AVX2.

loop:
- MOVOU X0, 0(DI)
- MOVOU X0, 16(DI)
- MOVOU X0, 32(DI)
- MOVOU X0, 48(DI)
- MOVOU X0, 64(DI)
- MOVOU X0, 80(DI)
- MOVOU X0, 96(DI)
- MOVOU X0, 112(DI)
- MOVOU X0, 128(DI)
- MOVOU X0, 144(DI)
- MOVOU X0, 160(DI)
- MOVOU X0, 176(DI)
- MOVOU X0, 192(DI)
- MOVOU X0, 208(DI)
- MOVOU X0, 224(DI)
- MOVOU X0, 240(DI)
+ MOVOU X15, 0(DI)
+ MOVOU X15, 16(DI)
+ MOVOU X15, 32(DI)
+ MOVOU X15, 48(DI)
+ MOVOU X15, 64(DI)
+ MOVOU X15, 80(DI)
+ MOVOU X15, 96(DI)
+ MOVOU X15, 112(DI)
+ MOVOU X15, 128(DI)
+ MOVOU X15, 144(DI)
+ MOVOU X15, 160(DI)
+ MOVOU X15, 176(DI)
+ MOVOU X15, 192(DI)
+ MOVOU X15, 208(DI)
+ MOVOU X15, 224(DI)
+ MOVOU X15, 240(DI)
SUBQ $256, BX
ADDQ $256, DI
CMPQ BX, $256
@@ -141,40 +150,40 @@
MOVQ AX, -8(DI)(BX*1)
RET
_17through32:
- MOVOU X0, (DI)
- MOVOU X0, -16(DI)(BX*1)
+ MOVOU X15, (DI)
+ MOVOU X15, -16(DI)(BX*1)
RET
_33through64:
- MOVOU X0, (DI)
- MOVOU X0, 16(DI)
- MOVOU X0, -32(DI)(BX*1)
- MOVOU X0, -16(DI)(BX*1)
+ MOVOU X15, (DI)
+ MOVOU X15, 16(DI)
+ MOVOU X15, -32(DI)(BX*1)
+ MOVOU X15, -16(DI)(BX*1)
RET
_65through128:
- MOVOU X0, (DI)
- MOVOU X0, 16(DI)
- MOVOU X0, 32(DI)
- MOVOU X0, 48(DI)
- MOVOU X0, -64(DI)(BX*1)
- MOVOU X0, -48(DI)(BX*1)
- MOVOU X0, -32(DI)(BX*1)
- MOVOU X0, -16(DI)(BX*1)
+ MOVOU X15, (DI)
+ MOVOU X15, 16(DI)
+ MOVOU X15, 32(DI)
+ MOVOU X15, 48(DI)
+ MOVOU X15, -64(DI)(BX*1)
+ MOVOU X15, -48(DI)(BX*1)
+ MOVOU X15, -32(DI)(BX*1)
+ MOVOU X15, -16(DI)(BX*1)
RET
_129through256:
- MOVOU X0, (DI)
- MOVOU X0, 16(DI)
- MOVOU X0, 32(DI)
- MOVOU X0, 48(DI)
- MOVOU X0, 64(DI)
- MOVOU X0, 80(DI)
- MOVOU X0, 96(DI)
- MOVOU X0, 112(DI)
- MOVOU X0, -128(DI)(BX*1)
- MOVOU X0, -112(DI)(BX*1)
- MOVOU X0, -96(DI)(BX*1)
- MOVOU X0, -80(DI)(BX*1)
- MOVOU X0, -64(DI)(BX*1)
- MOVOU X0, -48(DI)(BX*1)
- MOVOU X0, -32(DI)(BX*1)
- MOVOU X0, -16(DI)(BX*1)
+ MOVOU X15, (DI)
+ MOVOU X15, 16(DI)
+ MOVOU X15, 32(DI)
+ MOVOU X15, 48(DI)
+ MOVOU X15, 64(DI)
+ MOVOU X15, 80(DI)
+ MOVOU X15, 96(DI)
+ MOVOU X15, 112(DI)
+ MOVOU X15, -128(DI)(BX*1)
+ MOVOU X15, -112(DI)(BX*1)
+ MOVOU X15, -96(DI)(BX*1)
+ MOVOU X15, -80(DI)(BX*1)
+ MOVOU X15, -64(DI)(BX*1)
+ MOVOU X15, -48(DI)(BX*1)
+ MOVOU X15, -32(DI)(BX*1)
+ MOVOU X15, -16(DI)(BX*1)
RET
diff --git a/src/runtime/memmove_amd64.s b/src/runtime/memmove_amd64.s
index d91641a..df38551 100644
--- a/src/runtime/memmove_amd64.s
+++ b/src/runtime/memmove_amd64.s
@@ -31,11 +31,20 @@
// See memmove Go doc for important implementation constraints.

// func memmove(to, from unsafe.Pointer, n uintptr)
-TEXT runtime·memmove(SB), NOSPLIT, $0-24
-
+// ABIInternal for performance.
+TEXT runtime·memmove<ABIInternal>(SB), NOSPLIT, $0-24
+#ifdef GOEXPERIMENT_regabiargs
+ // AX = to
+ // BX = from
+ // CX = n
+ MOVQ AX, DI
+ MOVQ BX, SI
+ MOVQ CX, BX
+#else
MOVQ to+0(FP), DI
MOVQ from+8(FP), SI
MOVQ n+16(FP), BX
+#endif

// REP instructions have a high startup cost, so we handle small sizes
// with some straightline code. The REP MOVSQ instruction is really fast
@@ -244,6 +253,10 @@
MOVOU X13, -48(DI)(BX*1)
MOVOU X14, -32(DI)(BX*1)
MOVOU X15, -16(DI)(BX*1)
+#ifdef GOEXPERIMENT_regabiargs
+ // X15 must be zero on return
+ XORPS X15, X15
+#endif
RET
move_256through2048:
SUBQ $256, BX
@@ -283,6 +296,10 @@
LEAQ 256(SI), SI
LEAQ 256(DI), DI
JGE move_256through2048
+#ifdef GOEXPERIMENT_regabiargs
+ // X15 must be zero on return
+ XORPS X15, X15
+#endif
JMP tail

avxUnaligned:
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index f635d94..16d7583 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -109,6 +109,9 @@
//go:noescape
func memmove(to, from unsafe.Pointer, n uintptr)

+// Outside assembly calls memmove. Make sure it has ABI wrappers.
+//go:linkname memmove
+
//go:linkname reflect_memmove reflect.memmove
func reflect_memmove(to, from unsafe.Pointer, n uintptr) {
memmove(to, from, n)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Cherry Zhang <cher...@google.com>
Gerrit-MessageType: newchange

Austin Clements (Gerrit)

unread,
Apr 9, 2021, 10:49:06 AM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, Cherry Zhang, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek, Cherry Zhang.

Patch set 1:Run-TryBot +1

View Change

1 comment:

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Cherry Zhang <cher...@google.com>
Gerrit-Comment-Date: Fri, 09 Apr 2021 14:49:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Cherry Zhang (Gerrit)

unread,
Apr 9, 2021, 1:58:20 PM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Patch set 1:Code-Review +2

View Change

3 comments:


    • // AX = ptr to data

    • 	// BX = seed
      // CX = size
      #endif

      I guess this is fine, but a little weird for an ifdef block that contains only comments.

  • File src/runtime/stubs.go:

    • Patch Set #1, Line 112: // Outside assembly calls memmove. Make sure it has ABI wrappers.

      How do you feed about just breaking them...

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 1
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Fri, 09 Apr 2021 17:58:16 +0000

Cherry Zhang (Gerrit)

unread,
Apr 9, 2021, 1:59:59 PM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Patch set 2:Code-Review +2

View Change

1 comment:

  • File src/runtime/memmove_amd64.s:

    • Patch Set #1, Line 256: #ifdef GOEXPERIMENT_regabiargs

      I think the register needs to be zeroed when regabig is enabled (regabiargs may not be enabled). (Also other places.)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 2
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Fri, 09 Apr 2021 17:59:54 +0000

Austin Clements (Gerrit)

unread,
Apr 9, 2021, 2:09:30 PM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, Cherry Zhang, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek.

View Change

1 comment:

  • File src/runtime/memmove_amd64.s:

    • I think the register needs to be zeroed when regabig is enabled (regabiargs may not be enabled). […]

      Oh, you're right, because we're calling this an ABIInternal function regardless of experiment configuration now. Done.

      PTAL.

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 2
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Fri, 09 Apr 2021 18:09:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Cherry Zhang <cher...@google.com>
Gerrit-MessageType: comment

Austin Clements (Gerrit)

unread,
Apr 9, 2021, 2:27:17 PM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Cherry Zhang, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek, Cherry Zhang.

View Change

4 comments:

    • For register ABI, the frame size does not include the result. (Not sure how much it matters. […]

      Fixed.

      (This happened with panicIndex/Slice, too.)

    • Patch Set #1, Line 1015:

      #ifdef GOEXPERIMENT_regabiargs
      // AX = ptr to data
      // BX = seed
      // CX = size
      #endif

      I guess this is fine, but a little weird for an ifdef block that contains only comments.

    • I agree it's a little weird. The idea is that when we pull out the non-experiment path, we'll wind up with the right comments.

  • File src/runtime/stubs.go:

    • Patch Set #1, Line 112: // Outside assembly calls memmove. Make sure it has ABI wrappers.

      How do you feed about just breaking them...

    • Bad. :(

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 2
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Cherry Zhang <cher...@google.com>
Gerrit-Comment-Date: Fri, 09 Apr 2021 18:27:11 +0000

Austin Clements (Gerrit)

unread,
Apr 9, 2021, 2:39:42 PM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek, Cherry Zhang.

Austin Clements uploaded patch set #3 to this change.

View Change

runtime: port performance-critical functions to regabi

DO NOT SUBMIT. Needs benchmarks (early results are looking good but
not perfect).

This CL ports a few performance-critical runtime assembly functions to
use register arguments directly. While using the faster ABI is nice,
the real win here is that we avoid ABI wrappers: since these are
"builtin" functions in the compiler, it can generate calls to them
without knowing that their native implementation is ABI0. Hence, it
generates ABIInternal calls that go through ABI wrappers. By porting
them to use ABIInternal natively, we avoid the overhead of the ABI
wrapper.

Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
---
M src/runtime/asm_amd64.s
M src/runtime/memclr_amd64.s
M src/runtime/memmove_amd64.s
M src/runtime/stubs.go
4 files changed, 183 insertions(+), 58 deletions(-)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 3
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Cherry Zhang <cher...@google.com>
Gerrit-MessageType: newpatchset

Cherry Zhang (Gerrit)

unread,
Apr 9, 2021, 3:58:34 PM4/9/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Patch set 3:Code-Review +2

View Change

1 comment:

  • File src/runtime/asm_amd64.s:

    • Fixed. […]

      I _think_ the spill slots are actually included, so this will be 24 for regabiargs. This is what I saw on the compiler side. I still haven't thought carefully what it implies.

      Stack scanning at morestack might need that, but these are all nosplit. Defer is another case where argument size matters, but we now only defer argument-less functions. Maybe it doesn't matter.

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 3
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Fri, 09 Apr 2021 19:58:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Austin Clements <aus...@google.com>

Austin Clements (Gerrit)

unread,
Apr 11, 2021, 4:08:14 PM4/11/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Cherry Zhang, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek.

View Change

1 comment:

  • File src/runtime/asm_amd64.s:

    • I _think_ the spill slots are actually included, so this will be 24 for regabiargs. […]

      Oh no, you're right. But I also think you're right that it doesn't matter... Fixed. (Again (I hope))

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 3
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Sun, 11 Apr 2021 20:08:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

Austin Clements (Gerrit)

unread,
Apr 11, 2021, 4:08:26 PM4/11/21
to Austin Clements, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek.

Austin Clements uploaded patch set #4 to this change.

View Change

runtime: port performance-critical functions to regabi

This CL ports a few performance-critical runtime assembly functions to
use register arguments directly. While using the faster ABI is nice,
the real win here is that we avoid ABI wrappers: since these are
"builtin" functions in the compiler, it can generate calls to them
without knowing that their native implementation is ABI0. Hence, it
generates ABIInternal calls that go through ABI wrappers. By porting
them to use ABIInternal natively, we avoid the overhead of the ABI
wrapper.

This significantly improves performance on several benchmarks,
comparing regabiwrappers before and after this change:

name old time/op new time/op delta
BiogoIgor 15.7s ± 2% 15.7s ± 2% ~ (p=0.617 n=25+25)
BiogoKrishna 18.5s ± 5% 17.7s ± 2% -4.61% (p=0.000 n=25+25)
BleveIndexBatch100 5.91s ± 3% 5.82s ± 3% -1.60% (p=0.000 n=25+25)
BleveQuery 6.76s ± 0% 6.60s ± 1% -2.31% (p=0.000 n=22+25)
CompileTemplate 248ms ± 5% 245ms ± 1% ~ (p=0.643 n=25+20)
CompileUnicode 94.4ms ± 3% 93.9ms ± 2% ~ (p=0.152 n=24+23)
CompileGoTypes 1.60s ± 2% 1.59s ± 2% ~ (p=0.059 n=24+24)
CompileCompiler 104ms ± 3% 103ms ± 1% ~ (p=0.056 n=25+22)
CompileSSA 10.9s ± 1% 10.9s ± 1% ~ (p=0.052 n=25+25)
CompileFlate 156ms ± 8% 152ms ± 1% -2.49% (p=0.008 n=25+21)
CompileGoParser 248ms ± 1% 249ms ± 2% ~ (p=0.058 n=21+20)
CompileReflect 595ms ± 3% 601ms ± 4% ~ (p=0.182 n=25+25)
CompileTar 211ms ± 2% 211ms ± 1% ~ (p=0.663 n=23+23)
CompileXML 282ms ± 2% 284ms ± 5% ~ (p=0.456 n=21+23)
CompileStdCmd 13.6s ± 2% 13.5s ± 2% ~ (p=0.112 n=25+24)
FoglemanFauxGLRenderRotateBoat 8.69s ± 2% 8.67s ± 0% ~ (p=0.094 n=22+25)
FoglemanPathTraceRenderGopherIter1 20.2s ± 2% 20.7s ± 3% +2.53% (p=0.000 n=24+24)
GopherLuaKNucleotide 31.4s ± 1% 31.0s ± 1% -1.28% (p=0.000 n=25+24)
MarkdownRenderXHTML 246ms ± 1% 244ms ± 1% -0.79% (p=0.000 n=20+21)
Tile38WithinCircle100kmRequest 843µs ± 4% 818µs ± 4% -2.93% (p=0.000 n=25+25)
Tile38IntersectsCircle100kmRequest 1.06ms ± 5% 1.05ms ± 3% -1.19% (p=0.021 n=24+25)
Tile38KNearestLimit100Request 1.01ms ± 1% 1.01ms ± 2% ~ (p=0.335 n=22+25)
[Geo mean] 596ms 592ms -0.71%

(https://perf.golang.org/search?q=upload:20210411.5)

It also significantly reduces the performance penalty of enabling
regabiwrappers, though it doesn't yet fully close the gap on all
benchmarks:

name old time/op new time/op delta
BiogoIgor 15.7s ± 1% 15.7s ± 2% ~ (p=0.366 n=24+25)
BiogoKrishna 17.7s ± 2% 17.7s ± 2% ~ (p=0.315 n=23+25)
BleveIndexBatch100 5.86s ± 4% 5.82s ± 3% ~ (p=0.137 n=24+25)
BleveQuery 6.55s ± 0% 6.60s ± 1% +0.83% (p=0.000 n=24+25)
CompileTemplate 244ms ± 1% 245ms ± 1% ~ (p=0.208 n=21+20)
CompileUnicode 94.0ms ± 4% 93.9ms ± 2% ~ (p=0.666 n=24+23)
CompileGoTypes 1.60s ± 2% 1.59s ± 2% ~ (p=0.154 n=25+24)
CompileCompiler 103ms ± 1% 103ms ± 1% ~ (p=0.905 n=24+22)
CompileSSA 10.9s ± 2% 10.9s ± 1% ~ (p=0.803 n=25+25)
CompileFlate 153ms ± 1% 152ms ± 1% ~ (p=0.182 n=23+21)
CompileGoParser 250ms ± 2% 249ms ± 2% ~ (p=0.843 n=24+20)
CompileReflect 595ms ± 4% 601ms ± 4% ~ (p=0.141 n=25+25)
CompileTar 212ms ± 3% 211ms ± 1% ~ (p=0.499 n=23+23)
CompileXML 282ms ± 1% 284ms ± 5% ~ (p=0.129 n=20+23)
CompileStdCmd 13.5s ± 2% 13.5s ± 2% ~ (p=0.480 n=24+24)
FoglemanFauxGLRenderRotateBoat 8.66s ± 1% 8.67s ± 0% ~ (p=0.325 n=25+25)
FoglemanPathTraceRenderGopherIter1 20.6s ± 3% 20.7s ± 3% ~ (p=0.137 n=25+24)
GopherLuaKNucleotide 30.5s ± 2% 31.0s ± 1% +1.68% (p=0.000 n=23+24)
MarkdownRenderXHTML 243ms ± 1% 244ms ± 1% +0.51% (p=0.000 n=23+21)
Tile38WithinCircle100kmRequest 801µs ± 2% 818µs ± 4% +2.11% (p=0.000 n=25+25)
Tile38IntersectsCircle100kmRequest 1.01ms ± 2% 1.05ms ± 3% +4.34% (p=0.000 n=24+25)
Tile38KNearestLimit100Request 1.00ms ± 1% 1.01ms ± 2% +0.81% (p=0.008 n=21+25)
[Geo mean] 589ms 592ms +0.50%

(https://perf.golang.org/search?q=upload:20210411.6)


Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
---
M src/runtime/asm_amd64.s
M src/runtime/memclr_amd64.s
M src/runtime/memmove_amd64.s
M src/runtime/stubs.go
4 files changed, 183 insertions(+), 58 deletions(-)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 4
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-MessageType: newpatchset

Cherry Zhang (Gerrit)

unread,
Apr 12, 2021, 11:41:48 AM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Patch set 4:Code-Review +2

View Change

2 comments:

    • Oh no, you're right. But I also think you're right that it doesn't matter... Fixed. […]

      Is PS4 the one I'm supposed to be looking at? It seems the same as PS3, with 0 argument area sizes.

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 4
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 15:41:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Austin Clements (Gerrit)

unread,
Apr 12, 2021, 11:45:58 AM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Austin Clements uploaded patch set #5 to this change.

View Change

4 files changed, 184 insertions(+), 59 deletions(-)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 5
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-MessageType: newpatchset

Austin Clements (Gerrit)

unread,
Apr 12, 2021, 11:47:36 AM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Cherry Zhang, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek.

View Change

1 comment:

  • File src/runtime/asm_amd64.s:

    • Is PS4 the one I'm supposed to be looking at? It seems the same as PS3, with 0 argument area sizes.

      Now I'm super confused and the only explanation I can think of is that I must have somehow lost the argument size fixes in a rebase disaster. PTAL at PS5.

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 5
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 15:47:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

Cherry Zhang (Gerrit)

unread,
Apr 12, 2021, 11:54:52 AM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Patch set 5:Code-Review +2

View Change

1 comment:

  • File src/runtime/asm_amd64.s:

    • Now I'm super confused and the only explanation I can think of is that I must have somehow lost the […]

      Why 8? I think it is 24, for the spill slots of three args. Also for the functions below, just one fewer word for the result.

      Also memmove and memclr in the other files. I think the arg area size is the same for both ABIs.

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 5
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 15:54:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

Cherry Zhang (Gerrit)

unread,
Apr 12, 2021, 12:27:50 PM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

View Change

1 comment:

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 5
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 16:27:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Austin Clements (Gerrit)

unread,
Apr 12, 2021, 1:01:30 PM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Cherry Zhang, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek.

View Change

2 comments:

  • Patchset:

    • Patch Set #5:

      > Patch Set 5: TryBot-Result-1 […]

      vet is getting increasingly unhelpful for these ABIInternal functions, I'm afraid. But they're also buried in so much preprocessor goo that I think we'll have to fix golang.org/cl/17544 before we can really address this.

  • File src/runtime/asm_amd64.s:

    • Why 8? I think it is 24, for the spill slots of three args. […]

      Restored the original argument sizes to keep vet happy. ¯\_(ツ)_/¯

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 5
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 17:01:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

Austin Clements (Gerrit)

unread,
Apr 12, 2021, 1:01:54 PM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Michael Knyszek.

Austin Clements uploaded patch set #6 to this change.

View Change

4 files changed, 174 insertions(+), 58 deletions(-)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 6
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-MessageType: newpatchset

Cherry Zhang (Gerrit)

unread,
Apr 12, 2021, 1:05:12 PM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, Go Bot, Michael Knyszek, golang-co...@googlegroups.com

Attention is currently required from: Austin Clements, Michael Knyszek.

Patch set 6:Code-Review +2

View Change

1 comment:

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 6
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Austin Clements <aus...@google.com>
Gerrit-Attention: Michael Knyszek <mkny...@google.com>
Gerrit-Comment-Date: Mon, 12 Apr 2021 17:05:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Austin Clements (Gerrit)

unread,
Apr 12, 2021, 2:08:54 PM4/12/21
to Austin Clements, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go Bot, Cherry Zhang, Michael Knyszek, golang-co...@googlegroups.com

Austin Clements submitted this change.

View Change

Approvals: Cherry Zhang: Looks good to me, approved Austin Clements: Trusted; Run TryBots Go Bot: TryBots succeeded
Reviewed-on: https://go-review.googlesource.com/c/go/+/308931
Trust: Austin Clements <aus...@google.com>
Run-TryBot: Austin Clements <aus...@google.com>
Reviewed-by: Cherry Zhang <cher...@google.com>
TryBot-Result: Go Bot <go...@golang.org>

---
M src/runtime/asm_amd64.s
M src/runtime/memclr_amd64.s
M src/runtime/memmove_amd64.s
M src/runtime/stubs.go
4 files changed, 174 insertions(+), 58 deletions(-)

diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s
index 77f4939..e883f20 100644
@@ -1245,7 +1289,15 @@

PXOR X10, X8
PXOR X11, X9
PXOR X9, X8
+#ifdef GOEXPERIMENT_regabig

+ // X15 must be zero on return
+	PXOR	X15, X15
+#endif
+#ifdef GOEXPERIMENT_regabiargs

+ MOVQ X8, AX // return X8
+#else
MOVQ X8, (DX)
+#endif
RET

aes129plus:
@@ -1361,38 +1413,73 @@

PXOR X10, X8
PXOR X11, X9
PXOR X9, X8
+#ifdef GOEXPERIMENT_regabig

+ // X15 must be zero on return
+	PXOR	X15, X15
+#endif
+#ifdef GOEXPERIMENT_regabiargs
+	// AX = ptr to data
+ // BX = seed
+#else
index d91641a..f1e3403 100644
+#ifdef GOEXPERIMENT_regabig

+ // X15 must be zero on return
+	PXOR	X15, X15

+#endif
RET
move_256through2048:
SUBQ $256, BX
@@ -283,6 +296,10 @@
LEAQ 256(SI), SI
LEAQ 256(DI), DI
JGE move_256through2048
+#ifdef GOEXPERIMENT_regabig

+ // X15 must be zero on return
+	PXOR	X15, X15

+#endif
JMP tail

avxUnaligned:
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index f635d94..16d7583 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -109,6 +109,9 @@
//go:noescape
func memmove(to, from unsafe.Pointer, n uintptr)

+// Outside assembly calls memmove. Make sure it has ABI wrappers.
+//go:linkname memmove
+
//go:linkname reflect_memmove reflect.memmove
func reflect_memmove(to, from unsafe.Pointer, n uintptr) {
memmove(to, from, n)

To view, visit change 308931. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Gerrit-Change-Number: 308931
Gerrit-PatchSet: 7
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Cherry Zhang <cher...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages