runtime: rename fastrand1 to fastrand
Change-Id: I37706ff0a3486827c5b072c95ad890ea87ede847
Reviewed-on: https://go-review.googlesource.com/28210
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/src/runtime/alg.go b/src/runtime/alg.go
index 147332e..80f205c 100644
--- a/src/runtime/alg.go
+++ b/src/runtime/alg.go
@@ -109,7 +109,7 @@
case f == 0:
return c1 * (c0 ^ h) // +0, -0
case f != f:
- return c1 * (c0 ^ h ^ uintptr(fastrand1())) // any kind of NaN
+ return c1 * (c0 ^ h ^ uintptr(fastrand())) // any kind of NaN
default:
return memhash(p, h, 4)
}
@@ -121,7 +121,7 @@
case f == 0:
return c1 * (c0 ^ h) // +0, -0
case f != f:
- return c1 * (c0 ^ h ^ uintptr(fastrand1())) // any kind of NaN
+ return c1 * (c0 ^ h ^ uintptr(fastrand())) // any kind of NaN
default:
return memhash(p, h, 8)
}
diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s
index f039fbf..1203822 100644
--- a/src/runtime/asm_386.s
+++ b/src/runtime/asm_386.s
@@ -1573,7 +1573,7 @@
MOVL BX, (AX)
RET
-TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand(SB), NOSPLIT, $0-4
get_tls(CX)
MOVL g(CX), AX
MOVL g_m(AX), AX
diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s
index 3383bbe..f44fc11 100644
--- a/src/runtime/asm_amd64.s
+++ b/src/runtime/asm_amd64.s
@@ -2052,7 +2052,7 @@
MOVB $0, ret+48(FP)
RET
-TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand(SB), NOSPLIT, $0-4
get_tls(CX)
MOVQ g(CX), AX
MOVQ g_m(AX), AX
diff --git a/src/runtime/asm_amd64p32.s b/src/runtime/asm_amd64p32.s
index dec77e9..6aa2308 100644
--- a/src/runtime/asm_amd64p32.s
+++ b/src/runtime/asm_amd64p32.s
@@ -973,7 +973,7 @@
MOVB AX, ret+24(FP)
RET
-TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand(SB), NOSPLIT, $0-4
get_tls(CX)
MOVL g(CX), AX
MOVL g_m(AX), AX
diff --git a/src/runtime/asm_arm.s b/src/runtime/asm_arm.s
index 59a0e75..29f39cf 100644
--- a/src/runtime/asm_arm.s
+++ b/src/runtime/asm_arm.s
@@ -952,7 +952,7 @@
MOVW R0, ret+12(FP)
RET
-TEXT runtime·fastrand1(SB),NOSPLIT,$-4-4
+TEXT runtime·fastrand(SB),NOSPLIT,$-4-4
MOVW g_m(g), R1
MOVW m_fastrand(R1), R0
ADD.S R0, R0
diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s
index 2fb4eea..066b534 100644
--- a/src/runtime/asm_arm64.s
+++ b/src/runtime/asm_arm64.s
@@ -949,7 +949,7 @@
MOVB R0, ret+48(FP)
RET
-TEXT runtime·fastrand1(SB),NOSPLIT,$-8-4
+TEXT runtime·fastrand(SB),NOSPLIT,$-8-4
MOVD g_m(g), R1
MOVWU m_fastrand(R1), R0
ADD R0, R0
diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s
index 098de41..15105b9 100644
--- a/src/runtime/asm_mips64x.s
+++ b/src/runtime/asm_mips64x.s
@@ -822,7 +822,7 @@
MOVV R1, ret+24(FP)
RET
-TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand(SB), NOSPLIT, $0-4
MOVV g_m(g), R2
MOVWU m_fastrand(R2), R1
ADDU R1, R1
diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s
index 3bff886..67b3d50 100644
--- a/src/runtime/asm_ppc64x.s
+++ b/src/runtime/asm_ppc64x.s
@@ -1042,7 +1042,7 @@
MOVD R8, (R7)
RET
-TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand(SB), NOSPLIT, $0-4
MOVD g_m(g), R4
MOVWZ m_fastrand(R4), R3
ADD R3, R3
diff --git a/src/runtime/asm_s390x.s b/src/runtime/asm_s390x.s
index 896ccde..cf0ed1a 100644
--- a/src/runtime/asm_s390x.s
+++ b/src/runtime/asm_s390x.s
@@ -874,7 +874,7 @@
CLC $1, 0(R3), 0(R5)
RET
-TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand(SB), NOSPLIT, $0-4
MOVD g_m(g), R4
MOVWZ m_fastrand(R4), R3
ADD R3, R3
diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go
index f756e7b..9d8c2f8 100644
--- a/src/runtime/hashmap.go
+++ b/src/runtime/hashmap.go
@@ -256,7 +256,7 @@
h.count = 0
h.B = B
h.flags = 0
- h.hash0 = fastrand1()
+ h.hash0 = fastrand()
h.buckets = buckets
h.oldbuckets = nil
h.nevacuate = 0
@@ -655,9 +655,9 @@
}
// decide where to start
- r := uintptr(fastrand1())
+ r := uintptr(fastrand())
if h.B > 31-bucketCntBits {
- r += uintptr(fastrand1()) << 31
+ r += uintptr(fastrand()) << 31
}
it.startBucket = r & (uintptr(1)<<h.B - 1)
it.offset = uint8(r >> h.B & (bucketCnt - 1))
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 7d7f9e11..4f0a2ce 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -843,7 +843,7 @@
// x = -log_e(q) * period
// x = log_2(q) * (-log_e(2)) * period ; Using log_2 for efficiency
const randomBitCount = 26
- q := fastrand1()%(1<<randomBitCount) + 1
+ q := fastrand()%(1<<randomBitCount) + 1
qlog := fastlog2(float64(q)) - randomBitCount
if qlog > 0 {
qlog = 0
@@ -861,7 +861,7 @@
rate = 0x3fffffff
}
if rate != 0 {
- return int32(int(fastrand1()) % (2 * rate))
+ return int32(int(fastrand()) % (2 * rate))
}
return 0
}
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index cd5ddad..f184d81 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -616,7 +616,7 @@
}
myID := gp.m.p.ptr().id
for tries := 0; tries < 5; tries++ {
- id := int32(fastrand1() % uint32(gomaxprocs-1))
+ id := int32(fastrand() % uint32(gomaxprocs-1))
if id >= myID {
id++
}
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go
index c3e4e2c..37b5e1b 100644
--- a/src/runtime/mprof.go
+++ b/src/runtime/mprof.go
@@ -289,7 +289,7 @@
cycles = 1
}
rate := int64(atomic.Load64(&blockprofilerate))
- if rate <= 0 || (rate > cycles && int64(fastrand1())%rate > cycles) {
+ if rate <= 0 || (rate > cycles && int64(fastrand())%rate > cycles) {
return
}
gp := getg()
diff --git a/src/runtime/os_darwin_arm.go b/src/runtime/os_darwin_arm.go
index 1ccc959..ee1bd17 100644
--- a/src/runtime/os_darwin_arm.go
+++ b/src/runtime/os_darwin_arm.go
@@ -17,8 +17,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/os_darwin_arm64.go b/src/runtime/os_darwin_arm64.go
index 4d35af9..8de132d 100644
--- a/src/runtime/os_darwin_arm64.go
+++ b/src/runtime/os_darwin_arm64.go
@@ -6,8 +6,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/os_freebsd_arm.go b/src/runtime/os_freebsd_arm.go
index 1f2add2..0399499 100644
--- a/src/runtime/os_freebsd_arm.go
+++ b/src/runtime/os_freebsd_arm.go
@@ -17,8 +17,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/os_linux_arm.go b/src/runtime/os_linux_arm.go
index 8e2765a..d7d734b 100644
--- a/src/runtime/os_linux_arm.go
+++ b/src/runtime/os_linux_arm.go
@@ -53,8 +53,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed fastrand().
// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // randomNumber provides better seeding of fastrand1.
+ // randomNumber provides better seeding of fastrand.
return nanotime() + int64(randomNumber)
}
diff --git a/src/runtime/os_linux_arm64.go b/src/runtime/os_linux_arm64.go
index 43262ae..bdc341d 100644
--- a/src/runtime/os_linux_arm64.go
+++ b/src/runtime/os_linux_arm64.go
@@ -19,8 +19,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed fastrand().
// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // randomNumber provides better seeding of fastrand1.
+ // randomNumber provides better seeding of fastrand.
return nanotime() + int64(randomNumber)
}
diff --git a/src/runtime/os_linux_mips64x.go b/src/runtime/os_linux_mips64x.go
index 8039b2f..dcc9763 100644
--- a/src/runtime/os_linux_mips64x.go
+++ b/src/runtime/os_linux_mips64x.go
@@ -22,9 +22,9 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed fastrand().
// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // randomNumber provides better seeding of fastrand1.
+ // randomNumber provides better seeding of fastrand.
return nanotime() + int64(randomNumber)
}
diff --git a/src/runtime/os_nacl_arm.go b/src/runtime/os_nacl_arm.go
index f94c183..8669ee7 100644
--- a/src/runtime/os_nacl_arm.go
+++ b/src/runtime/os_nacl_arm.go
@@ -16,8 +16,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/os_netbsd_arm.go b/src/runtime/os_netbsd_arm.go
index 03032e8..95603da 100644
--- a/src/runtime/os_netbsd_arm.go
+++ b/src/runtime/os_netbsd_arm.go
@@ -28,8 +28,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/os_openbsd_arm.go b/src/runtime/os_openbsd_arm.go
index b46fef0..be2e1e9 100644
--- a/src/runtime/os_openbsd_arm.go
+++ b/src/runtime/os_openbsd_arm.go
@@ -17,8 +17,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/os_plan9_arm.go b/src/runtime/os_plan9_arm.go
index 30cde8f..fdce1e7 100644
--- a/src/runtime/os_plan9_arm.go
+++ b/src/runtime/os_plan9_arm.go
@@ -10,8 +10,8 @@
//go:nosplit
func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
+ // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- // TODO: need more entropy to better seed fastrand1.
+ // TODO: need more entropy to better seed fastrand.
return nanotime()
}
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 75e09b3..67e8447 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -1909,7 +1909,7 @@
atomic.Xadd(&sched.nmspinning, 1)
}
for i := 0; i < 4; i++ {
- for enum := stealOrder.start(fastrand1()); !enum.done(); enum.next() {
+ for enum := stealOrder.start(fastrand()); !enum.done(); enum.next() {
if sched.gcwaiting != 0 {
goto top
}
@@ -4034,7 +4034,7 @@
// If the run queue is full, runnext puts g on the global queue.
// Executed only by the owner P.
func runqput(_p_ *p, gp *g, next bool) {
- if randomizeScheduler && next && fastrand1()%2 == 0 {
+ if randomizeScheduler && next && fastrand()%2 == 0 {
next = false
}
@@ -4087,7 +4087,7 @@
if randomizeScheduler {
for i := uint32(1); i <= n; i++ {
- j := fastrand1() % (i + 1)
+ j := fastrand() % (i + 1)
batch[i], batch[j] = batch[j], batch[i]
}
}
diff --git a/src/runtime/select.go b/src/runtime/select.go
index 433048f..1aaafff 100644
--- a/src/runtime/select.go
+++ b/src/runtime/select.go
@@ -270,7 +270,7 @@
pollslice := slice{unsafe.Pointer(sel.pollorder), int(sel.ncase), int(sel.ncase)}
pollorder := *(*[]uint16)(unsafe.Pointer(&pollslice))
for i := 1; i < int(sel.ncase); i++ {
- j := int(fastrand1()) % (i + 1)
+ j := int(fastrand()) % (i + 1)
pollorder[i] = pollorder[j]
pollorder[j] = uint16(i)
}
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index 0f75663..f6bb2fb 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -81,7 +81,7 @@
var hashLoad = loadFactor
// in asm_*.s
-func fastrand1() uint32
+func fastrand() uint32
// in asm_*.s
//go:noescape
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index 4f6fae2..7a37085 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -437,7 +437,7 @@
// a recursive stack's cycle is slightly
// larger than the cache.
if cache != nil {
- ci := fastrand1() % uint32(len(cache.entries))
+ ci := fastrand() % uint32(len(cache.entries))
cache.entries[ci] = pcvalueCacheEnt{
targetpc: targetpc,
off: off,