]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] runtime: remove tracebackdefers
authorCherry Mui <cherryyz@google.com>
Fri, 4 Jun 2021 21:18:09 +0000 (17:18 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 8 Jun 2021 19:46:25 +0000 (19:46 +0000)
tracebackdefers is used for scanning/copying deferred functions'
arguments. Now that deferred functions are always argumentless,
it does nothing. Remove.

Change-Id: I55bedabe5584ea41a12cdb03d55ec9692a5aacd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/325916
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/mgcmark.go
src/runtime/stack.go
src/runtime/traceback.go

index 1fd0732d62dcc6b8a0831701d535bf322d08d9dc..eb70ae9f49326d2f399ec00c84bc8b8b385e754b 100644 (file)
@@ -750,14 +750,11 @@ func scanstack(gp *g, gcw *gcWork) {
        // Find additional pointers that point into the stack from the heap.
        // Currently this includes defers and panics. See also function copystack.
 
-       // Find and trace all defer arguments.
-       tracebackdefers(gp, scanframe, nil)
-
        // Find and trace other pointers in defer records.
        for d := gp._defer; d != nil; d = d.link {
                if d.fn != nil {
-                       // tracebackdefers above does not scan the func value, which could
-                       // be a stack allocated closure. See issue 30453.
+                       // Scan the func value, which could be a stack allocated closure.
+                       // See issue 30453.
                        scanblock(uintptr(unsafe.Pointer(&d.fn)), sys.PtrSize, &oneptrmask[0], gcw, &state)
                }
                if d.link != nil {
index a1182b00bdc152ff02835da1bf2c07c6816244b8..b5545ac796d87504ecc856a1624efbbde9200d08 100644 (file)
@@ -753,11 +753,6 @@ func adjustdefers(gp *g, adjinfo *adjustinfo) {
                adjustpointer(adjinfo, unsafe.Pointer(&d.varp))
                adjustpointer(adjinfo, unsafe.Pointer(&d.fd))
        }
-
-       // Adjust defer argument blocks the same way we adjust active stack frames.
-       // Note: this code is after the loop above, so that if a defer record is
-       // stack allocated, we work on the copy in the new stack.
-       tracebackdefers(gp, adjustframe, noescape(unsafe.Pointer(adjinfo)))
 }
 
 func adjustpanics(gp *g, adjinfo *adjustinfo) {
index 2564273a53ba8e6d5d3fc3d1069f83e158abc948..3fc9d07fc5a0b7641885db05138819a975025667 100644 (file)
@@ -21,38 +21,6 @@ import (
 
 const usesLR = sys.MinFrameSize > 0
 
-// Traceback over the deferred function calls.
-// Report them like calls that have been invoked but not started executing yet.
-func tracebackdefers(gp *g, callback func(*stkframe, unsafe.Pointer) bool, v unsafe.Pointer) {
-       var frame stkframe
-       for d := gp._defer; d != nil; d = d.link {
-               fn := d.fn
-               if fn == nil {
-                       // Defer of nil function. Args don't matter.
-                       frame.pc = 0
-                       frame.fn = funcInfo{}
-                       frame.argp = 0
-                       frame.arglen = 0
-                       frame.argmap = nil
-               } else {
-                       frame.pc = fn.fn
-                       f := findfunc(frame.pc)
-                       if !f.valid() {
-                               print("runtime: unknown pc in defer ", hex(frame.pc), "\n")
-                               throw("unknown pc")
-                       }
-                       frame.fn = f
-                       frame.argp = 0
-                       frame.arglen = 0
-                       frame.argmap = nil
-               }
-               frame.continpc = frame.pc
-               if !callback((*stkframe)(noescape(unsafe.Pointer(&frame))), v) {
-                       return
-               }
-       }
-}
-
 const sizeofSkipFunction = 256
 
 // Generic traceback. Handles runtime stack prints (pcbuf == nil),