Skip to content

Commit

Permalink
coro: do not reset cont address
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Oct 23, 2014
1 parent 9e75fd9 commit 90de1df
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/pmc/continuation.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ destination to continue execution.
Parrot_sub_full_sub_name(INTERP, from_sub));
#endif
}
GETATTR_Coroutine_address(INTERP, from_sub, pc);
SETATTR_Coroutine_yield(INTERP, from_sub, 2);
pc = VTABLE_invoke(INTERP, from_sub, pc);
}
Expand Down
3 changes: 2 additions & 1 deletion src/pmc/coroutine.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void print_sub_name(PARROT_INTERP, ARGIN(PMC *sub_pmc))
# define TRACE_CORO_1(s, arg) \
if (Interp_trace_TEST(interp, PARROT_TRACE_CORO_STATE_FLAG)) \
fprintf(stderr, (s), (arg))
# define TRACE_CORO_d(s, arg) /* TRACE_CORO_1(s, arg) */
# define TRACE_CORO_d(s, arg) TRACE_CORO_1(s, arg)
#endif


Expand Down Expand Up @@ -259,6 +259,7 @@ yields are exhausted and the coro is dead.
Parrot_pcc_set_context(INTERP, ctx);
TRACE_CORO_d("# - coro: first ctx %p\n", caller_ctx);
TRACE_CORO_d("# - coro: to_ctx %p\n", ctx);
TRACE_CORO_d("# - coro: cont %p\n", ccont);

GET_ATTR_n_regs_used(INTERP, SELF, n_regs_used);
Parrot_pcc_allocate_registers(INTERP, ctx, n_regs_used);
Expand Down
9 changes: 5 additions & 4 deletions t/compilers/imcc/syn/pcc.t
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ pir_output_is( <<'CODE', <<'OUT', "coroutine iterator" );
.local int i
i=5
new $P1, 'Continuation'
set_label $P1, after_loop
loop:
$I2 = _addtwo(i)
if $I2 == -1 goto after_loop
$I2 = _addtwo($P1, i)
print $I2
print "\n"
goto loop
Expand All @@ -177,18 +177,19 @@ loop:
.end
.sub _addtwo
.param pmc when_done
.param int a
.local int i
i = 0
loop:
if i >= 10 goto done
if i >= 7 goto done
$I5 = a+i
.yield($I5)
i = i + 1
goto loop
done:
print "done in coroutine\n"
.return(-1)
when_done()
.end
CODE
5
Expand Down
13 changes: 3 additions & 10 deletions t/pmc/coroutine.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ done
OUTPUT

# very old-style syntax, returncc does not honor the continuation label here
pir_output_is( <<'CODE', <<'OUTPUT', "yield and returncc with cont", todo=>'returncc to label' );
pir_output_is( <<'CODE', <<'OUTPUT', "yield and returncc with cont"); #, todo=>'returncc to label' );
.sub __main__ :main
.local pmc return
.local pmc counter
Expand Down Expand Up @@ -88,21 +88,14 @@ return_here:
.set_yield x
.end_yield
x = x + 1
if x <= 10 goto iloop
if x <= 3 goto iloop
returncc
.end
CODE
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
OUTPUT

pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in main" );
Expand Down Expand Up @@ -550,7 +543,7 @@ in coro 2nd
2
OUTPUT

pir_output_is(<<'CODE', <<'OUTPUT', "autoreset", todo => 'wrong return cont GH #1106' );
pir_output_is(<<'CODE', <<'OUTPUT', "autoreset"); #, todo => 'wrong return cont GH #1106' );
.sub 'main' :main
.const 'Coroutine' $P99 = 'MyCoro'
$P99.'autoreset'()
Expand Down

0 comments on commit 90de1df

Please sign in to comment.