]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: unify fastrand1 and fastrand2
authorKeith Randall <khr@golang.org>
Tue, 2 Sep 2014 21:33:33 +0000 (14:33 -0700)
committerKeith Randall <khr@golang.org>
Tue, 2 Sep 2014 21:33:33 +0000 (14:33 -0700)
C and Go calling conventions are now compatible, so we
don't need two versions of this function.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/139080043

src/pkg/runtime/alg.go
src/pkg/runtime/asm_386.s
src/pkg/runtime/asm_amd64.s
src/pkg/runtime/asm_amd64p32.s
src/pkg/runtime/asm_arm.s
src/pkg/runtime/hashmap.go
src/pkg/runtime/malloc.go
src/pkg/runtime/runtime.c
src/pkg/runtime/select.go
src/pkg/runtime/stubs.go

index 01fbc931e57a0a8d009e0a41e900682cf55ab5ba..e9ed59503ffbf8fe705a4a256d02b98a083d8493 100644 (file)
@@ -111,7 +111,7 @@ func f32hash(p unsafe.Pointer, s, h uintptr) uintptr {
        case f == 0:
                return c1 * (c0 ^ h) // +0, -0
        case f != f:
-               return c1 * (c0 ^ h ^ uintptr(fastrand2())) // any kind of NaN
+               return c1 * (c0 ^ h ^ uintptr(fastrand1())) // any kind of NaN
        default:
                return memhash(p, 4, h)
        }
@@ -123,7 +123,7 @@ func f64hash(p unsafe.Pointer, s, h uintptr) uintptr {
        case f == 0:
                return c1 * (c0 ^ h) // +0, -0
        case f != f:
-               return c1 * (c0 ^ h ^ uintptr(fastrand2())) // any kind of NaN
+               return c1 * (c0 ^ h ^ uintptr(fastrand1())) // any kind of NaN
        default:
                return memhash(p, 8, h)
        }
index 35805d63c626b19a41c09b80ece60e0737df570f..681a1b68198a9fc0bd81e831ba92f165c9054061 100644 (file)
@@ -2283,7 +2283,7 @@ TEXT runtime·duffcopy(SB), NOSPLIT, $0-0
 TEXT runtime·timenow(SB), NOSPLIT, $0-0
        JMP     time·now(SB)
 
-TEXT runtime·fastrand2(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
        get_tls(CX)
        MOVL    g(CX), AX
        MOVL    g_m(AX), AX
index 07eec9ebb68ce80ea14bc2799add17569f659149..0121b7d86592f7c32fab49dbfe54d7fc7d65deeb 100644 (file)
@@ -2335,7 +2335,7 @@ TEXT runtime·duffcopy(SB), NOSPLIT, $0-0
 TEXT runtime·timenow(SB), NOSPLIT, $0-0
        JMP     time·now(SB)
 
-TEXT runtime·fastrand2(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
        get_tls(CX)
        MOVQ    g(CX), AX
        MOVQ    g_m(AX), AX
index 76a6dc230055e7e9d4447f0438a8e25a590b78c7..03cf9bd4448afacabc8d4999b878c1e70c022b59 100644 (file)
@@ -1208,7 +1208,7 @@ eqret:
 TEXT runtime·timenow(SB), NOSPLIT, $0-0
        JMP     time·now(SB)
 
-TEXT runtime·fastrand2(SB), NOSPLIT, $0-4
+TEXT runtime·fastrand1(SB), NOSPLIT, $0-4
        get_tls(CX)
        MOVL    g(CX), AX
        MOVL    g_m(AX), AX
index 0e87df42b70ddf7b8d974815247f430fd7fc6e6a..87ea9742460f117623dee5d37a35058d5c22311a 100644 (file)
@@ -1259,7 +1259,7 @@ TEXT runtime·duffcopy(SB), NOSPLIT, $0-0
        MOVW.P  R0, 4(R2)
        RET
 
-TEXT runtime·fastrand2(SB), NOSPLIT, $-4-4
+TEXT runtime·fastrand1(SB), NOSPLIT, $-4-4
        MOVW    g_m(g), R1
        MOVW    m_fastrand(R1), R0
        ADD.S   R0, R0
index 309e26db96f11b1ab8828a0dc7653ee5d64e741e..1bdceab8bb18dfc2906064ab1213e2715ca76878 100644 (file)
@@ -219,7 +219,7 @@ func makemap(t *maptype, hint int64) *hmap {
        h.count = 0
        h.B = B
        h.flags = 0
-       h.hash0 = fastrand2()
+       h.hash0 = fastrand1()
        h.buckets = buckets
        h.oldbuckets = nil
        h.nevacuate = 0
@@ -568,7 +568,7 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) {
 
        // iterator state
        it.bucket = 0
-       it.offset = uint8(fastrand2() & (bucketCnt - 1))
+       it.offset = uint8(fastrand1() & (bucketCnt - 1))
        it.done = false
        it.bptr = nil
 
index 5b1825a04cb697c12354742dab48964681dc20a3..84587a36d6bd4ae3b5ae3d2fa749b64ac40ebaca 100644 (file)
@@ -387,7 +387,7 @@ func profilealloc(mp *m, x unsafe.Pointer, size uintptr) {
                if rate > 0x3fffffff { // make 2*rate not overflow
                        rate = 0x3fffffff
                }
-               next := int32(fastrand2()) % (2 * int32(rate))
+               next := int32(fastrand1()) % (2 * int32(rate))
                // Subtract the "remainder" of the current allocation.
                // Otherwise objects that are close in size to sampling rate
                // will be under-sampled, because we consistently discard this remainder.
index 8bef7dc07672a2b6ab2c46dcb7755f6882519305..d4999e74650d542103471554f121048853faf834 100644 (file)
@@ -265,19 +265,6 @@ runtime·check(void)
                runtime·throw("FixedStack is not power-of-2");
 }
 
-uint32
-runtime·fastrand1(void)
-{
-       uint32 x;
-
-       x = g->m->fastrand;
-       x += x;
-       if(x & 0x80000000L)
-               x ^= 0x88888eefUL;
-       g->m->fastrand = x;
-       return x;
-}
-
 static Mutex ticksLock;
 static int64 ticks;
 
index 31976cd6f83c063235b92a51770affb677f52734..dbe0543bf7e72738f89c85fb67321a3844684828 100644 (file)
@@ -226,7 +226,7 @@ func selectgoImpl(sel *_select) (uintptr, uint16) {
        }
        for i := 1; i < int(sel.ncase); i++ {
                o := pollorder[i]
-               j := int(fastrand2()) % (i + 1)
+               j := int(fastrand1()) % (i + 1)
                pollorder[i] = pollorder[j]
                pollorder[j] = o
        }
index 3106a1530e3d5eae08839bbf9622370e4419c149..cdcf4b36708c8e184aba0a9e3d44a3a0e6fc30c6 100644 (file)
@@ -101,9 +101,6 @@ func racemalloc(p unsafe.Pointer, size uintptr)
 //go:noescape
 func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
 
-// in asm_*.s
-func fastrand2() uint32
-
 const (
        concurrentSweep = true
 )