mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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
This commit is contained in:
parent
c93f74d34b
commit
0f99a91bb5
3 changed files with 13 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue