mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link, runtime: use offset for _func.entry
The first field of the func data stored by the linker is the entry PC for the function. Prior to this change, this was stored as a relocation to the function. Change this to be an offset relative to runtime.text. This reduces the number of relocations on darwin/arm64 by about 10%. It also slightly shrinks binaries: file before after Δ % addr2line 3803058 3791298 -11760 -0.309% api 5140114 5104242 -35872 -0.698% asm 4886850 4840626 -46224 -0.946% buildid 2512466 2503042 -9424 -0.375% cgo 4374770 4342274 -32496 -0.743% compile 22920530 22769202 -151328 -0.660% cover 4624626 4588242 -36384 -0.787% dist 3217570 3205522 -12048 -0.374% doc 3715026 3684498 -30528 -0.822% fix 3148226 3119266 -28960 -0.920% link 6350226 6313362 -36864 -0.581% nm 3768850 3757106 -11744 -0.312% objdump 4140594 4127618 -12976 -0.313% pack 2227474 2218818 -8656 -0.389% pprof 13598706 13506786 -91920 -0.676% test2json 2497234 2487426 -9808 -0.393% trace 10198066 10118498 -79568 -0.780% vet 6930658 6889074 -41584 -0.600% total 108055044 107366900 -688144 -0.637% It should also incrementally speed up binary launching. This is the first step towards removing enough relocations that pages that were previously dirtied by the loader may remain clean, which will offer memory savings useful in constrained environments. Change-Id: Icfba55e696ba2f9c99c4f179125ba5a3ba4369c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/351463 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
88ea8a5fe0
commit
d3ad216f8e
4 changed files with 76 additions and 30 deletions
|
|
@ -858,8 +858,8 @@ const (
|
|||
// Keep in sync with linker (../cmd/link/internal/ld/pcln.go:/pclntab)
|
||||
// and with package debug/gosym and with symtab.go in package runtime.
|
||||
type _func struct {
|
||||
entryPC uintptr // start pc
|
||||
nameoff int32 // function name
|
||||
entryoff uint32 // start pc, as offset from moduledata.text/pcHeader.textStart
|
||||
nameoff int32 // function name
|
||||
|
||||
args int32 // in/out args size
|
||||
deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any.
|
||||
|
|
@ -879,7 +879,7 @@ type _func struct {
|
|||
// A *Func can be either a *_func or a *funcinl, and they are distinguished
|
||||
// by the first uintptr.
|
||||
type funcinl struct {
|
||||
ones uintptr // set to ^0 to distinguish from _func
|
||||
ones uint32 // set to ^0 to distinguish from _func
|
||||
entry uintptr // entry of the real (the "outermost") frame
|
||||
name string
|
||||
file string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue