aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/stubs.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/stubs.go')
-rw-r--r--libgo/go/runtime/stubs.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go
index 84fa1c7..c454356b 100644
--- a/libgo/go/runtime/stubs.go
+++ b/libgo/go/runtime/stubs.go
@@ -107,16 +107,21 @@ func reflect_memmove(to, from unsafe.Pointer, n uintptr) {
func memcmp(a, b unsafe.Pointer, size uintptr) int32
// exported value for testing
-var hashLoad = loadFactor
+var hashLoad = float32(loadFactorNum) / float32(loadFactorDen)
//go:nosplit
func fastrand() uint32 {
mp := getg().m
- fr := mp.fastrand
- mx := uint32(int32(fr)>>31) & 0xa8888eef
- fr = fr<<1 ^ mx
- mp.fastrand = fr
- return fr
+ // Implement xorshift64+: 2 32-bit xorshift sequences added together.
+ // Shift triplet [17,7,16] was calculated as indicated in Marsaglia's
+ // Xorshift paper: https://www.jstatsoft.org/article/view/v008i14/xorshift.pdf
+ // This generator passes the SmallCrush suite, part of TestU01 framework:
+ // http://simul.iro.umontreal.ca/testu01/tu01.html
+ s1, s0 := mp.fastrand[0], mp.fastrand[1]
+ s1 ^= s1 << 17
+ s1 = s1 ^ s0 ^ s1>>7 ^ s0>>16
+ mp.fastrand[0], mp.fastrand[1] = s0, s1
+ return s0 + s1
}
//go:nosplit
@@ -192,14 +197,16 @@ func publicationBarrier()
// getcallerpc returns the program counter (PC) of its caller's caller.
// getcallersp returns the stack pointer (SP) of its caller's caller.
-// For both, the argp must be a pointer to the caller's first function argument.
+// argp must be a pointer to the caller's first function argument.
// The implementation may or may not use argp, depending on
-// the architecture.
+// the architecture. The implementation may be a compiler
+// intrinsic; there is not necessarily code implementing this
+// on every platform.
//
// For example:
//
// func f(arg1, arg2, arg3 int) {
-// pc := getcallerpc(unsafe.Pointer(&arg1))
+// pc := getcallerpc()
// sp := getcallersp(unsafe.Pointer(&arg1))
// }
//
@@ -219,7 +226,7 @@ func publicationBarrier()
// immediately and can only be passed to nosplit functions.
//go:noescape
-func getcallerpc(argp unsafe.Pointer) uintptr
+func getcallerpc() uintptr
//go:noescape
func getcallersp(argp unsafe.Pointer) uintptr
@@ -430,7 +437,7 @@ func setpagesize(s uintptr) {
}
}
-// Temporary for gccgo until we port mgc.go.
+// Called by C code during library initialization.
//go:linkname runtime_m0 runtime.runtime_m0
func runtime_m0() *m {
return &m0