mirror of
https://github.com/golang/go
synced 2024-11-17 12:44:49 -07:00
runtime: move entry method from _func to funcInfo
This will be required when we change from storing entry PCs in _func to entry PC offsets, which are relative to the containing module. Notably, almost all uses of the entry method were already called on a funcInfo. Only Func.Entry incurs the additional module lookup cost. This makes Entry considerably slower, but it is probably still fast enough in absolute terms that it is OK. name old time/op new time/op delta Func/Name-8 8.86ns ± 0% 8.33ns ± 2% -5.92% (p=0.000 n=12+13) Func/Entry-8 0.64ns ± 0% 2.62ns ±36% +310.07% (p=0.000 n=14+15) Func/FileLine-8 24.5ns ± 0% 25.0ns ± 4% +2.21% (p=0.015 n=14+13) Change-Id: Ia2d5de5f2f83fab334f1875452b9e8e87651d340 Reviewed-on: https://go-review.googlesource.com/c/go/+/351461 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
61a0a70113
commit
f0c79caa13
@ -65,7 +65,7 @@ func TestIntendedInlining(t *testing.T) {
|
||||
"(*bmap).keys",
|
||||
"(*bmap).overflow",
|
||||
"(*waitq).enqueue",
|
||||
"(*_func).entry",
|
||||
"funcInfo.entry",
|
||||
|
||||
// GC-related ones
|
||||
"cgoInRange",
|
||||
|
@ -272,11 +272,14 @@ func (f *Func) raw() *_func {
|
||||
}
|
||||
|
||||
func (f *Func) funcInfo() funcInfo {
|
||||
fn := f.raw()
|
||||
return f.raw().funcInfo()
|
||||
}
|
||||
|
||||
func (f *_func) funcInfo() funcInfo {
|
||||
// Find the module containing fn. fn is located in the pclntable.
|
||||
// The unsafe.Pointer to uintptr conversions and arithmetic
|
||||
// are safe because we are working with module addresses.
|
||||
ptr := uintptr(unsafe.Pointer(fn))
|
||||
ptr := uintptr(unsafe.Pointer(f))
|
||||
var mod *moduledata
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
if len(datap.pclntable) == 0 {
|
||||
@ -288,7 +291,7 @@ func (f *Func) funcInfo() funcInfo {
|
||||
break
|
||||
}
|
||||
}
|
||||
return funcInfo{fn, mod}
|
||||
return funcInfo{f, mod}
|
||||
}
|
||||
|
||||
// PCDATA and FUNCDATA table indexes.
|
||||
@ -682,7 +685,7 @@ func (f *Func) Entry() uintptr {
|
||||
fi := (*funcinl)(unsafe.Pointer(fn))
|
||||
return fi.entry
|
||||
}
|
||||
return fn.entry()
|
||||
return fn.funcInfo().entry()
|
||||
}
|
||||
|
||||
// FileLine returns the file name and line number of the
|
||||
@ -735,7 +738,7 @@ func (f *_func) isInlined() bool {
|
||||
}
|
||||
|
||||
// entry returns the entry PC for f.
|
||||
func (f *_func) entry() uintptr {
|
||||
func (f funcInfo) entry() uintptr {
|
||||
return f.entryPC
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user