mirror of
https://github.com/golang/go
synced 2024-11-18 20:04:52 -07:00
runtime: rename ptrsize to ptrdata
I forgot there is already a ptrSize constant. Rename field to avoid some confusion. Change-Id: I098fdcc8afc947d6c02c41c6e6de24624cc1c8ff Reviewed-on: https://go-review.googlesource.com/9700 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
92715d7780
commit
ceefebd795
@ -685,9 +685,9 @@ func haspointers(t *Type) bool {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeptrsize returns the length in bytes of the prefix of t
|
// typeptrdata returns the length in bytes of the prefix of t
|
||||||
// containing pointer data. Anything after this offset is scalar data.
|
// containing pointer data. Anything after this offset is scalar data.
|
||||||
func typeptrsize(t *Type) uint64 {
|
func typeptrdata(t *Type) uint64 {
|
||||||
if !haspointers(t) {
|
if !haspointers(t) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -716,7 +716,7 @@ func typeptrsize(t *Type) uint64 {
|
|||||||
return uint64(Widthptr)
|
return uint64(Widthptr)
|
||||||
}
|
}
|
||||||
// haspointers already eliminated t.Bound == 0.
|
// haspointers already eliminated t.Bound == 0.
|
||||||
return uint64(t.Bound-1)*uint64(t.Type.Width) + typeptrsize(t.Type)
|
return uint64(t.Bound-1)*uint64(t.Type.Width) + typeptrdata(t.Type)
|
||||||
|
|
||||||
case TSTRUCT:
|
case TSTRUCT:
|
||||||
// Find the last field that has pointers.
|
// Find the last field that has pointers.
|
||||||
@ -726,10 +726,10 @@ func typeptrsize(t *Type) uint64 {
|
|||||||
lastPtrField = t1
|
lastPtrField = t1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uint64(lastPtrField.Width) + typeptrsize(lastPtrField.Type)
|
return uint64(lastPtrField.Width) + typeptrdata(lastPtrField.Type)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Fatal("typeptrsize: unexpected type, %v", t)
|
Fatal("typeptrdata: unexpected type, %v", t)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -794,7 +794,7 @@ func dcommontype(s *Sym, ot int, t *Type) int {
|
|||||||
// zero unsafe.Pointer
|
// zero unsafe.Pointer
|
||||||
// }
|
// }
|
||||||
ot = duintptr(s, ot, uint64(t.Width))
|
ot = duintptr(s, ot, uint64(t.Width))
|
||||||
ot = duintptr(s, ot, typeptrsize(t))
|
ot = duintptr(s, ot, typeptrdata(t))
|
||||||
|
|
||||||
ot = duint32(s, ot, typehash(t))
|
ot = duint32(s, ot, typehash(t))
|
||||||
ot = duint8(s, ot, 0) // unused
|
ot = duint8(s, ot, 0) // unused
|
||||||
|
@ -246,7 +246,7 @@ const (
|
|||||||
// so that code cannot convert from, say, *arrayType to *ptrType.
|
// so that code cannot convert from, say, *arrayType to *ptrType.
|
||||||
type rtype struct {
|
type rtype struct {
|
||||||
size uintptr
|
size uintptr
|
||||||
ptrsize uintptr
|
ptrdata uintptr
|
||||||
hash uint32 // hash of type; avoids computation in hash tables
|
hash uint32 // hash of type; avoids computation in hash tables
|
||||||
_ uint8 // unused/padding
|
_ uint8 // unused/padding
|
||||||
align uint8 // alignment of variable with this type
|
align uint8 // alignment of variable with this type
|
||||||
@ -1826,14 +1826,14 @@ func bucketOf(ktyp, etyp *rtype) *rtype {
|
|||||||
}
|
}
|
||||||
// overflow
|
// overflow
|
||||||
gc.append(bitsPointer)
|
gc.append(bitsPointer)
|
||||||
tptrsize := gc.size
|
ptrdata := gc.size
|
||||||
if runtime.GOARCH == "amd64p32" {
|
if runtime.GOARCH == "amd64p32" {
|
||||||
gc.append(bitsScalar)
|
gc.append(bitsScalar)
|
||||||
}
|
}
|
||||||
|
|
||||||
b := new(rtype)
|
b := new(rtype)
|
||||||
b.size = gc.size
|
b.size = gc.size
|
||||||
b.ptrsize = tptrsize
|
b.ptrdata = ptrdata
|
||||||
b.kind = kind
|
b.kind = kind
|
||||||
b.gc[0], _ = gc.finalize()
|
b.gc[0], _ = gc.finalize()
|
||||||
s := "bucket(" + *ktyp.string + "," + *etyp.string + ")"
|
s := "bucket(" + *ktyp.string + "," + *etyp.string + ")"
|
||||||
@ -1920,8 +1920,8 @@ func ArrayOf(count int, elem Type) Type {
|
|||||||
panic("reflect.ArrayOf: array size would exceed virtual address space")
|
panic("reflect.ArrayOf: array size would exceed virtual address space")
|
||||||
}
|
}
|
||||||
array.size = typ.size * uintptr(count)
|
array.size = typ.size * uintptr(count)
|
||||||
if count > 0 && typ.ptrsize != 0 {
|
if count > 0 && typ.ptrdata != 0 {
|
||||||
array.ptrsize = typ.size*uintptr(count-1) + typ.ptrsize
|
array.ptrdata = typ.size*uintptr(count-1) + typ.ptrdata
|
||||||
}
|
}
|
||||||
array.align = typ.align
|
array.align = typ.align
|
||||||
array.fieldAlign = typ.fieldAlign
|
array.fieldAlign = typ.fieldAlign
|
||||||
@ -2090,7 +2090,7 @@ func funcLayout(t *rtype, rcvr *rtype) (frametype *rtype, argSize, retOffset uin
|
|||||||
// build dummy rtype holding gc program
|
// build dummy rtype holding gc program
|
||||||
x := new(rtype)
|
x := new(rtype)
|
||||||
x.size = gc.size
|
x.size = gc.size
|
||||||
x.ptrsize = gc.size // over-approximation
|
x.ptrdata = gc.size // over-approximation
|
||||||
var hasPtr bool
|
var hasPtr bool
|
||||||
x.gc[0], hasPtr = gc.finalize()
|
x.gc[0], hasPtr = gc.finalize()
|
||||||
if !hasPtr {
|
if !hasPtr {
|
||||||
|
@ -13,7 +13,7 @@ import "unsafe"
|
|||||||
// ../reflect/type.go:/^type.rtype.
|
// ../reflect/type.go:/^type.rtype.
|
||||||
type _type struct {
|
type _type struct {
|
||||||
size uintptr
|
size uintptr
|
||||||
ptrsize uintptr // Bytes of prefix containing pointer slots.
|
ptrdata uintptr // size of memory prefix holding all pointers
|
||||||
hash uint32
|
hash uint32
|
||||||
_unused uint8
|
_unused uint8
|
||||||
align uint8
|
align uint8
|
||||||
|
Loading…
Reference in New Issue
Block a user