mirror of https://github.com/golang/go.git
cmd/link: use MapMaxKeyBytes,MapMaxElemBytes,MapBucketCount of internal/abi
For #59670
This commit is contained in:
parent
9b4b3e5acc
commit
df6a7bf29a
|
|
@ -850,13 +850,6 @@ func mkinternaltypename(base string, arg1 string, arg2 string) string {
|
|||
return fmt.Sprintf("%s<%s,%s>", base, arg1, arg2)
|
||||
}
|
||||
|
||||
// synthesizemaptypes is way too closely married to runtime/hashmap.c
|
||||
const (
|
||||
MaxKeySize = abi.MapMaxKeyBytes
|
||||
MaxValSize = abi.MapMaxElemBytes
|
||||
BucketSize = abi.MapBucketCount
|
||||
)
|
||||
|
||||
func (d *dwctxt) mkinternaltype(ctxt *Link, abbrev int, typename, keyname, valname string, f func(*dwarf.DWDie)) loader.Sym {
|
||||
name := mkinternaltypename(typename, keyname, valname)
|
||||
symname := dwarf.InfoPrefix + name
|
||||
|
|
@ -891,11 +884,11 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
|
|||
|
||||
// compute size info like hashmap.c does.
|
||||
indirectKey, indirectVal := false, false
|
||||
if keysize > MaxKeySize {
|
||||
if keysize > abi.MapMaxKeyBytes {
|
||||
keysize = int64(d.arch.PtrSize)
|
||||
indirectKey = true
|
||||
}
|
||||
if valsize > MaxValSize {
|
||||
if valsize > abi.MapMaxElemBytes {
|
||||
valsize = int64(d.arch.PtrSize)
|
||||
indirectVal = true
|
||||
}
|
||||
|
|
@ -903,28 +896,28 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
|
|||
// Construct type to represent an array of BucketSize keys
|
||||
keyname := d.nameFromDIESym(keytype)
|
||||
dwhks := d.mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]key", keyname, "", func(dwhk *dwarf.DWDie) {
|
||||
newattr(dwhk, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize*keysize, 0)
|
||||
newattr(dwhk, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount*keysize, 0)
|
||||
t := keytype
|
||||
if indirectKey {
|
||||
t = d.defptrto(keytype)
|
||||
}
|
||||
d.newrefattr(dwhk, dwarf.DW_AT_type, t)
|
||||
fld := d.newdie(dwhk, dwarf.DW_ABRV_ARRAYRANGE, "size")
|
||||
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, BucketSize, 0)
|
||||
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount, 0)
|
||||
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
|
||||
})
|
||||
|
||||
// Construct type to represent an array of BucketSize values
|
||||
valname := d.nameFromDIESym(valtype)
|
||||
dwhvs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]val", valname, "", func(dwhv *dwarf.DWDie) {
|
||||
newattr(dwhv, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize*valsize, 0)
|
||||
newattr(dwhv, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount*valsize, 0)
|
||||
t := valtype
|
||||
if indirectVal {
|
||||
t = d.defptrto(valtype)
|
||||
}
|
||||
d.newrefattr(dwhv, dwarf.DW_AT_type, t)
|
||||
fld := d.newdie(dwhv, dwarf.DW_ABRV_ARRAYRANGE, "size")
|
||||
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, BucketSize, 0)
|
||||
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount, 0)
|
||||
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
|
||||
})
|
||||
|
||||
|
|
@ -936,20 +929,20 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
|
|||
|
||||
fld := d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "keys")
|
||||
d.newrefattr(fld, dwarf.DW_AT_type, dwhks)
|
||||
newmemberoffsetattr(fld, BucketSize)
|
||||
newmemberoffsetattr(fld, abi.MapBucketCount)
|
||||
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "values")
|
||||
d.newrefattr(fld, dwarf.DW_AT_type, dwhvs)
|
||||
newmemberoffsetattr(fld, BucketSize+BucketSize*int32(keysize))
|
||||
newmemberoffsetattr(fld, abi.MapBucketCount+abi.MapBucketCount*int32(keysize))
|
||||
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "overflow")
|
||||
d.newrefattr(fld, dwarf.DW_AT_type, d.defptrto(d.dtolsym(dwhb.Sym)))
|
||||
newmemberoffsetattr(fld, BucketSize+BucketSize*(int32(keysize)+int32(valsize)))
|
||||
newmemberoffsetattr(fld, abi.MapBucketCount+abi.MapBucketCount*(int32(keysize)+int32(valsize)))
|
||||
if d.arch.RegSize > d.arch.PtrSize {
|
||||
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "pad")
|
||||
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
|
||||
newmemberoffsetattr(fld, BucketSize+BucketSize*(int32(keysize)+int32(valsize))+int32(d.arch.PtrSize))
|
||||
newmemberoffsetattr(fld, abi.MapBucketCount+abi.MapBucketCount*(int32(keysize)+int32(valsize))+int32(d.arch.PtrSize))
|
||||
}
|
||||
|
||||
newattr(dwhb, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, BucketSize+BucketSize*keysize+BucketSize*valsize+int64(d.arch.RegSize), 0)
|
||||
newattr(dwhb, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount+abi.MapBucketCount*keysize+abi.MapBucketCount*valsize+int64(d.arch.RegSize), 0)
|
||||
})
|
||||
|
||||
// Construct hash<K,V>
|
||||
|
|
|
|||
Loading…
Reference in New Issue