aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2022-12-15 18:14:13 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2023-01-30 16:00:58 +0000
commitd42c08a2be456d353a7aca3110edeb9bdb66ebd0 (patch)
tree9f53d34cde09be9f62886ab03eea6574b0fa700b /src/runtime
parentf2a2600860ebcd1b86a0d8b67308da0a3fa673f0 (diff)
downloadgo-d42c08a2be456d353a7aca3110edeb9bdb66ebd0.tar.xz
reflect,runtime: add Value.Clear
Fixes #55002 Change-Id: I7d0f14cc54f67f2769b51d2efafc4ae3714f0e3d Reviewed-on: https://go-review.googlesource.com/c/go/+/457895 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/map.go5
-rw-r--r--src/runtime/mbarrier.go9
2 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/map.go b/src/runtime/map.go
index 6179c1e371..3f5817a577 100644
--- a/src/runtime/map.go
+++ b/src/runtime/map.go
@@ -1403,6 +1403,11 @@ func reflect_maplen(h *hmap) int {
return h.count
}
+//go:linkname reflect_mapclear reflect.mapclear
+func reflect_mapclear(t *maptype, h *hmap) {
+ mapclear(t, h)
+}
+
//go:linkname reflectlite_maplen internal/reflectlite.maplen
func reflectlite_maplen(h *hmap) int {
if h == nil {
diff --git a/src/runtime/mbarrier.go b/src/runtime/mbarrier.go
index 46ef42f74d..dbcd4db868 100644
--- a/src/runtime/mbarrier.go
+++ b/src/runtime/mbarrier.go
@@ -334,6 +334,15 @@ func reflect_typedmemclrpartial(typ *_type, ptr unsafe.Pointer, off, size uintpt
memclrNoHeapPointers(ptr, size)
}
+//go:linkname reflect_typedarrayclear reflect.typedarrayclear
+func reflect_typedarrayclear(typ *_type, ptr unsafe.Pointer, len int) {
+ size := typ.size * uintptr(len)
+ if writeBarrier.needed && typ.ptrdata != 0 {
+ bulkBarrierPreWrite(uintptr(ptr), 0, size)
+ }
+ memclrNoHeapPointers(ptr, size)
+}
+
// memclrHasPointers clears n bytes of typed memory starting at ptr.
// The caller must ensure that the type of the object at ptr has
// pointers, usually by checking typ.ptrdata. However, ptr