mirror of
https://github.com/golang/go
synced 2024-11-18 04:14:49 -07:00
cmd/link: replace custom hashmap in DWARF writer
Also stop creating a map for each symbol, as it does not seem to help. Linking juju: tip: real 0m5.470s user 0m6.131s this: real 0m4.811s user 0m5.582s Change-Id: Ib3d931c996396a00942581770ff32df1eb8d6615 Reviewed-on: https://go-review.googlesource.com/20140 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
97b2295f06
commit
c0f7195d62
@ -485,18 +485,6 @@ func writeabbrev() {
|
||||
/*
|
||||
* Debugging Information Entries and their attributes.
|
||||
*/
|
||||
const (
|
||||
HASHSIZE = 107
|
||||
)
|
||||
|
||||
func dwarfhashstr(s string) uint32 {
|
||||
h := uint32(0)
|
||||
for s != "" {
|
||||
h = h + h + h + uint32(s[0])
|
||||
s = s[1:]
|
||||
}
|
||||
return h % HASHSIZE
|
||||
}
|
||||
|
||||
// For DW_CLS_string and _block, value should contain the length, and
|
||||
// data the data, for _reference, value is 0 and data is a DWDie* to
|
||||
@ -518,9 +506,8 @@ type DWDie struct {
|
||||
attr *DWAttr
|
||||
// offset into .debug_info section, i.e relative to
|
||||
// infoo. only valid after call to putdie()
|
||||
offs int64
|
||||
hash []*DWDie // optional index of children by name, enabled by mkindex()
|
||||
hlink *DWDie // bucket chain in parent's index
|
||||
offs int64
|
||||
hash map[string]*DWDie // optional index of DWAttr by name, enabled by mkindex()
|
||||
}
|
||||
|
||||
/*
|
||||
@ -580,16 +567,14 @@ func newdie(parent *DWDie, abbrev int, name string) *DWDie {
|
||||
newattr(die, DW_AT_name, DW_CLS_STRING, int64(len(name)), name)
|
||||
|
||||
if parent.hash != nil {
|
||||
h := int(dwarfhashstr(name))
|
||||
die.hlink = parent.hash[h]
|
||||
parent.hash[h] = die
|
||||
parent.hash[name] = die
|
||||
}
|
||||
|
||||
return die
|
||||
}
|
||||
|
||||
func mkindex(die *DWDie) {
|
||||
die.hash = make([]*DWDie, HASHSIZE)
|
||||
die.hash = make(map[string]*DWDie)
|
||||
}
|
||||
|
||||
func walktypedef(die *DWDie) *DWDie {
|
||||
@ -610,7 +595,6 @@ func walktypedef(die *DWDie) *DWDie {
|
||||
func find(die *DWDie, name string) *DWDie {
|
||||
var prev *DWDie
|
||||
for ; die != prev; prev, die = die, walktypedef(die) {
|
||||
|
||||
if die.hash == nil {
|
||||
for a := die.child; a != nil; a = a.link {
|
||||
if name == getattr(a, DW_AT_name).data {
|
||||
@ -619,28 +603,9 @@ func find(die *DWDie, name string) *DWDie {
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
h := int(dwarfhashstr(name))
|
||||
a := die.hash[h]
|
||||
|
||||
if a == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if name == getattr(a, DW_AT_name).data {
|
||||
if a := die.hash[name]; a != nil {
|
||||
return a
|
||||
}
|
||||
|
||||
// Move found ones to head of the list.
|
||||
for b := a.hlink; b != nil; b = b.hlink {
|
||||
if name == getattr(b, DW_AT_name).data {
|
||||
a.hlink = b.hlink
|
||||
b.hlink = die.hash[h]
|
||||
die.hash[h] = b
|
||||
return b
|
||||
}
|
||||
a = b
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -1621,12 +1586,9 @@ func writelines() {
|
||||
}
|
||||
|
||||
var (
|
||||
dt int
|
||||
offs int64
|
||||
varhash [HASHSIZE]*DWDie
|
||||
dt, da int
|
||||
offs int64
|
||||
)
|
||||
da := 0
|
||||
dwfunc.hash = varhash[:] // enable indexing of children by name
|
||||
for a := s.Autom; a != nil; a = a.Link {
|
||||
switch a.Name {
|
||||
case obj.A_AUTO:
|
||||
@ -1678,8 +1640,6 @@ func writelines() {
|
||||
|
||||
da++
|
||||
}
|
||||
|
||||
dwfunc.hash = nil
|
||||
}
|
||||
|
||||
flushunit(dwinfo, epc, epcs, unitstart, int32(headerend-unitstart-10))
|
||||
|
Loading…
Reference in New Issue
Block a user