… | |
… | |
1383 | coro_setup (aTHX_ next); |
1383 | coro_setup (aTHX_ next); |
1384 | } |
1384 | } |
1385 | else |
1385 | else |
1386 | load_perl (aTHX_ next); |
1386 | load_perl (aTHX_ next); |
1387 | |
1387 | |
|
|
1388 | assert (!prev->cctx);//D temporary |
|
|
1389 | |
1388 | /* possibly untie and reuse the cctx */ |
1390 | /* possibly untie and reuse the cctx */ |
1389 | if (expect_true ( |
1391 | if (expect_true ( |
1390 | cctx_current->idle_sp == STACKLEVEL |
1392 | cctx_current->idle_sp == STACKLEVEL |
1391 | && !(cctx_current->flags & CC_TRACE) |
1393 | && !(cctx_current->flags & CC_TRACE) |
1392 | && !force_cctx |
1394 | && !force_cctx |
1393 | )) |
1395 | )) |
1394 | { |
1396 | { |
1395 | /* I assume that stacklevel is a stronger indicator than PL_top_env changes */ |
1397 | /* I assume that stacklevel is a stronger indicator than PL_top_env changes */ |
1396 | assert (("FATAL: current top_env must equal previous top_env in Coro (please report)", PL_top_env == cctx_current->idle_te)); |
1398 | assert (("FATAL: current top_env must equal previous top_env in Coro (please report)", PL_top_env == cctx_current->idle_te)); |
1397 | |
1399 | |
1398 | /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get */ |
1400 | /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get. */ |
1399 | /* without this the next cctx_get might destroy the prev__cctx while still in use */ |
1401 | /* without this the next cctx_get might destroy the running cctx while still in use */ |
1400 | if (expect_false (CCTX_EXPIRED (cctx_current))) |
1402 | if (expect_false (CCTX_EXPIRED (cctx_current))) |
1401 | if (!next->cctx) |
1403 | if (expect_true (!next->cctx)) |
1402 | next->cctx = cctx_get (aTHX); |
1404 | next->cctx = cctx_get (aTHX); |
1403 | |
1405 | |
1404 | cctx_put (cctx_current); |
1406 | cctx_put (cctx_current); |
1405 | assert (!prev->cctx);//D temporary |
|
|
1406 | } |
1407 | } |
1407 | else |
1408 | else |
1408 | prev->cctx = cctx_current; |
1409 | prev->cctx = cctx_current; |
1409 | |
1410 | |
1410 | ++next->usecount; |
1411 | ++next->usecount; |
… | |
… | |
1758 | static void |
1759 | static void |
1759 | api_trace (pTHX_ SV *coro_sv, int flags) |
1760 | api_trace (pTHX_ SV *coro_sv, int flags) |
1760 | { |
1761 | { |
1761 | struct coro *coro = SvSTATE (coro_sv); |
1762 | struct coro *coro = SvSTATE (coro_sv); |
1762 | |
1763 | |
|
|
1764 | if (coro->flags & CF_RUNNING) |
|
|
1765 | croak ("cannot enable tracing on a running coroutine, caught"); |
|
|
1766 | |
1763 | if (flags & CC_TRACE) |
1767 | if (flags & CC_TRACE) |
1764 | { |
1768 | { |
1765 | if (!coro->cctx) |
1769 | if (!coro->cctx) |
1766 | coro->cctx = cctx_new_run (); |
1770 | coro->cctx = cctx_new_run (); |
1767 | else if (!(coro->cctx->flags & CC_TRACE)) |
1771 | else if (!(coro->cctx->flags & CC_TRACE)) |
1768 | croak ("cannot enable tracing on coroutine with custom stack,"); |
1772 | croak ("cannot enable tracing on coroutine with custom stack, caught"); |
1769 | |
1773 | |
1770 | coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL)); |
1774 | coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL)); |
1771 | } |
1775 | } |
1772 | else if (coro->cctx && coro->cctx->flags & CC_TRACE) |
1776 | else if (coro->cctx && coro->cctx->flags & CC_TRACE) |
1773 | { |
1777 | { |