mirror of
https://github.com/golang/go
synced 2024-11-18 02:34:46 -07:00
[dev.link] cmd/link: move findfunctab to a generated symbol
Basically removes all allocation from findfunctab: Findfunctab_GC 172kB ± 0% 0kB ± 0% ~ (p=1.000 n=1+1) Change-Id: I246f7d2751317886b658f7ef672fb30b3c519668 Reviewed-on: https://go-review.googlesource.com/c/go/+/239281 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
f033e23414
commit
1fdf5ba50c
@ -585,9 +585,6 @@ const (
|
||||
// a given text symbols is a container (outer sym).
|
||||
func (ctxt *Link) findfunctab(container loader.Bitmap) {
|
||||
ldr := ctxt.loader
|
||||
t := ldr.CreateSymForUpdate("runtime.findfunctab", 0)
|
||||
t.SetType(sym.SRODATA)
|
||||
ldr.SetAttrLocal(t.Sym(), true)
|
||||
|
||||
// find min and max address
|
||||
min := ldr.SymValue(ctxt.Textp[0])
|
||||
@ -598,6 +595,13 @@ func (ctxt *Link) findfunctab(container loader.Bitmap) {
|
||||
// that map to that subbucket.
|
||||
n := int32((max - min + SUBBUCKETSIZE - 1) / SUBBUCKETSIZE)
|
||||
|
||||
nbuckets := int32((max - min + BUCKETSIZE - 1) / BUCKETSIZE)
|
||||
|
||||
size := 4*int64(nbuckets) + int64(n)
|
||||
|
||||
writeFindFuncTab := func(_ *Link, s loader.Sym) {
|
||||
t := ldr.MakeSymbolUpdater(s)
|
||||
|
||||
indexes := make([]int32, n)
|
||||
for i := int32(0); i < n; i++ {
|
||||
indexes[i] = NOIDX
|
||||
@ -637,11 +641,6 @@ func (ctxt *Link) findfunctab(container loader.Bitmap) {
|
||||
idx++
|
||||
}
|
||||
|
||||
// allocate table
|
||||
nbuckets := int32((max - min + BUCKETSIZE - 1) / BUCKETSIZE)
|
||||
|
||||
t.Grow(4*int64(nbuckets) + int64(n))
|
||||
|
||||
// fill in table
|
||||
for i := int32(0); i < nbuckets; i++ {
|
||||
base := indexes[i*SUBBUCKETS]
|
||||
@ -661,4 +660,9 @@ func (ctxt *Link) findfunctab(container loader.Bitmap) {
|
||||
t.SetUint8(ctxt.Arch, int64(i)*(4+SUBBUCKETS)+4+int64(j), uint8(idx-base))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s := ctxt.createGeneratorSymbol("runtime.findfunctab", 0, sym.SRODATA, size, writeFindFuncTab)
|
||||
ldr.SetAttrReachable(s, true)
|
||||
ldr.SetAttrLocal(s, true)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user