diff options
| author | Russ Cox <rsc@golang.org> | 2014-09-08 21:02:36 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-09-08 21:02:36 -0400 |
| commit | 0f99a91bb56dd01dfd4e5ce4344e6006e3463ade (patch) | |
| tree | ee9114e1fac7f70c0e910fcc425e9a9b4b8e47e7 /src/runtime/stack.c | |
| parent | c93f74d34bf45bcbfa1cfda5ccd198ed5682ddf4 (diff) | |
| download | go-0f99a91bb56dd01dfd4e5ce4344e6006e3463ade.tar.xz | |
runtime: let stack copier update Panic structs for us
It already is updating parts of them; we're just getting lucky
retraversing them and not finding much to do.
Change argp to a pointer so that it will be updated too.
Existing tests break if you apply the change to adjustpanics
without also updating the type of argp.
LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/139380043
Diffstat (limited to 'src/runtime/stack.c')
| -rw-r--r-- | src/runtime/stack.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/runtime/stack.c b/src/runtime/stack.c index ca0eed06f9..8461c01f37 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -712,6 +712,10 @@ adjustdefers(G *gp, AdjustInfo *adjinfo) // get adjusted appropriately. // This only happens for runtime.main and runtime.gopanic now, // but a compiler optimization could do more of this. + // If such an optimization were introduced, Defer.argp should + // change to have pointer type so that it will be updated by + // the stack copying. Today both of those on-stack defers + // set argp = NoArgs, so no adjustment is necessary. *dp = (Defer*)((byte*)d + adjinfo->delta); continue; } @@ -751,17 +755,11 @@ adjustdefers(G *gp, AdjustInfo *adjinfo) static void adjustpanics(G *gp, AdjustInfo *adjinfo) { - Panic *p, **l; - - // only the topmost panic is on the current stack - for(l = &gp->panic; (p = *l) != nil; ) { - if(adjinfo->oldstk <= (byte*)p && (byte*)p < adjinfo->oldbase) - *l = (Panic*)((byte*)p + adjinfo->delta); - l = &p->link; - - if(adjinfo->oldstk <= (byte*)p->argp && (byte*)p->argp < adjinfo->oldbase) - p->argp += adjinfo->delta; - } + // Panic structs are all on the stack + // and are adjusted by stack copying. + // The only pointer we need to update is gp->panic, the head of the list. + if(adjinfo->oldstk <= (byte*)gp->panic && (byte*)gp->panic < adjinfo->oldbase) + gp->panic = (Panic*)((byte*)gp->panic + adjinfo->delta); } static void |
