]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/reflect/type.go
[dev.typeparams] all: merge master (296ddf2) into dev.typeparams
[gostls13.git] / src / reflect / type.go
index f672a7a5d5fc996e93a38c4c99fddd4fee76a687..278426da09e3a6431cc518d7488839f906266f88 100644 (file)
@@ -16,6 +16,7 @@
 package reflect
 
 import (
+       "internal/goarch"
        "internal/unsafeheader"
        "strconv"
        "sync"
@@ -1924,13 +1925,13 @@ func MapOf(key, elem Type) Type {
        }
        mt.flags = 0
        if ktyp.size > maxKeySize {
-               mt.keysize = uint8(ptrSize)
+               mt.keysize = uint8(goarch.PtrSize)
                mt.flags |= 1 // indirect key
        } else {
                mt.keysize = uint8(ktyp.size)
        }
        if etyp.size > maxValSize {
-               mt.valuesize = uint8(ptrSize)
+               mt.valuesize = uint8(goarch.PtrSize)
                mt.flags |= 2 // indirect value
        } else {
                mt.valuesize = uint8(etyp.size)
@@ -2231,31 +2232,31 @@ func bucketOf(ktyp, etyp *rtype) *rtype {
        var ptrdata uintptr
        var overflowPad uintptr
 
-       size := bucketSize*(1+ktyp.size+etyp.size) + overflowPad + ptrSize
+       size := bucketSize*(1+ktyp.size+etyp.size) + overflowPad + goarch.PtrSize
        if size&uintptr(ktyp.align-1) != 0 || size&uintptr(etyp.align-1) != 0 {
                panic("reflect: bad size computation in MapOf")
        }
 
        if ktyp.ptrdata != 0 || etyp.ptrdata != 0 {
-               nptr := (bucketSize*(1+ktyp.size+etyp.size) + ptrSize) / ptrSize
+               nptr := (bucketSize*(1+ktyp.size+etyp.size) + goarch.PtrSize) / goarch.PtrSize
                mask := make([]byte, (nptr+7)/8)
-               base := bucketSize / ptrSize
+               base := bucketSize / goarch.PtrSize
 
                if ktyp.ptrdata != 0 {
                        emitGCMask(mask, base, ktyp, bucketSize)
                }
-               base += bucketSize * ktyp.size / ptrSize
+               base += bucketSize * ktyp.size / goarch.PtrSize
 
                if etyp.ptrdata != 0 {
                        emitGCMask(mask, base, etyp, bucketSize)
                }
-               base += bucketSize * etyp.size / ptrSize
-               base += overflowPad / ptrSize
+               base += bucketSize * etyp.size / goarch.PtrSize
+               base += overflowPad / goarch.PtrSize
 
                word := base
                mask[word/8] |= 1 << (word % 8)
                gcdata = &mask[0]
-               ptrdata = (word + 1) * ptrSize
+               ptrdata = (word + 1) * goarch.PtrSize
 
                // overflow word must be last
                if ptrdata != size {
@@ -2264,7 +2265,7 @@ func bucketOf(ktyp, etyp *rtype) *rtype {
        }
 
        b := &rtype{
-               align:   ptrSize,
+               align:   goarch.PtrSize,
                size:    size,
                kind:    uint8(Struct),
                ptrdata: ptrdata,
@@ -2288,8 +2289,8 @@ func emitGCMask(out []byte, base uintptr, typ *rtype, n uintptr) {
        if typ.kind&kindGCProg != 0 {
                panic("reflect: unexpected GC program")
        }
-       ptrs := typ.ptrdata / ptrSize
-       words := typ.size / ptrSize
+       ptrs := typ.ptrdata / goarch.PtrSize
+       words := typ.size / goarch.PtrSize
        mask := typ.gcSlice(0, (ptrs+7)/8)
        for j := uintptr(0); j < ptrs; j++ {
                if (mask[j/8]>>(j%8))&1 != 0 {
@@ -2312,7 +2313,7 @@ func appendGCProg(dst []byte, typ *rtype) []byte {
        }
 
        // Element is small with pointer mask; use as literal bits.
-       ptrs := typ.ptrdata / ptrSize
+       ptrs := typ.ptrdata / goarch.PtrSize
        mask := typ.gcSlice(0, (ptrs+7)/8)
 
        // Emit 120-bit chunks of full bytes (max is 127 but we avoid using partial bytes).
@@ -2759,7 +2760,7 @@ func StructOf(fields []StructField) Type {
                        }
                        // Pad to start of this field with zeros.
                        if ft.offset() > off {
-                               n := (ft.offset() - off) / ptrSize
+                               n := (ft.offset() - off) / goarch.PtrSize
                                prog = append(prog, 0x01, 0x00) // emit a 0 bit
                                if n > 1 {
                                        prog = append(prog, 0x81)      // repeat previous bit
@@ -2936,11 +2937,11 @@ func ArrayOf(length int, elem Type) Type {
                array.gcdata = typ.gcdata
                array.ptrdata = typ.ptrdata
 
-       case typ.kind&kindGCProg == 0 && array.size <= maxPtrmaskBytes*8*ptrSize:
+       case typ.kind&kindGCProg == 0 && array.size <= maxPtrmaskBytes*8*goarch.PtrSize:
                // Element is small with pointer mask; array is still small.
                // Create direct pointer mask by turning each 1 bit in elem
                // into length 1 bits in larger mask.
-               mask := make([]byte, (array.ptrdata/ptrSize+7)/8)
+               mask := make([]byte, (array.ptrdata/goarch.PtrSize+7)/8)
                emitGCMask(mask, 0, typ, array.len)
                array.gcdata = &mask[0]
 
@@ -2950,8 +2951,8 @@ func ArrayOf(length int, elem Type) Type {
                prog := []byte{0, 0, 0, 0} // will be length of prog
                prog = appendGCProg(prog, typ)
                // Pad from ptrdata to size.
-               elemPtrs := typ.ptrdata / ptrSize
-               elemWords := typ.size / ptrSize
+               elemPtrs := typ.ptrdata / goarch.PtrSize
+               elemWords := typ.size / goarch.PtrSize
                if elemPtrs < elemWords {
                        // Emit literal 0 bit, then repeat as needed.
                        prog = append(prog, 0x01, 0x00)
@@ -3063,13 +3064,13 @@ func funcLayout(t *funcType, rcvr *rtype) (frametype *rtype, framePool *sync.Poo
 
        // build dummy rtype holding gc program
        x := &rtype{
-               align: ptrSize,
+               align: goarch.PtrSize,
                // Don't add spill space here; it's only necessary in
                // reflectcall's frame, not in the allocated frame.
                // TODO(mknyszek): Remove this comment when register
                // spill space in the frame is no longer required.
-               size:    align(abi.retOffset+abi.ret.stackBytes, ptrSize),
-               ptrdata: uintptr(abi.stackPtrs.n) * ptrSize,
+               size:    align(abi.retOffset+abi.ret.stackBytes, goarch.PtrSize),
+               ptrdata: uintptr(abi.stackPtrs.n) * goarch.PtrSize,
        }
        if abi.stackPtrs.n > 0 {
                x.gcdata = &abi.stackPtrs.data[0]
@@ -3124,14 +3125,14 @@ func addTypeBits(bv *bitVector, offset uintptr, t *rtype) {
        switch Kind(t.kind & kindMask) {
        case Chan, Func, Map, Ptr, Slice, String, UnsafePointer:
                // 1 pointer at start of representation
-               for bv.n < uint32(offset/uintptr(ptrSize)) {
+               for bv.n < uint32(offset/uintptr(goarch.PtrSize)) {
                        bv.append(0)
                }
                bv.append(1)
 
        case Interface:
                // 2 pointers
-               for bv.n < uint32(offset/uintptr(ptrSize)) {
+               for bv.n < uint32(offset/uintptr(goarch.PtrSize)) {
                        bv.append(0)
                }
                bv.append(1)