proc: cache module data (#3800)
Cache module data so that we don't reload it every time we look up a variable with a generic type.
This commit is contained in:
parent
582305a813
commit
059f149433
@ -104,6 +104,8 @@ type BinaryInfo struct {
|
|||||||
// dwrapUnwrapCache caches unwrapping of defer wrapper functions (dwrap)
|
// dwrapUnwrapCache caches unwrapping of defer wrapper functions (dwrap)
|
||||||
dwrapUnwrapCache map[uint64]*Function
|
dwrapUnwrapCache map[uint64]*Function
|
||||||
|
|
||||||
|
moduleDataCache []ModuleData
|
||||||
|
|
||||||
// Go 1.17 register ABI is enabled.
|
// Go 1.17 register ABI is enabled.
|
||||||
regabi bool
|
regabi bool
|
||||||
|
|
||||||
|
|||||||
@ -260,6 +260,7 @@ func (t *Target) SupportsFunctionCalls() bool {
|
|||||||
func (t *Target) ClearCaches() {
|
func (t *Target) ClearCaches() {
|
||||||
t.clearFakeMemory()
|
t.clearFakeMemory()
|
||||||
t.gcache.Clear()
|
t.gcache.Clear()
|
||||||
|
t.BinInfo().moduleDataCache = nil
|
||||||
for _, thread := range t.ThreadList() {
|
for _, thread := range t.ThreadList() {
|
||||||
thread.Common().g = nil
|
thread.Common().g = nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,9 +149,15 @@ func resolveParametricType(bi *BinaryInfo, mem MemoryReadWriter, t godwarf.Type,
|
|||||||
}
|
}
|
||||||
_type := newVariable("", rtypeAddr, runtimeType, bi, mem)
|
_type := newVariable("", rtypeAddr, runtimeType, bi, mem)
|
||||||
|
|
||||||
mds, err := LoadModuleData(bi, _type.mem)
|
var mds []ModuleData
|
||||||
if err != nil {
|
if bi.moduleDataCache != nil {
|
||||||
return ptyp.TypedefType.Type, fmt.Errorf("error loading module data: %v", err)
|
mds = bi.moduleDataCache
|
||||||
|
} else {
|
||||||
|
mds, err = LoadModuleData(bi, _type.mem)
|
||||||
|
if err != nil {
|
||||||
|
return ptyp.TypedefType.Type, fmt.Errorf("error loading module data: %v", err)
|
||||||
|
}
|
||||||
|
bi.moduleDataCache = mds
|
||||||
}
|
}
|
||||||
|
|
||||||
typ, _, err := RuntimeTypeToDIE(_type, 0, mds)
|
typ, _, err := RuntimeTypeToDIE(_type, 0, mds)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user