Skip to content

Commit 90de1df

Browse files
author
Reini Urban
committed
coro: do not reset cont address
1 parent 9e75fd9 commit 90de1df

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

src/pmc/continuation.pmc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ destination to continue execution.
319319
Parrot_sub_full_sub_name(INTERP, from_sub));
320320
#endif
321321
}
322-
GETATTR_Coroutine_address(INTERP, from_sub, pc);
323322
SETATTR_Coroutine_yield(INTERP, from_sub, 2);
324323
pc = VTABLE_invoke(INTERP, from_sub, pc);
325324
}

src/pmc/coroutine.pmc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void print_sub_name(PARROT_INTERP, ARGIN(PMC *sub_pmc))
5656
# define TRACE_CORO_1(s, arg) \
5757
if (Interp_trace_TEST(interp, PARROT_TRACE_CORO_STATE_FLAG)) \
5858
fprintf(stderr, (s), (arg))
59-
# define TRACE_CORO_d(s, arg) /* TRACE_CORO_1(s, arg) */
59+
# define TRACE_CORO_d(s, arg) TRACE_CORO_1(s, arg)
6060
#endif
6161

6262

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

263264
GET_ATTR_n_regs_used(INTERP, SELF, n_regs_used);
264265
Parrot_pcc_allocate_registers(INTERP, ctx, n_regs_used);

t/compilers/imcc/syn/pcc.t

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ pir_output_is( <<'CODE', <<'OUT', "coroutine iterator" );
165165
.local int i
166166
i=5
167167
new $P1, 'Continuation'
168+
set_label $P1, after_loop
168169
loop:
169-
$I2 = _addtwo(i)
170-
if $I2 == -1 goto after_loop
170+
$I2 = _addtwo($P1, i)
171171
print $I2
172172
print "\n"
173173
goto loop
@@ -177,18 +177,19 @@ loop:
177177
.end
178178
179179
.sub _addtwo
180+
.param pmc when_done
180181
.param int a
181182
.local int i
182183
i = 0
183184
loop:
184-
if i >= 10 goto done
185+
if i >= 7 goto done
185186
$I5 = a+i
186187
.yield($I5)
187188
i = i + 1
188189
goto loop
189190
done:
190191
print "done in coroutine\n"
191-
.return(-1)
192+
when_done()
192193
.end
193194
CODE
194195
5

t/pmc/coroutine.t

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ done
4949
OUTPUT
5050

5151
# very old-style syntax, returncc does not honor the continuation label here
52-
pir_output_is( <<'CODE', <<'OUTPUT', "yield and returncc with cont", todo=>'returncc to label' );
52+
pir_output_is( <<'CODE', <<'OUTPUT', "yield and returncc with cont"); #, todo=>'returncc to label' );
5353
.sub __main__ :main
5454
.local pmc return
5555
.local pmc counter
@@ -88,21 +88,14 @@ return_here:
8888
.set_yield x
8989
.end_yield
9090
x = x + 1
91-
if x <= 10 goto iloop
91+
if x <= 3 goto iloop
9292
returncc
9393
.end
9494
CODE
9595
0 0
9696
1 0
9797
2 0
9898
3 0
99-
4 0
100-
5 0
101-
6 0
102-
7 0
103-
8 0
104-
9 0
105-
10 0
10699
OUTPUT
107100

108101
pasm_output_is( <<'CODE', <<'OUTPUT', "Coroutine - exception in main" );
@@ -550,7 +543,7 @@ in coro 2nd
550543
2
551544
OUTPUT
552545

553-
pir_output_is(<<'CODE', <<'OUTPUT', "autoreset", todo => 'wrong return cont GH #1106' );
546+
pir_output_is(<<'CODE', <<'OUTPUT', "autoreset"); #, todo => 'wrong return cont GH #1106' );
554547
.sub 'main' :main
555548
.const 'Coroutine' $P99 = 'MyCoro'
556549
$P99.'autoreset'()

0 commit comments

Comments
 (0)