runtime: add lr, ctxt, ret to Gobuf
Add gostartcall and gostartcallfn.
The old gogocall = gostartcall + gogo.
The old gogocallfn = gostartcallfn + gogo.
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c File src/pkg/runtime/stack.c (right): https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c#newcode281 src/pkg/runtime/stack.c:281: runtime·gostartcall(&label, m->morepc, nil); the context argument here must be ...
10 years, 10 months ago
(2013-06-06 09:36:50 UTC)
#1
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/asm_386.s File src/pkg/runtime/asm_386.s (right): https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/asm_386.s#newcode385 src/pkg/runtime/asm_386.s:385: TEXT runtime·atomicstorep(SB), 7, $0 I am getting a weird ...
10 years, 10 months ago
(2013-06-06 09:57:02 UTC)
#2
10 years, 10 months ago
(2013-06-10 19:03:46 UTC)
#3
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/mgc0.c
File src/pkg/runtime/mgc0.c (right):
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/mgc0.c#newc...
src/pkg/runtime/mgc0.c:1405: if(pc == (byte*)f->entry) {
On 2013/06/06 09:57:02, dvyukov wrote:
> The idea behind my CL that adds 'started' parameter to addframeroots
> (https://codereview.appspot.com/9873045)
> is to not let all this platform-dependent mess into GC code.
> I want it to be situated in traceback code, and provide slightly higher-level
> interface to GC code.
>
> Preempted functions will have *not* adjusted SP, but PC != f->entry (PC points
> to the point after morestack call).
> So this condition will need to be updated in 2 places -- traceback and GC.
>
> You wrote:
> >This CL will need to be revised if Dmitriy cleans up my CL tweaking the
> > goroutine representation. In that CL there is no longer a concept of
> > a non-started > goroutine. There are just functions on the stack that
> > haven't yet bumped the SP to allocate a frame (those are identified by pc ==
> f->entry).
>
> My 'started' parameter means exactly that -- whether SP is adjusted or not. If
> it does not adjust SP yet, it's not started in some sense. Probably it's a bad
> name.
> A better option may be to pass properly adjusted SP and FP to addframeroots.
I am in favor of a cleaner fix, but I think it should be done in a separate CL.
I agree that perhaps passing in separate sp fp is best.
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c
File src/pkg/runtime/stack.c (right):
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c#new...
src/pkg/runtime/stack.c:138: if(0) {
On 2013/06/06 09:57:02, dvyukov wrote:
> drop {} ;)
Done.
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c#new...
src/pkg/runtime/stack.c:281: runtime·gostartcall(&label, m->morepc, nil);
On 2013/06/06 09:36:50, dvyukov wrote:
> the context argument here must be m->cret
> after changing it to:
>
> label.ret = 0;
> label.ctxt = nil;
> if(reflectcall)
> runtime·gostartcallfn(&label, (FuncVal*)m->morepc);
> else
> runtime·gostartcall(&label, m->morepc, (void*)m->cret);
> m->morepc = nil;
> m->cret = 0;
> runtime·gogo(&label);
>
> it seems to work fine
Ugh. Thanks. I added a comment too.
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/sys_x86.c
File src/pkg/runtime/sys_x86.c (right):
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/sys_x86.c#n...
src/pkg/runtime/sys_x86.c:28: runtime·gostartcall(gobuf, fv->fn, fv);
On 2013/06/06 09:57:02, dvyukov wrote:
> Can we just do this call inplace?
I guess, but then there are two copies. Does it matter? This doesn't run very
often.
10 years, 10 months ago
(2013-06-10 19:21:41 UTC)
#4
On 2013/06/10 19:03:46, rsc wrote:
> https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/mgc0.c
> File src/pkg/runtime/mgc0.c (right):
>
>
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/mgc0.c#newc...
> src/pkg/runtime/mgc0.c:1405: if(pc == (byte*)f->entry) {
> On 2013/06/06 09:57:02, dvyukov wrote:
> > The idea behind my CL that adds 'started' parameter to addframeroots
> > (https://codereview.appspot.com/9873045)
> > is to not let all this platform-dependent mess into GC code.
> > I want it to be situated in traceback code, and provide slightly
higher-level
> > interface to GC code.
> >
> > Preempted functions will have *not* adjusted SP, but PC != f->entry (PC
points
> > to the point after morestack call).
> > So this condition will need to be updated in 2 places -- traceback and GC.
> >
> > You wrote:
> > >This CL will need to be revised if Dmitriy cleans up my CL tweaking the
> > > goroutine representation. In that CL there is no longer a concept of
> > > a non-started > goroutine. There are just functions on the stack that
> > > haven't yet bumped the SP to allocate a frame (those are identified by pc
==
> > f->entry).
> >
> > My 'started' parameter means exactly that -- whether SP is adjusted or not.
If
> > it does not adjust SP yet, it's not started in some sense. Probably it's a
bad
> > name.
> > A better option may be to pass properly adjusted SP and FP to addframeroots.
>
> I am in favor of a cleaner fix, but I think it should be done in a separate
CL.
> I agree that perhaps passing in separate sp fp is best.
>
> https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c
> File src/pkg/runtime/stack.c (right):
>
>
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c#new...
> src/pkg/runtime/stack.c:138: if(0) {
> On 2013/06/06 09:57:02, dvyukov wrote:
> > drop {} ;)
>
> Done.
>
>
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/stack.c#new...
> src/pkg/runtime/stack.c:281: runtime·gostartcall(&label, m->morepc, nil);
> On 2013/06/06 09:36:50, dvyukov wrote:
> > the context argument here must be m->cret
> > after changing it to:
> >
> > label.ret = 0;
> > label.ctxt = nil;
> > if(reflectcall)
> > runtime·gostartcallfn(&label, (FuncVal*)m->morepc);
> > else
> > runtime·gostartcall(&label, m->morepc, (void*)m->cret);
> > m->morepc = nil;
> > m->cret = 0;
> > runtime·gogo(&label);
> >
> > it seems to work fine
>
> Ugh. Thanks. I added a comment too.
>
> https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/sys_x86.c
> File src/pkg/runtime/sys_x86.c (right):
>
>
https://codereview.appspot.com/10036044/diff/5001/src/pkg/runtime/sys_x86.c#n...
> src/pkg/runtime/sys_x86.c:28: runtime·gostartcall(gobuf, fv->fn, fv);
> On 2013/06/06 09:57:02, dvyukov wrote:
> > Can we just do this call inplace?
>
> I guess, but then there are two copies. Does it matter? This doesn't run very
> often.
It does not matter too much.
The changes are not uploaded yet, right?
I think Ian must take a look as well.
PTAL On 386, all.bash compiles and passes (thanks to CL 10167043). On amd64, all.bash almost ...
10 years, 10 months ago
(2013-06-10 20:16:06 UTC)
#5
PTAL
On 386, all.bash compiles and passes (thanks to CL 10167043).
On amd64, all.bash almost passes. It fails at fixedbugs/issue5493.go with not
all finalizers called (8 of 10). I can't tell if this is the CL's fault or the
test is just flaky.
I have not tested ARM.
On 2013/06/10 20:16:06, rsc wrote: > PTAL > > On 386, all.bash compiles and passes ...
10 years, 10 months ago
(2013-06-10 21:16:54 UTC)
#7
On 2013/06/10 20:16:06, rsc wrote:
> PTAL
>
> On 386, all.bash compiles and passes (thanks to CL 10167043).
>
> On amd64, all.bash almost passes. It fails at fixedbugs/issue5493.go with not
> all finalizers called (8 of 10). I can't tell if this is the CL's fault or the
> test is just flaky.
I think you need to zeroize gp->sched.ctxt in mcall or in gogo (or probably
runtime.goexit will do for now).
ctxt is void*, so when GC scans runtime.allg, it sees that pointer. Even if you
make it uintptr, G can be reached from other places and be scanned
conservatively, and then the closure will be leaked again.
On Tue, Jun 11, 2013 at 9:41 AM, <rsc@golang.org> wrote: > https://codereview.appspot.**com/10036044/diff/16001/src/** > pkg/runtime/asm_arm.s#**newcode104<https://codereview.appspot.com/10036044/diff/16001/src/pkg/runtime/asm_arm.s#newcode104> > ...
10 years, 10 months ago
(2013-06-11 18:16:15 UTC)
#11
On Tue, Jun 11, 2013 at 9:41 AM, <rsc@golang.org> wrote:
> https://codereview.appspot.**com/10036044/diff/16001/src/**
>
pkg/runtime/asm_arm.s#**newcode104<https://codereview.appspot.com/10036044/diff/16001/src/pkg/runtime/asm_arm.s#newcode104>
> src/pkg/runtime/asm_arm.s:104: MOVW $0, gobuf_lr(R0)
> On 2013/06/10 21:09:46, minux wrote:
>
>> please use a temporary register to assign 0 to memory (I used R11).
>>
>
> Done, but doesn't 5l do that for me?
at least 5l doesn't do that now. Do you want it to be implemented?
I'm pretty sure that the new code and the stack frame walker are not getting ...
10 years, 10 months ago
(2013-06-11 18:52:41 UTC)
#13
I'm pretty sure that the new code and the stack frame walker are not
getting along: if I turn the stack frame-based gc off, all is well. I'm
working on simplifying the stack frame walker a bit, which should help.
Russ
LGTM. https://codereview.appspot.com/10036044/diff/69001/src/pkg/runtime/runtime.h File src/pkg/runtime/runtime.h (right): https://codereview.appspot.com/10036044/diff/69001/src/pkg/runtime/runtime.h#newcode212 src/pkg/runtime/runtime.h:212: // The offsets of these fields are known ...
10 years, 10 months ago
(2013-06-12 19:10:47 UTC)
#15
Thanks for the review. https://codereview.appspot.com/10036044/diff/69001/src/pkg/runtime/runtime.h File src/pkg/runtime/runtime.h (right): https://codereview.appspot.com/10036044/diff/69001/src/pkg/runtime/runtime.h#newcode212 src/pkg/runtime/runtime.h:212: // The offsets of these ...
10 years, 10 months ago
(2013-06-12 19:15:07 UTC)
#16
Issue 10036044: code review 10036044: runtime: add lr, ctxt, ret to Gobuf
(Closed)
Created 10 years, 10 months ago by rsc
Modified 10 years, 10 months ago
Reviewers:
Base URL:
Comments: 18