alloc_trace.go raw
1 package compiler
2
3 // AllocSiteInfo describes a heap allocation site matched by -print-allocs.
4 type AllocSiteInfo struct {
5 ID int32 `json:"id"`
6 Name string `json:"name"` // "pkg/path.FuncName@file:line"
7 }
8
9 var AllocSites []AllocSiteInfo
10
11 func ResetAllocSites() {
12 AllocSites = AllocSites[:0]
13 }
14
15 func nextAllocSite(name string) int32 {
16 id := int32(len(AllocSites))
17 AllocSites = append(AllocSites, AllocSiteInfo{ID: id, Name: name})
18 return id
19 }
20