ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.458 by root, Fri Jun 17 04:59:27 2016 UTC vs.
Revision 1.463 by root, Wed Jun 22 20:37:27 2016 UTC

730static void 730static void
731swap_svs_enter (pTHX_ Coro__State c) 731swap_svs_enter (pTHX_ Coro__State c)
732{ 732{
733 int i; 733 int i;
734 734
735 for (i = 0; i <= AvFILLp (c->swap_sv); i += 2)
736 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]);
737}
738
739static void
740swap_svs_leave (pTHX_ Coro__State c)
741{
742 int i;
743
735 for (i = AvFILLp (c->swap_sv) - 1; i >= 0; i -= 2) 744 for (i = AvFILLp (c->swap_sv) - 1; i >= 0; i -= 2)
736 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]);
737}
738
739static void
740swap_svs_leave (pTHX_ Coro__State c)
741{
742 int i;
743
744 for (i = 0; i <= AvFILLp (c->swap_sv); i += 2)
745 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]); 745 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]);
746} 746}
747 747
748#define SWAP_SVS_ENTER(coro) \ 748#define SWAP_SVS_ENTER(coro) \
749 if (ecb_expect_false ((coro)->swap_sv)) \ 749 if (ecb_expect_false ((coro)->swap_sv)) \
963#endif 963#endif
964 964
965 New(54,PL_savestack,24,ANY); 965 New(54,PL_savestack,24,ANY);
966 PL_savestack_ix = 0; 966 PL_savestack_ix = 0;
967 PL_savestack_max = 24; 967 PL_savestack_max = 24;
968#if !PERL_VERSION_ATLEAST (5,24,0)
969 /* perl 5.24 moves SS_MAXPUSH optimisation from */
970 /* the header macros to PL_savestack_max */
971 PL_savestack_max -= SS_MAXPUSH;
972#endif
968 973
969#if !PERL_VERSION_ATLEAST (5,10,0) 974#if !PERL_VERSION_ATLEAST (5,10,0)
970 New(54,PL_retstack,4,OP*); 975 New(54,PL_retstack,4,OP*);
971 PL_retstack_ix = 0; 976 PL_retstack_ix = 0;
972 PL_retstack_max = 4; 977 PL_retstack_max = 4;
1538 * coro body here, as perl_run destroys these. Likewise, we cannot catch 1543 * coro body here, as perl_run destroys these. Likewise, we cannot catch
1539 * runtime errors here, as this is just a random interpreter, not a thread. 1544 * runtime errors here, as this is just a random interpreter, not a thread.
1540 */ 1545 */
1541 1546
1542 /* 1547 /*
1548 * pp_entersub in 5.24 no longer ENTERs, but perl_destruct
1549 * requires PL_scopestack_ix, so do it here if required.
1550 */
1551 if (!PL_scopestack_ix)
1552 ENTER;
1553
1554 /*
1543 * If perl-run returns we assume exit() was being called or the coro 1555 * If perl-run returns we assume exit() was being called or the coro
1544 * fell off the end, which seems to be the only valid (non-bug) 1556 * fell off the end, which seems to be the only valid (non-bug)
1545 * reason for perl_run to return. We try to mimic whatever perl is normally 1557 * reason for perl_run to return. We try to mimic whatever perl is normally
1546 * doing in that case. YMMV. 1558 * doing in that case. YMMV.
1547 */ 1559 */
2428 av_clear (GvAV (PL_defgv)); 2440 av_clear (GvAV (PL_defgv));
2429 hv_store (hv, "desc", sizeof ("desc") - 1, SvREFCNT_inc_NN (sv_async_pool_idle), 0); 2441 hv_store (hv, "desc", sizeof ("desc") - 1, SvREFCNT_inc_NN (sv_async_pool_idle), 0);
2430 2442
2431 if (ecb_expect_false (coro->swap_sv)) 2443 if (ecb_expect_false (coro->swap_sv))
2432 { 2444 {
2445 swap_svs_leave (coro);
2433 SvREFCNT_dec_NN (coro->swap_sv); 2446 SvREFCNT_dec_NN (coro->swap_sv);
2434 coro->swap_sv = 0; 2447 coro->swap_sv = 0;
2435 } 2448 }
2436 2449
2437 coro->prio = 0; 2450 coro->prio = 0;
2438 2451
2439 if (coro->cctx && ecb_expect_false (coro->cctx->flags & CC_TRACE)) 2452 if (ecb_expect_false (coro->cctx) && ecb_expect_false (coro->cctx->flags & CC_TRACE))
2440 api_trace (aTHX_ coro_current, 0); 2453 api_trace (aTHX_ coro_current, 0);
2441 2454
2442 frame->prepare = prepare_schedule; 2455 frame->prepare = prepare_schedule;
2443 av_push (av_async_pool, SvREFCNT_inc (hv)); 2456 av_push (av_async_pool, SvREFCNT_inc (hv));
2444 } 2457 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines