// reflect_addReflectOff adds a pointer to the reflection offset lookup map.
//go:linkname reflect_addReflectOff reflect.addReflectOff
func reflect_addReflectOff(ptr unsafe.Pointer) int32 {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
if reflectOffs.m == nil {
reflectOffs.m = make(map[int32]unsafe.Pointer)
reflectOffs.minv = make(map[unsafe.Pointer]int32)
reflectOffs.m[id] = ptr
reflectOffs.minv[ptr] = id
}
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
return id
}
minv map[unsafe.Pointer]int32
}
+func reflectOffsLock() {
+ lock(&reflectOffs.lock)
+ if raceenabled {
+ raceacquire(unsafe.Pointer(&reflectOffs.lock))
+ }
+}
+
+func reflectOffsUnlock() {
+ if raceenabled {
+ racerelease(unsafe.Pointer(&reflectOffs.lock))
+ }
+ unlock(&reflectOffs.lock)
+}
+
func resolveNameOff(ptrInModule unsafe.Pointer, off nameOff) name {
if off == 0 {
return name{}
}
}
if md == nil {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
res, found := reflectOffs.m[int32(off)]
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
if !found {
println("runtime: nameOff", hex(off), "base", hex(base), "not in ranges:")
for next := &firstmoduledata; next != nil; next = next.next {
}
}
if md == nil {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
res := reflectOffs.m[int32(off)]
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
if res == nil {
println("runtime: typeOff", hex(off), "base", hex(base), "not in ranges:")
for next := &firstmoduledata; next != nil; next = next.next {
}
}
if md == nil {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
res := reflectOffs.m[int32(off)]
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
if res == nil {
println("runtime: textOff", hex(off), "base", hex(base), "not in ranges:")
for next := &firstmoduledata; next != nil; next = next.next {