]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: move entry method from _func to funcInfo
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Sep 2021 21:22:51 +0000 (14:22 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 27 Sep 2021 20:59:03 +0000 (20:59 +0000)
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>
src/cmd/compile/internal/test/inl_test.go
src/runtime/symtab.go

index 06afe835e2f8c26be890926d80c5586a67b58717..89247fbabf177dec428e6b4e003fa0f9020c0870 100644 (file)
@@ -65,7 +65,7 @@ func TestIntendedInlining(t *testing.T) {
                        "(*bmap).keys",
                        "(*bmap).overflow",
                        "(*waitq).enqueue",
-                       "(*_func).entry",
+                       "funcInfo.entry",
 
                        // GC-related ones
                        "cgoInRange",
index a11e22130da463296a2380dc94da5ad18f6b7a9a..7a9bb3e06b31965a7425a47b9341c65517cde970 100644 (file)
@@ -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
 }