aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/reflect
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-11-07 07:25:23 -0800
committerIan Lance Taylor <iant@golang.org>2020-11-10 07:25:32 -0800
commitcf392dbdf17e38026f8e3c0e9af7f5b87f63be56 (patch)
tree6b1df9cdc36cc47b6164db69a14bc86a63dc77c6 /libgo/go/reflect
parent0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739 (diff)
downloadgcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.zip
gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.tar.gz
gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.tar.bz2
libgo: update to Go 1.15.4 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/268177
Diffstat (limited to 'libgo/go/reflect')
-rw-r--r--libgo/go/reflect/deepequal.go12
-rw-r--r--libgo/go/reflect/value.go12
2 files changed, 22 insertions, 2 deletions
diff --git a/libgo/go/reflect/deepequal.go b/libgo/go/reflect/deepequal.go
index 8a2bf8b..b99c345 100644
--- a/libgo/go/reflect/deepequal.go
+++ b/libgo/go/reflect/deepequal.go
@@ -37,7 +37,17 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
// and it's safe and valid to get Value's internal pointer.
hard := func(v1, v2 Value) bool {
switch v1.Kind() {
- case Map, Slice, Ptr, Interface:
+ case Ptr:
+ if v1.typ.ptrdata == 0 {
+ // go:notinheap pointers can't be cyclic.
+ // At least, all of our current uses of go:notinheap have
+ // that property. The runtime ones aren't cyclic (and we don't use
+ // DeepEqual on them anyway), and the cgo-generated ones are
+ // all empty structs.
+ return false
+ }
+ fallthrough
+ case Map, Slice, Interface:
// Nil pointers cannot be cyclic. Avoid putting them in the visited map.
return !v1.IsNil() && !v2.IsNil()
}
diff --git a/libgo/go/reflect/value.go b/libgo/go/reflect/value.go
index 64f7432..1394dd3 100644
--- a/libgo/go/reflect/value.go
+++ b/libgo/go/reflect/value.go
@@ -91,6 +91,7 @@ func (f flag) ro() flag {
// pointer returns the underlying pointer represented by v.
// v.Kind() must be Ptr, Map, Chan, Func, or UnsafePointer
+// if v.Kind() == Ptr, the base type must not be go:notinheap.
func (v Value) pointer() unsafe.Pointer {
if v.typ.size != ptrSize || !v.typ.pointers() {
panic("can't call pointer on a non-pointer Value")
@@ -1263,7 +1264,16 @@ func (v Value) Pointer() uintptr {
// TODO: deprecate
k := v.kind()
switch k {
- case Chan, Map, Ptr, UnsafePointer:
+ case Ptr:
+ if v.typ.ptrdata == 0 {
+ // Handle pointers to go:notinheap types directly,
+ // so we never materialize such pointers as an
+ // unsafe.Pointer. (Such pointers are always indirect.)
+ // See issue 42076.
+ return *(*uintptr)(v.ptr)
+ }
+ fallthrough
+ case Chan, Map, UnsafePointer:
return uintptr(v.pointer())
case Func:
p := v.pointer()