Skip to content

runtime,cmd/link: merge pcbucketsize const into internal/abi #65373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/cmd/link/internal/ld/pcln.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions src/internal/abi/symtab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions src/runtime/symtab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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])
Expand Down