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.456 by root, Sun Mar 6 06:26:21 2016 UTC vs.
Revision 1.471 by root, Fri Jul 14 23:20:07 2017 UTC

116# define CORO_CLOCK_MONOTONIC 1 116# define CORO_CLOCK_MONOTONIC 1
117# define CORO_CLOCK_THREAD_CPUTIME_ID 3 117# define CORO_CLOCK_THREAD_CPUTIME_ID 3
118# endif 118# endif
119#endif 119#endif
120 120
121/* one off bugfix for perl 5.22 */
122#if PERL_VERSION_ATLEAST(5,22,0) && !PERL_VERSION_ATLEAST(5,24,0)
123# undef PadlistNAMES
124# define PadlistNAMES(pl) *((PADNAMELIST **)PadlistARRAY (pl))
125#endif
126
127#if PERL_VERSION_ATLEAST(5,24,0)
128# define SUB_ARGARRAY PL_curpad[0]
129#else
130# define SUB_ARGARRAY (SV *)cx->blk_sub.argarray
131#endif
132
133/* perl usually suppresses asserts. for debugging, we sometimes force it to be on */
134#if 0
135# undef NDEBUG
136# include <assert.h>
137#endif
138
121static double (*nvtime)(); /* so why doesn't it take void? */ 139static double (*nvtime)(); /* so why doesn't it take void? */
122static void (*u2time)(pTHX_ UV ret[2]); 140static void (*u2time)(pTHX_ UV ret[2]);
123 141
124/* we hijack an hopefully unused CV flag for our purposes */ 142/* we hijack an hopefully unused CV flag for our purposes */
125#define CVf_SLF 0x4000 143#define CVf_SLF 0x4000
726#endif 744#endif
727} 745}
728 746
729/* swap sv heads, at least logically */ 747/* swap sv heads, at least logically */
730static void 748static void
731swap_svs (pTHX_ Coro__State c) 749swap_svs_enter (pTHX_ Coro__State c)
732{ 750{
733 int i; 751 int i;
734 752
735 for (i = 0; i <= AvFILLp (c->swap_sv); i += 2) 753 for (i = 0; i <= AvFILLp (c->swap_sv); i += 2)
736 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]); 754 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]);
737} 755}
738 756
757static void
758swap_svs_leave (pTHX_ Coro__State c)
759{
760 int i;
761
762 for (i = AvFILLp (c->swap_sv) - 1; i >= 0; i -= 2)
763 swap_sv (AvARRAY (c->swap_sv)[i], AvARRAY (c->swap_sv)[i + 1]);
764}
765
739#define SWAP_SVS(coro) \ 766#define SWAP_SVS_ENTER(coro) \
740 if (ecb_expect_false ((coro)->swap_sv)) \ 767 if (ecb_expect_false ((coro)->swap_sv)) \
741 swap_svs (aTHX_ (coro)) 768 swap_svs_enter (aTHX_ (coro))
769
770#define SWAP_SVS_LEAVE(coro) \
771 if (ecb_expect_false ((coro)->swap_sv)) \
772 swap_svs_leave (aTHX_ (coro))
742 773
743static void 774static void
744on_enterleave_call (pTHX_ SV *cb); 775on_enterleave_call (pTHX_ SV *cb);
745 776
746static void 777static void
799 830
800 for (i = 0; i <= AvFILLp (c->on_enter_xs); i += 2) 831 for (i = 0; i <= AvFILLp (c->on_enter_xs); i += 2)
801 ((coro_enterleave_hook)AvARRAY (c->on_enter_xs)[i]) (aTHX_ AvARRAY (c->on_enter_xs)[i + 1]); 832 ((coro_enterleave_hook)AvARRAY (c->on_enter_xs)[i]) (aTHX_ AvARRAY (c->on_enter_xs)[i + 1]);
802 } 833 }
803 834
804 SWAP_SVS (c); 835 SWAP_SVS_ENTER (c);
805} 836}
806 837
807static void 838static void
808save_perl (pTHX_ Coro__State c) 839save_perl (pTHX_ Coro__State c)
809{ 840{
810 SWAP_SVS (c); 841 SWAP_SVS_LEAVE (c);
811 842
812 if (ecb_expect_false (c->on_leave_xs)) 843 if (ecb_expect_false (c->on_leave_xs))
813 { 844 {
814 int i; 845 int i;
815 846
950#endif 981#endif
951 982
952 New(54,PL_savestack,24,ANY); 983 New(54,PL_savestack,24,ANY);
953 PL_savestack_ix = 0; 984 PL_savestack_ix = 0;
954 PL_savestack_max = 24; 985 PL_savestack_max = 24;
986#if PERL_VERSION_ATLEAST (5,24,0)
987 /* perl 5.24 moves SS_MAXPUSH optimisation from */
988 /* the header macros to PL_savestack_max */
989 PL_savestack_max -= SS_MAXPUSH;
990#endif
955 991
956#if !PERL_VERSION_ATLEAST (5,10,0) 992#if !PERL_VERSION_ATLEAST (5,10,0)
957 New(54,PL_retstack,4,OP*); 993 New(54,PL_retstack,4,OP*);
958 PL_retstack_ix = 0; 994 PL_retstack_ix = 0;
959 PL_retstack_max = 4; 995 PL_retstack_max = 4;
1025 } 1061 }
1026 1062
1027 return rss; 1063 return rss;
1028} 1064}
1029 1065
1030/** coroutine stack handling ************************************************/ 1066/** provide custom get/set/clear methods for %SIG elements ******************/
1031
1032static int (*orig_sigelem_get) (pTHX_ SV *sv, MAGIC *mg);
1033static int (*orig_sigelem_set) (pTHX_ SV *sv, MAGIC *mg);
1034static int (*orig_sigelem_clr) (pTHX_ SV *sv, MAGIC *mg);
1035 1067
1036/* apparently < 5.8.8 */ 1068/* apparently < 5.8.8 */
1037#ifndef MgPV_nolen_const 1069#ifndef MgPV_nolen_const
1038#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \ 1070#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \
1039 SvPV_nolen((SV*)((mg)->mg_ptr)) : \ 1071 SvPV_nolen((SV*)((mg)->mg_ptr)) : \
1040 (const char*)(mg)->mg_ptr) 1072 (const char*)(mg)->mg_ptr)
1041#endif 1073#endif
1074
1075/* this will be a patched copy of PL_vtbl_sigelem */
1076static MGVTBL coro_sigelem_vtbl;
1077
1078static int ecb_cold
1079coro_sig_copy (pTHX_ SV *sv, MAGIC *mg, SV *nsv, const char *name, I32 namlen)
1080{
1081 char *key = SvPV_nolen ((SV *)name);
1082
1083 /* do what mg_copy normally does */
1084 sv_magic (nsv, mg->mg_obj, PERL_MAGIC_sigelem, name, namlen);
1085 assert (mg_find (nsv, PERL_MAGIC_sigelem)->mg_virtual == &PL_vtbl_sigelem);
1086
1087 /* patch sigelem vtbl, but only for __WARN__ and __DIE__ */
1088 if (*key == '_'
1089 && (strEQ (key, "__DIE__")
1090 || strEQ (key, "__WARN__")))
1091 mg_find (nsv, PERL_MAGIC_sigelem)->mg_virtual = &coro_sigelem_vtbl;
1092
1093 return 1;
1094}
1095
1096/* perl does not have a %SIG vtbl, we provide one so we can override */
1097/* the magic vtbl for the __DIE__ and __WARN__ members */
1098static const MGVTBL coro_sig_vtbl = {
1099 0, 0, 0, 0, 0,
1100 coro_sig_copy
1101};
1042 1102
1043/* 1103/*
1044 * This overrides the default magic get method of %SIG elements. 1104 * This overrides the default magic get method of %SIG elements.
1045 * The original one doesn't provide for reading back of PL_diehook/PL_warnhook 1105 * The original one doesn't provide for reading back of PL_diehook/PL_warnhook
1046 * and instead of trying to save and restore the hash elements (extremely slow), 1106 * and instead of trying to save and restore the hash elements (extremely slow),
1048 */ 1108 */
1049static int ecb_cold 1109static int ecb_cold
1050coro_sigelem_get (pTHX_ SV *sv, MAGIC *mg) 1110coro_sigelem_get (pTHX_ SV *sv, MAGIC *mg)
1051{ 1111{
1052 const char *s = MgPV_nolen_const (mg); 1112 const char *s = MgPV_nolen_const (mg);
1113 /* the key must be either __DIE__ or __WARN__ here */
1114 SV **svp = s[2] == 'D' ? &PL_diehook : &PL_warnhook;
1053 1115
1054 if (*s == '_') 1116 SV *ssv;
1055 {
1056 SV **svp = 0;
1057 1117
1058 if (strEQ (s, "__DIE__" )) svp = &PL_diehook;
1059 if (strEQ (s, "__WARN__")) svp = &PL_warnhook;
1060
1061 if (svp) 1118 if (!*svp)
1062 {
1063 SV *ssv;
1064
1065 if (!*svp)
1066 ssv = &PL_sv_undef; 1119 ssv = &PL_sv_undef;
1067 else if (SvTYPE (*svp) == SVt_PVCV) /* perlio directly stores a CV in warnhook. ugh. */ 1120 else if (SvTYPE (*svp) == SVt_PVCV) /* perlio directly stores a CV in warnhook. ugh. */
1068 ssv = sv_2mortal (newRV_inc (*svp)); 1121 ssv = sv_2mortal (newRV_inc (*svp));
1069 else 1122 else
1070 ssv = *svp; 1123 ssv = *svp;
1071 1124
1072 sv_setsv (sv, ssv); 1125 sv_setsv (sv, ssv);
1073 return 0; 1126 return 0;
1074 }
1075 }
1076
1077 return orig_sigelem_get ? orig_sigelem_get (aTHX_ sv, mg) : 0;
1078} 1127}
1079 1128
1080static int ecb_cold 1129static int ecb_cold
1081coro_sigelem_clr (pTHX_ SV *sv, MAGIC *mg) 1130coro_sigelem_clr (pTHX_ SV *sv, MAGIC *mg)
1082{ 1131{
1083 const char *s = MgPV_nolen_const (mg); 1132 const char *s = MgPV_nolen_const (mg);
1133 /* the key must be either __DIE__ or __WARN__ here */
1134 SV **svp = s[2] == 'D' ? &PL_diehook : &PL_warnhook;
1084 1135
1085 if (*s == '_')
1086 {
1087 SV **svp = 0;
1088
1089 if (strEQ (s, "__DIE__" )) svp = &PL_diehook;
1090 if (strEQ (s, "__WARN__")) svp = &PL_warnhook;
1091
1092 if (svp)
1093 {
1094 SV *old = *svp; 1136 SV *old = *svp;
1095 *svp = 0; 1137 *svp = 0;
1096 SvREFCNT_dec (old); 1138 SvREFCNT_dec (old);
1097 return 0; 1139 return 0;
1098 }
1099 }
1100
1101 return orig_sigelem_clr ? orig_sigelem_clr (aTHX_ sv, mg) : 0;
1102} 1140}
1103 1141
1104static int ecb_cold 1142static int ecb_cold
1105coro_sigelem_set (pTHX_ SV *sv, MAGIC *mg) 1143coro_sigelem_set (pTHX_ SV *sv, MAGIC *mg)
1106{ 1144{
1107 const char *s = MgPV_nolen_const (mg); 1145 const char *s = MgPV_nolen_const (mg);
1146 /* the key must be either __DIE__ or __WARN__ here */
1147 SV **svp = s[2] == 'D' ? &PL_diehook : &PL_warnhook;
1108 1148
1109 if (*s == '_')
1110 {
1111 SV **svp = 0;
1112
1113 if (strEQ (s, "__DIE__" )) svp = &PL_diehook;
1114 if (strEQ (s, "__WARN__")) svp = &PL_warnhook;
1115
1116 if (svp)
1117 {
1118 SV *old = *svp; 1149 SV *old = *svp;
1119 *svp = SvOK (sv) ? newSVsv (sv) : 0; 1150 *svp = SvOK (sv) ? newSVsv (sv) : 0;
1120 SvREFCNT_dec (old); 1151 SvREFCNT_dec (old);
1121 return 0; 1152 return 0;
1122 }
1123 }
1124
1125 return orig_sigelem_set ? orig_sigelem_set (aTHX_ sv, mg) : 0;
1126} 1153}
1127 1154
1128static void 1155static void
1129prepare_nop (pTHX_ struct coro_transfer_args *ta) 1156prepare_nop (pTHX_ struct coro_transfer_args *ta)
1130{ 1157{
1141static int 1168static int
1142slf_check_repeat (pTHX_ struct CoroSLF *frame) 1169slf_check_repeat (pTHX_ struct CoroSLF *frame)
1143{ 1170{
1144 return 1; 1171 return 1;
1145} 1172}
1173
1174/** coroutine stack handling ************************************************/
1146 1175
1147static UNOP init_perl_op; 1176static UNOP init_perl_op;
1148 1177
1149ecb_noinline static void /* noinline to keep it out of the transfer fast path */ 1178ecb_noinline static void /* noinline to keep it out of the transfer fast path */
1150init_perl (pTHX_ struct coro *coro) 1179init_perl (pTHX_ struct coro *coro)
1217 PL_op = (OP *)&init_perl_op; 1246 PL_op = (OP *)&init_perl_op;
1218 1247
1219 /* copy throw, in case it was set before init_perl */ 1248 /* copy throw, in case it was set before init_perl */
1220 CORO_THROW = coro->except; 1249 CORO_THROW = coro->except;
1221 1250
1222 SWAP_SVS (coro); 1251 SWAP_SVS_ENTER (coro);
1223 1252
1224 if (ecb_expect_false (enable_times)) 1253 if (ecb_expect_false (enable_times))
1225 { 1254 {
1226 coro_times_update (); 1255 coro_times_update ();
1227 coro_times_sub (coro); 1256 coro_times_sub (coro);
1265 /* this will cause transfer_check to croak on block*/ 1294 /* this will cause transfer_check to croak on block*/
1266 SvRV_set (coro_current, (SV *)coro->hv); 1295 SvRV_set (coro_current, (SV *)coro->hv);
1267 1296
1268 load_perl (aTHX_ coro); 1297 load_perl (aTHX_ coro);
1269 1298
1299 /* restore swapped sv's */
1300 SWAP_SVS_LEAVE (coro);
1301
1270 coro_unwind_stacks (aTHX); 1302 coro_unwind_stacks (aTHX);
1271
1272 /* restore swapped sv's */
1273 SWAP_SVS (coro);
1274 1303
1275 coro_destruct_stacks (aTHX); 1304 coro_destruct_stacks (aTHX);
1276 1305
1277 /* now save some sv's to be free'd later */ 1306 /* now save some sv's to be free'd later */
1278 svf [0] = GvSV (PL_defgv); 1307 svf [0] = GvSV (PL_defgv);
1393 SAVETMPS; 1422 SAVETMPS;
1394 EXTEND (SP, 3); 1423 EXTEND (SP, 3);
1395 PUSHMARK (SP); 1424 PUSHMARK (SP);
1396 PUSHs (&PL_sv_yes); 1425 PUSHs (&PL_sv_yes);
1397 PUSHs (fullname); 1426 PUSHs (fullname);
1398 PUSHs (CxHASARGS (cx) ? sv_2mortal (newRV_inc ((SV *)cx->blk_sub.argarray)) : &PL_sv_undef); 1427 PUSHs (CxHASARGS (cx) ? sv_2mortal (newRV_inc (SUB_ARGARRAY)) : &PL_sv_undef);
1399 PUTBACK; 1428 PUTBACK;
1400 cb = hv_fetch ((HV *)SvRV (coro_current), "_trace_sub_cb", sizeof ("_trace_sub_cb") - 1, 0); 1429 cb = hv_fetch ((HV *)SvRV (coro_current), "_trace_sub_cb", sizeof ("_trace_sub_cb") - 1, 0);
1401 if (cb) call_sv (*cb, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD); 1430 if (cb) call_sv (*cb, G_KEEPERR | G_EVAL | G_VOID | G_DISCARD);
1402 SPAGAIN; 1431 SPAGAIN;
1403 FREETMPS; 1432 FREETMPS;
1525 * coro body here, as perl_run destroys these. Likewise, we cannot catch 1554 * coro body here, as perl_run destroys these. Likewise, we cannot catch
1526 * runtime errors here, as this is just a random interpreter, not a thread. 1555 * runtime errors here, as this is just a random interpreter, not a thread.
1527 */ 1556 */
1528 1557
1529 /* 1558 /*
1559 * pp_entersub in 5.24 no longer ENTERs, but perl_destruct
1560 * requires PL_scopestack_ix, so do it here if required.
1561 */
1562 if (!PL_scopestack_ix)
1563 ENTER;
1564
1565 /*
1530 * If perl-run returns we assume exit() was being called or the coro 1566 * If perl-run returns we assume exit() was being called or the coro
1531 * fell off the end, which seems to be the only valid (non-bug) 1567 * fell off the end, which seems to be the only valid (non-bug)
1532 * reason for perl_run to return. We try to mimic whatever perl is normally 1568 * reason for perl_run to return. We try to mimic whatever perl is normally
1533 * doing in that case. YMMV. 1569 * doing in that case. YMMV.
1534 */ 1570 */
2413 else 2449 else
2414 { 2450 {
2415 av_clear (GvAV (PL_defgv)); 2451 av_clear (GvAV (PL_defgv));
2416 hv_store (hv, "desc", sizeof ("desc") - 1, SvREFCNT_inc_NN (sv_async_pool_idle), 0); 2452 hv_store (hv, "desc", sizeof ("desc") - 1, SvREFCNT_inc_NN (sv_async_pool_idle), 0);
2417 2453
2454 if (ecb_expect_false (coro->swap_sv))
2455 {
2456 SWAP_SVS_LEAVE (coro);
2457 SvREFCNT_dec_NN (coro->swap_sv);
2458 coro->swap_sv = 0;
2459 }
2460
2418 coro->prio = 0; 2461 coro->prio = 0;
2419 2462
2420 if (coro->cctx && (coro->cctx->flags & CC_TRACE)) 2463 if (ecb_expect_false (coro->cctx) && ecb_expect_false (coro->cctx->flags & CC_TRACE))
2421 api_trace (aTHX_ coro_current, 0); 2464 api_trace (aTHX_ coro_current, 0);
2422 2465
2423 frame->prepare = prepare_schedule; 2466 frame->prepare = prepare_schedule;
2424 av_push (av_async_pool, SvREFCNT_inc (hv)); 2467 av_push (av_async_pool, SvREFCNT_inc (hv));
2425 } 2468 }
3554 3597
3555 map_len = load_len + save_len + 16; 3598 map_len = load_len + save_len + 16;
3556 3599
3557 map_base = mmap (0, map_len, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 3600 map_base = mmap (0, map_len, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
3558 3601
3602 if (map_base == (char *)MAP_FAILED)
3603 map_base = mmap (0, map_len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
3604
3559 assert (("Coro: unable to mmap jit code page, cannot continue.", map_base != (char *)MAP_FAILED)); 3605 assert (("Coro: unable to mmap jit code page, cannot continue.", map_base != (char *)MAP_FAILED));
3560 3606
3561 load_perl_slots = (load_save_perl_slots_type)map_base; 3607 load_perl_slots = (load_save_perl_slots_type)map_base;
3562 memcpy (map_base, load_ptr, load_len); 3608 memcpy (map_base, load_ptr, load_len);
3563 3609
3599 cctx_current = cctx_new_empty (); 3645 cctx_current = cctx_new_empty ();
3600 3646
3601 irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV); 3647 irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV);
3602 stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); 3648 stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO);
3603 3649
3604 orig_sigelem_get = PL_vtbl_sigelem.svt_get; PL_vtbl_sigelem.svt_get = coro_sigelem_get; 3650 {
3605 orig_sigelem_set = PL_vtbl_sigelem.svt_set; PL_vtbl_sigelem.svt_set = coro_sigelem_set; 3651 /*
3606 orig_sigelem_clr = PL_vtbl_sigelem.svt_clear; PL_vtbl_sigelem.svt_clear = coro_sigelem_clr; 3652 * we provide a vtbvl for %SIG magic that replaces PL_vtbl_sig
3653 * by coro_sig_vtbl in hash values.
3654 */
3655 MAGIC *mg = mg_find ((SV *)GvHV (gv_fetchpv ("SIG", GV_ADD | GV_NOTQUAL, SVt_PVHV)), PERL_MAGIC_sig);
3656
3657 /* this only works if perl doesn't have a vtbl for %SIG */
3658 assert (!mg->mg_virtual);
3659
3660 /*
3661 * The irony is that the perl API itself asserts that mg_virtual
3662 * must be non-const, yet perl5porters insisted on marking their
3663 * vtbls as read-only, just to thwart perl modules from patching
3664 * them.
3665 */
3666 mg->mg_virtual = (MGVTBL *)&coro_sig_vtbl;
3667 mg->mg_flags |= MGf_COPY;
3668
3669 coro_sigelem_vtbl = PL_vtbl_sigelem;
3670 coro_sigelem_vtbl.svt_get = coro_sigelem_get;
3671 coro_sigelem_vtbl.svt_set = coro_sigelem_set;
3672 coro_sigelem_vtbl.svt_clear = coro_sigelem_clr;
3673 }
3607 3674
3608 rv_diehook = newRV_inc ((SV *)gv_fetchpv ("Coro::State::diehook" , 0, SVt_PVCV)); 3675 rv_diehook = newRV_inc ((SV *)gv_fetchpv ("Coro::State::diehook" , 0, SVt_PVCV));
3609 rv_warnhook = newRV_inc ((SV *)gv_fetchpv ("Coro::State::warnhook", 0, SVt_PVCV)); 3676 rv_warnhook = newRV_inc ((SV *)gv_fetchpv ("Coro::State::warnhook", 0, SVt_PVCV));
3610 3677
3611 coro_state_stash = gv_stashpv ("Coro::State", TRUE); 3678 coro_state_stash = gv_stashpv ("Coro::State", TRUE);
3918 if (ecb_expect_false (current == self)) 3985 if (ecb_expect_false (current == self))
3919 coro_times_sub (SvSTATE (coro_current)); 3986 coro_times_sub (SvSTATE (coro_current));
3920} 3987}
3921 3988
3922void 3989void
3923swap_sv (Coro::State coro, SV *sv, SV *swapsv) 3990swap_sv (Coro::State coro, SV *sva, SV *svb)
3924 CODE: 3991 CODE:
3925{ 3992{
3926 struct coro *current = SvSTATE_current; 3993 struct coro *current = SvSTATE_current;
3994 AV *swap_sv;
3995 int i;
3996
3997 sva = SvRV (sva);
3998 svb = SvRV (svb);
3927 3999
3928 if (current == coro) 4000 if (current == coro)
3929 SWAP_SVS (current); 4001 SWAP_SVS_LEAVE (current);
3930 4002
3931 if (!coro->swap_sv) 4003 if (!coro->swap_sv)
3932 coro->swap_sv = newAV (); 4004 coro->swap_sv = newAV ();
3933 4005
4006 swap_sv = coro->swap_sv;
4007
4008 for (i = AvFILLp (swap_sv) - 1; i >= 0; i -= 2)
4009 {
4010 SV *a = AvARRAY (swap_sv)[i ];
4011 SV *b = AvARRAY (swap_sv)[i + 1];
4012
4013 if (a == sva && b == svb)
4014 {
4015 SvREFCNT_dec_NN (a);
4016 SvREFCNT_dec_NN (b);
4017
4018 for (; i <= AvFILLp (swap_sv) - 2; i++)
4019 AvARRAY (swap_sv)[i] = AvARRAY (swap_sv)[i + 2];
4020
4021 AvFILLp (swap_sv) -= 2;
4022
4023 goto removed;
4024 }
4025 }
4026
3934 av_push (coro->swap_sv, SvREFCNT_inc_NN (SvRV (sv ))); 4027 av_push (swap_sv, SvREFCNT_inc_NN (sva));
3935 av_push (coro->swap_sv, SvREFCNT_inc_NN (SvRV (swapsv))); 4028 av_push (swap_sv, SvREFCNT_inc_NN (svb));
4029
4030 removed:
3936 4031
3937 if (current == coro) 4032 if (current == coro)
3938 SWAP_SVS (current); 4033 SWAP_SVS_ENTER (current);
3939} 4034}
3940 4035
3941 4036
3942MODULE = Coro::State PACKAGE = Coro 4037MODULE = Coro::State PACKAGE = Coro
3943 4038
3984 coroapi.enterleave_hook = api_enterleave_hook; 4079 coroapi.enterleave_hook = api_enterleave_hook;
3985 coroapi.enterleave_unhook = api_enterleave_unhook; 4080 coroapi.enterleave_unhook = api_enterleave_unhook;
3986 coroapi.enterleave_scope_hook = api_enterleave_scope_hook; 4081 coroapi.enterleave_scope_hook = api_enterleave_scope_hook;
3987 4082
3988 /*GCoroAPI = &coroapi;*/ 4083 /*GCoroAPI = &coroapi;*/
3989 sv_setiv (sv, (IV)&coroapi); 4084 sv_setiv (sv, PTR2IV (&coroapi));
3990 SvREADONLY_on (sv); 4085 SvREADONLY_on (sv);
3991 } 4086 }
3992} 4087}
3993 4088
3994SV * 4089SV *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines