diff options
| author | Austin Clements <austin@google.com> | 2023-02-09 14:40:05 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2023-03-10 17:59:27 +0000 |
| commit | 86b69ef329c346fc6cc9b262e97bbdce7322288c (patch) | |
| tree | b2281846b8c7a20982debfee440a74af405618ee /src | |
| parent | ec319d6d430d2b64c59ad3f8842048b3d79efae1 (diff) | |
| download | go-86b69ef329c346fc6cc9b262e97bbdce7322288c.tar.xz | |
runtime: replace cgoCtxt slice with index in traceback
Currently, gentraceback consumes the gp.cgoCtxt slice by copying the
slice header and then sub-slicing it as it unwinds. The code for this
is nice and clear, but we're about to lift this state into a structure
and mutating it is going to introduce write barriers that are
disallowed in gentraceback.
This CL replaces the mutable slice header with an index into
gp.cgoCtxt.
For #54466.
Change-Id: I6b701bb67d657290a784baaca34ed02d8247ede2
Reviewed-on: https://go-review.googlesource.com/c/go/+/466863
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/traceback.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index b4717ab164..17cd156f1d 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -76,7 +76,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in if usesLR { frame.lr = lr0 } - cgoCtxt := gp.cgoCtxt + cgoCtxt := len(gp.cgoCtxt) - 1 // Index into gp.cgoCtxt printing := pcbuf == nil && callback == nil // If the PC is zero, it's likely a nil function call. @@ -175,7 +175,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in flag = f.flag frame.lr = gp.sched.lr frame.sp = gp.sched.sp - cgoCtxt = gp.cgoCtxt + cgoCtxt = len(gp.cgoCtxt) - 1 case funcID_systemstack: // systemstack returns normally, so just follow the // stack transition. @@ -192,7 +192,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in } gp = gp.m.curg frame.sp = gp.sched.sp - cgoCtxt = gp.cgoCtxt + cgoCtxt = len(gp.cgoCtxt) - 1 flag &^= funcFlag_SPWRITE } } @@ -390,9 +390,9 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in } n++ - if f.funcID == funcID_cgocallback && len(cgoCtxt) > 0 { - ctxt := cgoCtxt[len(cgoCtxt)-1] - cgoCtxt = cgoCtxt[:len(cgoCtxt)-1] + if f.funcID == funcID_cgocallback && cgoCtxt >= 0 { + ctxt := gp.cgoCtxt[cgoCtxt] + cgoCtxt-- // skip only applies to Go frames. // callback != nil only used when we only care |
