Skip to content

Commit 458379d

Browse files
runtime,cmd/link: merge pcbucketsize const into internal/abi
For #59670 Change-Id: I53e100362325472fd16a986c49ad94bb2c77244f
1 parent b634f6f commit 458379d

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/cmd/link/internal/ld/pcln.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,8 @@ func expandGoroot(s string) string {
827827
}
828828

829829
const (
830-
BUCKETSIZE = 256 * abi.MINFUNC
831830
SUBBUCKETS = 16
832-
SUBBUCKETSIZE = BUCKETSIZE / SUBBUCKETS
831+
SUBBUCKETSIZE = abi.Pcbucketsize / SUBBUCKETS
833832
NOIDX = 0x7fffffff
834833
)
835834

@@ -847,7 +846,7 @@ func (ctxt *Link) findfunctab(state *pclntab, container loader.Bitmap) {
847846
// that map to that subbucket.
848847
n := int32((max - min + SUBBUCKETSIZE - 1) / SUBBUCKETSIZE)
849848

850-
nbuckets := int32((max - min + BUCKETSIZE - 1) / BUCKETSIZE)
849+
nbuckets := int32((max - min + abi.Pcbucketsize - 1) / abi.Pcbucketsize)
851850

852851
size := 4*int64(nbuckets) + int64(n)
853852

src/internal/abi/symtab.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,5 @@ const (
107107
)
108108

109109
const MINFUNC = 16 // minimum size for a function
110+
111+
const Pcbucketsize = 256 * MINFUNC // size of bucket in the pc->func lookup table

src/runtime/symtab.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,6 @@ type textsect struct {
497497
baseaddr uintptr // relocated section address
498498
}
499499

500-
const pcbucketsize = 256 * abi.MINFUNC // size of bucket in the pc->func lookup table
501-
502500
// findfuncbucket is an array of these structures.
503501
// Each bucket represents 4096 bytes of the text segment.
504502
// Each subbucket represents 256 bytes of the text segment.
@@ -780,8 +778,8 @@ func findfunc(pc uintptr) funcInfo {
780778
}
781779

782780
x := uintptr(pcOff) + datap.text - datap.minpc // TODO: are datap.text and datap.minpc always equal?
783-
b := x / pcbucketsize
784-
i := x % pcbucketsize / (pcbucketsize / nsub)
781+
b := x / abi.Pcbucketsize
782+
i := x % abi.Pcbucketsize / (abi.Pcbucketsize / nsub)
785783

786784
ffb := (*findfuncbucket)(add(unsafe.Pointer(datap.findfunctab), b*unsafe.Sizeof(findfuncbucket{})))
787785
idx := ffb.idx + uint32(ffb.subbuckets[i])

0 commit comments

Comments
 (0)