mirror of
https://github.com/golang/go.git
synced 2025-05-22 16:09:37 +00:00
reflect: remove redundent ifaceIndir
Use abi.(*Type).IfaceIndir instead. Change-Id: I31197cbf0edaf53bbb0455fa76d2a4a2ab40b420 GitHub-Last-Rev: 2659b696ef3680e13e22bdf6a63e5d82b7b1ecdf GitHub-Pull-Request: golang/go#67227 Reviewed-on: https://go-review.googlesource.com/c/go/+/583755 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
c637d4b939
commit
55a06f7920
@ -166,7 +166,7 @@ func (a *abiSeq) addRcvr(rcvr *abi.Type) (*abiStep, bool) {
|
||||
// The receiver is always one word.
|
||||
a.valueStart = append(a.valueStart, len(a.steps))
|
||||
var ok, ptr bool
|
||||
if ifaceIndir(rcvr) || rcvr.Pointers() {
|
||||
if rcvr.IfaceIndir() || rcvr.Pointers() {
|
||||
ok = a.assignIntN(0, goarch.PtrSize, 1, 0b1)
|
||||
ptr = true
|
||||
} else {
|
||||
|
@ -2606,7 +2606,7 @@ func StructOf(fields []StructField) Type {
|
||||
}
|
||||
|
||||
switch {
|
||||
case len(fs) == 1 && !ifaceIndir(fs[0].Typ):
|
||||
case len(fs) == 1 && !fs[0].Typ.IfaceIndir():
|
||||
// structs of 1 direct iface type can be direct
|
||||
typ.Kind_ |= abi.KindDirectIface
|
||||
default:
|
||||
@ -2801,7 +2801,7 @@ func ArrayOf(length int, elem Type) Type {
|
||||
}
|
||||
|
||||
switch {
|
||||
case length == 1 && !ifaceIndir(typ):
|
||||
case length == 1 && !typ.IfaceIndir():
|
||||
// array of 1 direct iface type can be direct
|
||||
array.Kind_ |= abi.KindDirectIface
|
||||
default:
|
||||
@ -2903,11 +2903,6 @@ func funcLayout(t *funcType, rcvr *abi.Type) (frametype *abi.Type, framePool *sy
|
||||
return lt.t, lt.framePool, lt.abid
|
||||
}
|
||||
|
||||
// ifaceIndir reports whether t is stored indirectly in an interface value.
|
||||
func ifaceIndir(t *abi.Type) bool {
|
||||
return t.Kind_&abi.KindDirectIface == 0
|
||||
}
|
||||
|
||||
// Note: this type must agree with runtime.bitvector.
|
||||
type bitVector struct {
|
||||
n uint32 // number of bits
|
||||
|
@ -624,7 +624,7 @@ func (v Value) call(op string, in []Value) []Value {
|
||||
}
|
||||
|
||||
// Handle pointers passed in registers.
|
||||
if !ifaceIndir(tv) {
|
||||
if !tv.IfaceIndir() {
|
||||
// Pointer-valued data gets put directly
|
||||
// into v.ptr.
|
||||
if steps[0].kind != abiStepPointer {
|
||||
@ -714,7 +714,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
|
||||
v := Value{typ, nil, flag(typ.Kind())}
|
||||
steps := abid.call.stepsForValue(i)
|
||||
if st := steps[0]; st.kind == abiStepStack {
|
||||
if ifaceIndir(typ) {
|
||||
if typ.IfaceIndir() {
|
||||
// value cannot be inlined in interface data.
|
||||
// Must make a copy, because f might keep a reference to it,
|
||||
// and we cannot let f keep a reference to the stack frame
|
||||
@ -728,7 +728,7 @@ func callReflect(ctxt *makeFuncImpl, frame unsafe.Pointer, retValid *bool, regs
|
||||
v.ptr = *(*unsafe.Pointer)(add(ptr, st.stkOff, "1-ptr"))
|
||||
}
|
||||
} else {
|
||||
if ifaceIndir(typ) {
|
||||
if typ.IfaceIndir() {
|
||||
// All that's left is values passed in registers that we need to
|
||||
// create space for the values.
|
||||
v.flag |= flagIndir
|
||||
@ -914,7 +914,7 @@ func storeRcvr(v Value, p unsafe.Pointer) {
|
||||
// the interface data word becomes the receiver word
|
||||
iface := (*nonEmptyInterface)(v.ptr)
|
||||
*(*unsafe.Pointer)(p) = iface.word
|
||||
} else if v.flag&flagIndir != 0 && !ifaceIndir(t) {
|
||||
} else if v.flag&flagIndir != 0 && !t.IfaceIndir() {
|
||||
*(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(v.ptr)
|
||||
} else {
|
||||
*(*unsafe.Pointer)(p) = v.ptr
|
||||
@ -1232,7 +1232,7 @@ func (v Value) Elem() Value {
|
||||
case Pointer:
|
||||
ptr := v.ptr
|
||||
if v.flag&flagIndir != 0 {
|
||||
if ifaceIndir(v.typ()) {
|
||||
if v.typ().IfaceIndir() {
|
||||
// This is a pointer to a not-in-heap object. ptr points to a uintptr
|
||||
// in the heap. That uintptr is the address of a not-in-heap object.
|
||||
// In general, pointers to not-in-heap objects can be total junk.
|
||||
@ -2258,7 +2258,7 @@ func (v Value) recv(nb bool) (val Value, ok bool) {
|
||||
t := tt.Elem
|
||||
val = Value{t, nil, flag(t.Kind())}
|
||||
var p unsafe.Pointer
|
||||
if ifaceIndir(t) {
|
||||
if t.IfaceIndir() {
|
||||
p = unsafe_New(t)
|
||||
val.ptr = p
|
||||
val.flag |= flagIndir
|
||||
@ -3297,7 +3297,7 @@ func New(typ Type) Value {
|
||||
}
|
||||
t := &typ.(*rtype).t
|
||||
pt := ptrTo(t)
|
||||
if ifaceIndir(pt) {
|
||||
if pt.IfaceIndir() {
|
||||
// This is a pointer to a not-in-heap type.
|
||||
panic("reflect: New of type that may not be allocated in heap (possibly undefined cgo C type)")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user