]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: store start PC in pcvalueCache
authorAustin Clements <austin@google.com>
Tue, 1 Aug 2023 17:45:31 +0000 (13:45 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 7 Aug 2023 19:31:22 +0000 (19:31 +0000)
Currently, pcvalue only returns a valid start PC if cache is nil.
We're about to eliminate the cache argument and always use a pcvalue
cache, so make sure the cache stores the start PC and always return it
from pcvalue.

Change-Id: Ie8854af4b7e7ba1c2a17a495d9229320821daa23
Reviewed-on: https://go-review.googlesource.com/c/go/+/515275
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/symtab.go

index b47f2d839099fa780fa53621d35b5ac05df18500..ff5f5f7f0ef4073fc9862891970d0aa3dd9a7b54 100644 (file)
@@ -829,8 +829,9 @@ type pcvalueCacheEnt struct {
        // targetpc and off together are the key of this cache entry.
        targetpc uintptr
        off      uint32
-       // val is the value of this cached pcvalue entry.
-       val int32
+
+       val   int32   // The value of this entry.
+       valPC uintptr // The PC at which val starts
 }
 
 // pcvalueCacheKey returns the outermost index in a pcvalueCache to use for targetpc.
@@ -842,7 +843,6 @@ func pcvalueCacheKey(targetpc uintptr) uintptr {
 }
 
 // Returns the PCData value, and the PC where this value starts.
-// TODO: the start PC is returned only when cache is nil.
 func pcvalue(f funcInfo, off uint32, targetpc uintptr, cache *pcvalueCache, strict bool) (int32, uintptr) {
        if off == 0 {
                return -1, 0
@@ -864,7 +864,7 @@ func pcvalue(f funcInfo, off uint32, targetpc uintptr, cache *pcvalueCache, stri
                        // fail in the first clause.
                        ent := &cache.entries[x][i]
                        if ent.off == off && ent.targetpc == targetpc {
-                               return ent.val, 0
+                               return ent.val, ent.valPC
                        }
                }
        }
@@ -903,6 +903,7 @@ func pcvalue(f funcInfo, off uint32, targetpc uintptr, cache *pcvalueCache, stri
                                        targetpc: targetpc,
                                        off:      off,
                                        val:      val,
+                                       valPC:    prevpc,
                                }
                        }