1
0
mirror of https://github.com/golang/go synced 2024-11-19 09:54:49 -07:00

[dev.garbage] runtime: add prefetcht0, prefetcht1, prefetcht2, prefetcht3, prefetchnta for GC

We don't know what we need yet, so add them all.
Add them even on x86 architectures (as no-ops) so that
the GC can refer to them unconditionally.

Eventually we'll know what we want and probably
have just one 'prefetch' with an appropriate meaning
on each architecture.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/179160043
This commit is contained in:
Russ Cox 2014-11-21 15:57:10 -05:00
parent cc73a44f67
commit 8c3f64022a
7 changed files with 94 additions and 1 deletions

View File

@ -2285,3 +2285,23 @@ TEXT runtime·getg(SB),NOSPLIT,$0-4
MOVL AX, ret+0(FP) MOVL AX, ret+0(FP)
RET RET
TEXT runtime·prefetcht0(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHT0 (AX)
RET
TEXT runtime·prefetcht1(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHT1 (AX)
RET
TEXT runtime·prefetcht2(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHT2 (AX)
RET
TEXT runtime·prefetchnta(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHNTA (AX)
RET

View File

@ -2228,3 +2228,23 @@ TEXT runtime·getg(SB),NOSPLIT,$0-8
MOVQ g(CX), AX MOVQ g(CX), AX
MOVQ AX, ret+0(FP) MOVQ AX, ret+0(FP)
RET RET
TEXT runtime·prefetcht0(SB),NOSPLIT,$0-8
MOVQ addr+0(FP), AX
PREFETCHT0 (AX)
RET
TEXT runtime·prefetcht1(SB),NOSPLIT,$0-8
MOVQ addr+0(FP), AX
PREFETCHT1 (AX)
RET
TEXT runtime·prefetcht2(SB),NOSPLIT,$0-8
MOVQ addr+0(FP), AX
PREFETCHT2 (AX)
RET
TEXT runtime·prefetchnta(SB),NOSPLIT,$0-8
MOVQ addr+0(FP), AX
PREFETCHNTA (AX)
RET

View File

@ -1079,3 +1079,24 @@ TEXT runtime·getg(SB),NOSPLIT,$0-4
MOVL g(CX), AX MOVL g(CX), AX
MOVL AX, ret+0(FP) MOVL AX, ret+0(FP)
RET RET
TEXT runtime·prefetcht0(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHT0 (AX)
RET
TEXT runtime·prefetcht1(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHT1 (AX)
RET
TEXT runtime·prefetcht2(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHT2 (AX)
RET
TEXT runtime·prefetchnta(SB),NOSPLIT,$0-4
MOVL addr+0(FP), AX
PREFETCHNTA (AX)
RET

View File

@ -1320,3 +1320,15 @@ TEXT runtime·goexit(SB),NOSPLIT,$-4-0
TEXT runtime·getg(SB),NOSPLIT,$-4-4 TEXT runtime·getg(SB),NOSPLIT,$-4-4
MOVW g, ret+0(FP) MOVW g, ret+0(FP)
RET RET
TEXT runtime·prefetcht0(SB),NOSPLIT,$0-4
RET
TEXT runtime·prefetcht1(SB),NOSPLIT,$0-4
RET
TEXT runtime·prefetcht2(SB),NOSPLIT,$0-4
RET
TEXT runtime·prefetchnta(SB),NOSPLIT,$0-4
RET

View File

@ -986,3 +986,15 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$0
TEXT runtime·goexit(SB),NOSPLIT,$-8-0 TEXT runtime·goexit(SB),NOSPLIT,$-8-0
MOVD R0, R0 // NOP MOVD R0, R0 // NOP
BL runtime·goexit1(SB) // does not return BL runtime·goexit1(SB) // does not return
TEXT runtime·prefetcht0(SB),NOSPLIT,$0-8
RETURN
TEXT runtime·prefetcht1(SB),NOSPLIT,$0-8
RETURN
TEXT runtime·prefetcht2(SB),NOSPLIT,$0-8
RETURN
TEXT runtime·prefetchnta(SB),NOSPLIT,$0-8
RETURN

View File

@ -97,7 +97,10 @@ func testAtomic64() {
z64 = 42 z64 = 42
x64 = 0 x64 = 0
// TODO: PREFETCH((unsafe.Pointer)(&z64)) prefetcht0(uintptr(unsafe.Pointer(&z64)))
prefetcht1(uintptr(unsafe.Pointer(&z64)))
prefetcht2(uintptr(unsafe.Pointer(&z64)))
prefetchnta(uintptr(unsafe.Pointer(&z64)))
if cas64(&z64, x64, 1) { if cas64(&z64, x64, 1) {
gothrow("cas64 failed") gothrow("cas64 failed")
} }

View File

@ -231,3 +231,8 @@ func call536870912(fn, arg unsafe.Pointer, n, retoffset uint32)
func call1073741824(fn, arg unsafe.Pointer, n, retoffset uint32) func call1073741824(fn, arg unsafe.Pointer, n, retoffset uint32)
func systemstack_switch() func systemstack_switch()
func prefetcht0(addr uintptr)
func prefetcht1(addr uintptr)
func prefetcht2(addr uintptr)
func prefetchnta(addr uintptr)