From 284e553035137fc339617f01dd53766977cd3e8c Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Fri, 16 Feb 2024 00:15:29 +0000 Subject: [PATCH] runtime,cmd/link: merge pcbucketsize const into internal/abi For #59670 Change-Id: I6343bacd3126fe6381a2e73be10f61691792824d GitHub-Last-Rev: bbab8d1142e5749f58c17f6f668e2eb679ff69d7 GitHub-Pull-Request: golang/go#65373 Reviewed-on: https://go-review.googlesource.com/c/go/+/559475 LUCI-TryBot-Result: Go LUCI Reviewed-by: Than McIntosh Reviewed-by: Cherry Mui --- src/cmd/link/internal/ld/pcln.go | 5 ++--- src/internal/abi/symtab.go | 2 ++ src/runtime/symtab.go | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cmd/link/internal/ld/pcln.go b/src/cmd/link/internal/ld/pcln.go index 170ebe5ebe..df06084352 100644 --- a/src/cmd/link/internal/ld/pcln.go +++ b/src/cmd/link/internal/ld/pcln.go @@ -827,9 +827,8 @@ func expandGoroot(s string) string { } const ( - BUCKETSIZE = 256 * abi.MINFUNC SUBBUCKETS = 16 - SUBBUCKETSIZE = BUCKETSIZE / SUBBUCKETS + SUBBUCKETSIZE = abi.FuncTabBucketSize / SUBBUCKETS NOIDX = 0x7fffffff ) @@ -847,7 +846,7 @@ func (ctxt *Link) findfunctab(state *pclntab, container loader.Bitmap) { // that map to that subbucket. n := int32((max - min + SUBBUCKETSIZE - 1) / SUBBUCKETSIZE) - nbuckets := int32((max - min + BUCKETSIZE - 1) / BUCKETSIZE) + nbuckets := int32((max - min + abi.FuncTabBucketSize - 1) / abi.FuncTabBucketSize) size := 4*int64(nbuckets) + int64(n) diff --git a/src/internal/abi/symtab.go b/src/internal/abi/symtab.go index 41026ea2ab..a3c9be7aa1 100644 --- a/src/internal/abi/symtab.go +++ b/src/internal/abi/symtab.go @@ -107,3 +107,5 @@ const ( ) const MINFUNC = 16 // minimum size for a function + +const FuncTabBucketSize = 256 * MINFUNC // size of bucket in the pc->func lookup table diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index a046ebef39..96a2d29079 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -497,8 +497,6 @@ type textsect struct { baseaddr uintptr // relocated section address } -const pcbucketsize = 256 * abi.MINFUNC // size of bucket in the pc->func lookup table - // findfuncbucket is an array of these structures. // Each bucket represents 4096 bytes of the text segment. // Each subbucket represents 256 bytes of the text segment. @@ -780,8 +778,8 @@ func findfunc(pc uintptr) funcInfo { } x := uintptr(pcOff) + datap.text - datap.minpc // TODO: are datap.text and datap.minpc always equal? - b := x / pcbucketsize - i := x % pcbucketsize / (pcbucketsize / nsub) + b := x / abi.FuncTabBucketSize + i := x % abi.FuncTabBucketSize / (abi.FuncTabBucketSize / nsub) ffb := (*findfuncbucket)(add(unsafe.Pointer(datap.findfunctab), b*unsafe.Sizeof(findfuncbucket{}))) idx := ffb.idx + uint32(ffb.subbuckets[i]) -- 2.48.1