summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-09-10 12:37:28 -0700
committerKeith Randall <khr@golang.org>2014-09-10 12:37:28 -0700
commit1884fb06321882d59cd9678b6f1f9fcaafdf9a27 (patch)
treeef8d3abd89b2c9fbaa4c91e4be7f65353c03850f /src/reflect
parent33b41d5dc4136f24e0a0feb9b3058600c76f687e (diff)
downloadgo-1884fb06321882d59cd9678b6f1f9fcaafdf9a27.tar.gz
reflect: use runtime's memmove instead of its own
They will both need write barriers at some point. But until then, no reason why we shouldn't share. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://codereview.appspot.com/141330043
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/value.go29
1 files changed, 3 insertions, 26 deletions
diff --git a/src/reflect/value.go b/src/reflect/value.go
index 368116a50..20d0e92ed 100644
--- a/src/reflect/value.go
+++ b/src/reflect/value.go
@@ -15,32 +15,6 @@ const bigEndian = false // can be smarter if we find a big-endian machine
const ptrSize = unsafe.Sizeof((*byte)(nil))
const cannotSet = "cannot set value obtained from unexported struct field"
-// TODO: This will have to go away when
-// the new gc goes in.
-func memmove(adst, asrc unsafe.Pointer, n uintptr) {
- dst := uintptr(adst)
- src := uintptr(asrc)
- switch {
- case src < dst && src+n > dst:
- // byte copy backward
- // careful: i is unsigned
- for i := n; i > 0; {
- i--
- *(*byte)(unsafe.Pointer(dst + i)) = *(*byte)(unsafe.Pointer(src + i))
- }
- case (n|src|dst)&(ptrSize-1) != 0:
- // byte copy forward
- for i := uintptr(0); i < n; i++ {
- *(*byte)(unsafe.Pointer(dst + i)) = *(*byte)(unsafe.Pointer(src + i))
- }
- default:
- // word copy forward
- for i := uintptr(0); i < n; i += ptrSize {
- *(*uintptr)(unsafe.Pointer(dst + i)) = *(*uintptr)(unsafe.Pointer(src + i))
- }
- }
-}
-
// Value is the reflection interface to a Go value.
//
// Not all methods apply to all kinds of values. Restrictions,
@@ -2703,6 +2677,9 @@ func call(fn, arg unsafe.Pointer, n uint32, retoffset uint32)
func ifaceE2I(t *rtype, src interface{}, dst unsafe.Pointer)
+//go:noescape
+func memmove(adst, asrc unsafe.Pointer, n uintptr)
+
// Dummy annotation marking that the value x escapes,
// for use in cases where the reflect code is so clever that
// the compiler cannot follow.