diff options
| author | qiulaidongfeng <2645477756@qq.com> | 2024-01-24 02:54:56 +0000 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2024-02-20 16:10:05 +0000 |
| commit | ff4e45fbc2ab7980087c0ae882a36803f6bc248f (patch) | |
| tree | 68484e5f4c30ed77d26a1f135b17b1ba3c957364 /src/cmd/compile | |
| parent | af3f94ce646201914a62145821630cc232c1d014 (diff) | |
| download | go-ff4e45fbc2ab7980087c0ae882a36803f6bc248f.tar.xz | |
cmd/compile/internal/reflectdata,reflect: merge MaxPtrmaskBytes const into internal/abi
For #59670
Change-Id: I5c0a463f54208db215683f11e6454d0178edda3c
GitHub-Last-Rev: 6963f3c8fb9cf34cdc8dda7ee92a58c71ca65520
GitHub-Pull-Request: golang/go#64904
Reviewed-on: https://go-review.googlesource.com/c/go/+/553275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/cmd/compile')
| -rw-r--r-- | src/cmd/compile/internal/reflectdata/reflect.go | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index fd64b2ebfe..185be4dd51 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -1498,39 +1498,6 @@ func (a typesByString) Less(i, j int) bool { } func (a typesByString) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -// maxPtrmaskBytes is the maximum length of a GC ptrmask bitmap, -// which holds 1-bit entries describing where pointers are in a given type. -// Above this length, the GC information is recorded as a GC program, -// which can express repetition compactly. In either form, the -// information is used by the runtime to initialize the heap bitmap, -// and for large types (like 128 or more words), they are roughly the -// same speed. GC programs are never much larger and often more -// compact. (If large arrays are involved, they can be arbitrarily -// more compact.) -// -// The cutoff must be large enough that any allocation large enough to -// use a GC program is large enough that it does not share heap bitmap -// bytes with any other objects, allowing the GC program execution to -// assume an aligned start and not use atomic operations. In the current -// runtime, this means all malloc size classes larger than the cutoff must -// be multiples of four words. On 32-bit systems that's 16 bytes, and -// all size classes >= 16 bytes are 16-byte aligned, so no real constraint. -// On 64-bit systems, that's 32 bytes, and 32-byte alignment is guaranteed -// for size classes >= 256 bytes. On a 64-bit system, 256 bytes allocated -// is 32 pointers, the bits for which fit in 4 bytes. So maxPtrmaskBytes -// must be >= 4. -// -// We used to use 16 because the GC programs do have some constant overhead -// to get started, and processing 128 pointers seems to be enough to -// amortize that overhead well. -// -// To make sure that the runtime's chansend can call typeBitsBulkBarrier, -// we raised the limit to 2048, so that even 32-bit systems are guaranteed to -// use bitmaps for objects up to 64 kB in size. -// -// Also known to reflect/type.go. -const maxPtrmaskBytes = 2048 - // GCSym returns a data symbol containing GC information for type t, along // with a boolean reporting whether the UseGCProg bit should be set in the // type kind, and the ptrdata field to record in the reflect type information. @@ -1553,7 +1520,7 @@ func GCSym(t *types.Type) (lsym *obj.LSym, useGCProg bool, ptrdata int64) { // When write is true, it writes the symbol data. func dgcsym(t *types.Type, write bool) (lsym *obj.LSym, useGCProg bool, ptrdata int64) { ptrdata = types.PtrDataSize(t) - if ptrdata/int64(types.PtrSize) <= maxPtrmaskBytes*8 { + if ptrdata/int64(types.PtrSize) <= abi.MaxPtrmaskBytes*8 { lsym = dgcptrmask(t, write) return } |
