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.319 by root, Thu Nov 20 07:25:01 2008 UTC vs.
Revision 1.337 by root, Fri Dec 5 18:26:10 2008 UTC

101# define CvISXSUB_on(cv) (void)cv 101# define CvISXSUB_on(cv) (void)cv
102#endif 102#endif
103#ifndef CvISXSUB 103#ifndef CvISXSUB
104# define CvISXSUB(cv) (CvXSUB (cv) ? TRUE : FALSE) 104# define CvISXSUB(cv) (CvXSUB (cv) ? TRUE : FALSE)
105#endif 105#endif
106#ifndef Newx
107# define Newx(ptr,nitems,type) New (0,ptr,nitems,type)
108#endif
106 109
107/* 5.8.7 */ 110/* 5.8.7 */
108#ifndef SvRV_set 111#ifndef SvRV_set
109# define SvRV_set(s,v) SvRV(s) = (v) 112# define SvRV_set(s,v) SvRV(s) = (v)
110#endif 113#endif
130#else 133#else
131# define dSTACKLEVEL volatile void *stacklevel 134# define dSTACKLEVEL volatile void *stacklevel
132# define STACKLEVEL ((void *)&stacklevel) 135# define STACKLEVEL ((void *)&stacklevel)
133#endif 136#endif
134 137
135#define IN_DESTRUCT (PL_main_cv == Nullcv) 138#define IN_DESTRUCT PL_dirty
136 139
137#if __GNUC__ >= 3 140#if __GNUC__ >= 3
138# define attribute(x) __attribute__(x) 141# define attribute(x) __attribute__(x)
139# define expect(expr,value) __builtin_expect ((expr),(value)) 142# define expect(expr,value) __builtin_expect ((expr),(value))
140# define INLINE static inline 143# define INLINE static inline
172static HV *coro_state_stash, *coro_stash; 175static HV *coro_state_stash, *coro_stash;
173static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ 176static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */
174 177
175static AV *av_destroy; /* destruction queue */ 178static AV *av_destroy; /* destruction queue */
176static SV *sv_manager; /* the manager coro */ 179static SV *sv_manager; /* the manager coro */
180static SV *sv_idle; /* $Coro::idle */
177 181
178static GV *irsgv; /* $/ */ 182static GV *irsgv; /* $/ */
179static GV *stdoutgv; /* *STDOUT */ 183static GV *stdoutgv; /* *STDOUT */
180static SV *rv_diehook; 184static SV *rv_diehook;
181static SV *rv_warnhook; 185static SV *rv_warnhook;
225 int valgrind_id; 229 int valgrind_id;
226#endif 230#endif
227 unsigned char flags; 231 unsigned char flags;
228} coro_cctx; 232} coro_cctx;
229 233
234coro_cctx *cctx_current; /* the currently running cctx */
235
236/*****************************************************************************/
237
230enum { 238enum {
231 CF_RUNNING = 0x0001, /* coroutine is running */ 239 CF_RUNNING = 0x0001, /* coroutine is running */
232 CF_READY = 0x0002, /* coroutine is ready */ 240 CF_READY = 0x0002, /* coroutine is ready */
233 CF_NEW = 0x0004, /* has never been switched to */ 241 CF_NEW = 0x0004, /* has never been switched to */
234 CF_DESTROYED = 0x0008, /* coroutine data has been freed */ 242 CF_DESTROYED = 0x0008, /* coroutine data has been freed */
239{ 247{
240 SV *defsv; 248 SV *defsv;
241 AV *defav; 249 AV *defav;
242 SV *errsv; 250 SV *errsv;
243 SV *irsgv; 251 SV *irsgv;
252 HV *hinthv;
244#define VAR(name,type) type name; 253#define VAR(name,type) type name;
245# include "state.h" 254# include "state.h"
246#undef VAR 255#undef VAR
247} perl_slots; 256} perl_slots;
248 257
346 HV *st; 355 HV *st;
347 GV *gvp; 356 GV *gvp;
348 return sv_2cv (sv, &st, &gvp, 0); 357 return sv_2cv (sv, &st, &gvp, 0);
349} 358}
350 359
360/*****************************************************************************/
361/* magic glue */
362
363#define CORO_MAGIC_type_cv 26
364#define CORO_MAGIC_type_state PERL_MAGIC_ext
365
366#define CORO_MAGIC_NN(sv, type) \
367 (expect_true (SvMAGIC (sv)->mg_type == type) \
368 ? SvMAGIC (sv) \
369 : mg_find (sv, type))
370
371#define CORO_MAGIC(sv, type) \
372 (expect_true (SvMAGIC (sv)) \
373 ? CORO_MAGIC_NN (sv, type) \
374 : 0)
375
376#define CORO_MAGIC_cv(cv) CORO_MAGIC (((SV *)(cv)), CORO_MAGIC_type_cv)
377#define CORO_MAGIC_state(sv) CORO_MAGIC_NN (((SV *)(sv)), CORO_MAGIC_type_state)
378
379INLINE struct coro *
380SvSTATE_ (pTHX_ SV *coro)
381{
382 HV *stash;
383 MAGIC *mg;
384
385 if (SvROK (coro))
386 coro = SvRV (coro);
387
388 if (expect_false (SvTYPE (coro) != SVt_PVHV))
389 croak ("Coro::State object required");
390
391 stash = SvSTASH (coro);
392 if (expect_false (stash != coro_stash && stash != coro_state_stash))
393 {
394 /* very slow, but rare, check */
395 if (!sv_derived_from (sv_2mortal (newRV_inc (coro)), "Coro::State"))
396 croak ("Coro::State object required");
397 }
398
399 mg = CORO_MAGIC_state (coro);
400 return (struct coro *)mg->mg_ptr;
401}
402
403#define SvSTATE(sv) SvSTATE_ (aTHX_ (sv))
404
405/* faster than SvSTATE, but expects a coroutine hv */
406#define SvSTATE_hv(hv) ((struct coro *)CORO_MAGIC_NN ((SV *)hv, CORO_MAGIC_type_state)->mg_ptr)
407#define SvSTATE_current SvSTATE_hv (SvRV (coro_current))
408
409/*****************************************************************************/
410/* padlist management and caching */
411
351static AV * 412static AV *
352coro_clone_padlist (pTHX_ CV *cv) 413coro_derive_padlist (pTHX_ CV *cv)
353{ 414{
354 AV *padlist = CvPADLIST (cv); 415 AV *padlist = CvPADLIST (cv);
355 AV *newpadlist, *newpad; 416 AV *newpadlist, *newpad;
356 417
357 newpadlist = newAV (); 418 newpadlist = newAV ();
362 Perl_pad_push (aTHX_ padlist, AvFILLp (padlist) + 1, 1); 423 Perl_pad_push (aTHX_ padlist, AvFILLp (padlist) + 1, 1);
363#endif 424#endif
364 newpad = (AV *)AvARRAY (padlist)[AvFILLp (padlist)]; 425 newpad = (AV *)AvARRAY (padlist)[AvFILLp (padlist)];
365 --AvFILLp (padlist); 426 --AvFILLp (padlist);
366 427
367 av_store (newpadlist, 0, SvREFCNT_inc_NN (*av_fetch (padlist, 0, FALSE))); 428 av_store (newpadlist, 0, SvREFCNT_inc_NN (AvARRAY (padlist)[0]));
368 av_store (newpadlist, 1, (SV *)newpad); 429 av_store (newpadlist, 1, (SV *)newpad);
369 430
370 return newpadlist; 431 return newpadlist;
371} 432}
372 433
373static void 434static void
374free_padlist (pTHX_ AV *padlist) 435free_padlist (pTHX_ AV *padlist)
375{ 436{
376 /* may be during global destruction */ 437 /* may be during global destruction */
377 if (SvREFCNT (padlist)) 438 if (!IN_DESTRUCT)
378 { 439 {
379 I32 i = AvFILLp (padlist); 440 I32 i = AvFILLp (padlist);
380 while (i >= 0) 441
442 while (i > 0) /* special-case index 0 */
381 { 443 {
382 SV **svp = av_fetch (padlist, i--, FALSE); 444 /* we try to be extra-careful here */
383 if (svp) 445 AV *av = (AV *)AvARRAY (padlist)[i--];
384 { 446 I32 j = AvFILLp (av);
385 SV *sv; 447
386 while (&PL_sv_undef != (sv = av_pop ((AV *)*svp))) 448 while (j >= 0)
449 SvREFCNT_dec (AvARRAY (av)[j--]);
450
451 AvFILLp (av) = -1;
387 SvREFCNT_dec (sv); 452 SvREFCNT_dec (av);
388
389 SvREFCNT_dec (*svp);
390 }
391 } 453 }
392 454
455 SvREFCNT_dec (AvARRAY (padlist)[0]);
456
457 AvFILLp (padlist) = -1;
393 SvREFCNT_dec ((SV*)padlist); 458 SvREFCNT_dec ((SV*)padlist);
394 } 459 }
395} 460}
396 461
397static int 462static int
406 471
407 SvREFCNT_dec (av); /* sv_magicext increased the refcount */ 472 SvREFCNT_dec (av); /* sv_magicext increased the refcount */
408 473
409 return 0; 474 return 0;
410} 475}
411
412#define CORO_MAGIC_type_cv 26
413#define CORO_MAGIC_type_state PERL_MAGIC_ext
414 476
415static MGVTBL coro_cv_vtbl = { 477static MGVTBL coro_cv_vtbl = {
416 0, 0, 0, 0, 478 0, 0, 0, 0,
417 coro_cv_free 479 coro_cv_free
418}; 480};
419
420#define CORO_MAGIC_NN(sv, type) \
421 (expect_true (SvMAGIC (sv)->mg_type == type) \
422 ? SvMAGIC (sv) \
423 : mg_find (sv, type))
424
425#define CORO_MAGIC(sv, type) \
426 (expect_true (SvMAGIC (sv)) \
427 ? CORO_MAGIC_NN (sv, type) \
428 : 0)
429
430#define CORO_MAGIC_cv(cv) CORO_MAGIC (((SV *)(cv)), CORO_MAGIC_type_cv)
431#define CORO_MAGIC_state(sv) CORO_MAGIC_NN (((SV *)(sv)), CORO_MAGIC_type_state)
432
433INLINE struct coro *
434SvSTATE_ (pTHX_ SV *coro)
435{
436 HV *stash;
437 MAGIC *mg;
438
439 if (SvROK (coro))
440 coro = SvRV (coro);
441
442 if (expect_false (SvTYPE (coro) != SVt_PVHV))
443 croak ("Coro::State object required");
444
445 stash = SvSTASH (coro);
446 if (expect_false (stash != coro_stash && stash != coro_state_stash))
447 {
448 /* very slow, but rare, check */
449 if (!sv_derived_from (sv_2mortal (newRV_inc (coro)), "Coro::State"))
450 croak ("Coro::State object required");
451 }
452
453 mg = CORO_MAGIC_state (coro);
454 return (struct coro *)mg->mg_ptr;
455}
456
457#define SvSTATE(sv) SvSTATE_ (aTHX_ (sv))
458
459/* faster than SvSTATE, but expects a coroutine hv */
460#define SvSTATE_hv(hv) ((struct coro *)CORO_MAGIC_NN ((SV *)hv, CORO_MAGIC_type_state)->mg_ptr)
461#define SvSTATE_current SvSTATE_hv (SvRV (coro_current))
462 481
463/* the next two functions merely cache the padlists */ 482/* the next two functions merely cache the padlists */
464static void 483static void
465get_padlist (pTHX_ CV *cv) 484get_padlist (pTHX_ CV *cv)
466{ 485{
477 CV *cp = Perl_cv_clone (aTHX_ cv); 496 CV *cp = Perl_cv_clone (aTHX_ cv);
478 CvPADLIST (cv) = CvPADLIST (cp); 497 CvPADLIST (cv) = CvPADLIST (cp);
479 CvPADLIST (cp) = 0; 498 CvPADLIST (cp) = 0;
480 SvREFCNT_dec (cp); 499 SvREFCNT_dec (cp);
481#else 500#else
482 CvPADLIST (cv) = coro_clone_padlist (aTHX_ cv); 501 CvPADLIST (cv) = coro_derive_padlist (aTHX_ cv);
483#endif 502#endif
484 } 503 }
485} 504}
486 505
487static void 506static void
494 mg = sv_magicext ((SV *)cv, (SV *)newAV (), CORO_MAGIC_type_cv, &coro_cv_vtbl, 0, 0); 513 mg = sv_magicext ((SV *)cv, (SV *)newAV (), CORO_MAGIC_type_cv, &coro_cv_vtbl, 0, 0);
495 514
496 av = (AV *)mg->mg_obj; 515 av = (AV *)mg->mg_obj;
497 516
498 if (expect_false (AvFILLp (av) >= AvMAX (av))) 517 if (expect_false (AvFILLp (av) >= AvMAX (av)))
499 av_extend (av, AvMAX (av) + 1); 518 av_extend (av, AvFILLp (av) + 1);
500 519
501 AvARRAY (av)[++AvFILLp (av)] = (SV *)CvPADLIST (cv); 520 AvARRAY (av)[++AvFILLp (av)] = (SV *)CvPADLIST (cv);
502} 521}
503 522
504/** load & save, init *******************************************************/ 523/** load & save, init *******************************************************/
509 perl_slots *slot = c->slot; 528 perl_slots *slot = c->slot;
510 c->slot = 0; 529 c->slot = 0;
511 530
512 PL_mainstack = c->mainstack; 531 PL_mainstack = c->mainstack;
513 532
514 GvSV (PL_defgv) = slot->defsv; 533 GvSV (PL_defgv) = slot->defsv;
515 GvAV (PL_defgv) = slot->defav; 534 GvAV (PL_defgv) = slot->defav;
516 GvSV (PL_errgv) = slot->errsv; 535 GvSV (PL_errgv) = slot->errsv;
517 GvSV (irsgv) = slot->irsgv; 536 GvSV (irsgv) = slot->irsgv;
537 GvHV (PL_hintgv) = slot->hinthv;
518 538
519 #define VAR(name,type) PL_ ## name = slot->name; 539 #define VAR(name,type) PL_ ## name = slot->name;
520 # include "state.h" 540 # include "state.h"
521 #undef VAR 541 #undef VAR
522 542
608 c->mainstack = PL_mainstack; 628 c->mainstack = PL_mainstack;
609 629
610 { 630 {
611 perl_slots *slot = c->slot = (perl_slots *)(cxstack + cxstack_ix + 1); 631 perl_slots *slot = c->slot = (perl_slots *)(cxstack + cxstack_ix + 1);
612 632
613 slot->defav = GvAV (PL_defgv); 633 slot->defav = GvAV (PL_defgv);
614 slot->defsv = DEFSV; 634 slot->defsv = DEFSV;
615 slot->errsv = ERRSV; 635 slot->errsv = ERRSV;
616 slot->irsgv = GvSV (irsgv); 636 slot->irsgv = GvSV (irsgv);
637 slot->hinthv = GvHV (PL_hintgv);
617 638
618 #define VAR(name,type) slot->name = PL_ ## name; 639 #define VAR(name,type) slot->name = PL_ ## name;
619 # include "state.h" 640 # include "state.h"
620 #undef VAR 641 #undef VAR
621 } 642 }
857 878
858 PL_runops = RUNOPS_DEFAULT; 879 PL_runops = RUNOPS_DEFAULT;
859 PL_curcop = &PL_compiling; 880 PL_curcop = &PL_compiling;
860 PL_in_eval = EVAL_NULL; 881 PL_in_eval = EVAL_NULL;
861 PL_comppad = 0; 882 PL_comppad = 0;
883 PL_comppad_name = 0;
884 PL_comppad_name_fill = 0;
885 PL_comppad_name_floor = 0;
862 PL_curpm = 0; 886 PL_curpm = 0;
863 PL_curpad = 0; 887 PL_curpad = 0;
864 PL_localizing = 0; 888 PL_localizing = 0;
865 PL_dirty = 0; 889 PL_dirty = 0;
866 PL_restartop = 0; 890 PL_restartop = 0;
867#if PERL_VERSION_ATLEAST (5,10,0) 891#if PERL_VERSION_ATLEAST (5,10,0)
868 PL_parser = 0; 892 PL_parser = 0;
869#endif 893#endif
894 PL_hints = 0;
870 895
871 /* recreate the die/warn hooks */ 896 /* recreate the die/warn hooks */
872 PL_diehook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__DIE__" , sizeof ("__DIE__" ) - 1, 1), rv_diehook ); 897 PL_diehook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__DIE__" , sizeof ("__DIE__" ) - 1, 1), rv_diehook );
873 PL_warnhook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__WARN__", sizeof ("__WARN__") - 1, 1), rv_warnhook); 898 PL_warnhook = 0; SvSetMagicSV (*hv_fetch (hv_sig, "__WARN__", sizeof ("__WARN__") - 1, 1), rv_warnhook);
874 899
875 GvSV (PL_defgv) = newSV (0); 900 GvSV (PL_defgv) = newSV (0);
876 GvAV (PL_defgv) = coro->args; coro->args = 0; 901 GvAV (PL_defgv) = coro->args; coro->args = 0;
877 GvSV (PL_errgv) = newSV (0); 902 GvSV (PL_errgv) = newSV (0);
878 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0); 903 GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0);
904 GvHV (PL_hintgv) = 0;
879 PL_rs = newSVsv (GvSV (irsgv)); 905 PL_rs = newSVsv (GvSV (irsgv));
880 PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv); 906 PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv);
881 907
882 { 908 {
883 dSP; 909 dSP;
901 slf_frame.prepare = prepare_nop; /* provide a nop function for an eventual pp_slf */ 927 slf_frame.prepare = prepare_nop; /* provide a nop function for an eventual pp_slf */
902 slf_frame.check = slf_check_nop; /* signal pp_slf to not repeat */ 928 slf_frame.check = slf_check_nop; /* signal pp_slf to not repeat */
903 929
904 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */ 930 /* and we have to provide the pp_slf op in any case, so pp_slf can skip it */
905 coro_setup_op.op_next = PL_op; 931 coro_setup_op.op_next = PL_op;
906 coro_setup_op.op_type = OP_CUSTOM; 932 coro_setup_op.op_type = OP_ENTERSUB;
907 coro_setup_op.op_ppaddr = pp_slf; 933 coro_setup_op.op_ppaddr = pp_slf;
908 /* no flags etc. required, as an init function won't be called */ 934 /* no flags etc. required, as an init function won't be called */
909 935
910 PL_op = (OP *)&coro_setup_op; 936 PL_op = (OP *)&coro_setup_op;
911 937
912 /* copy throw, in case it was set before coro_setup */ 938 /* copy throw, in case it was set before coro_setup */
913 CORO_THROW = coro->except; 939 CORO_THROW = coro->except;
914} 940}
915 941
916static void 942static void
917coro_destruct (pTHX_ struct coro *coro) 943coro_unwind_stacks (pTHX)
918{ 944{
919 if (!IN_DESTRUCT) 945 if (!IN_DESTRUCT)
920 { 946 {
921 /* restore all saved variables and stuff */ 947 /* restore all saved variables and stuff */
922 LEAVE_SCOPE (0); 948 LEAVE_SCOPE (0);
930 POPSTACK_TO (PL_mainstack); 956 POPSTACK_TO (PL_mainstack);
931 957
932 /* unwind main stack */ 958 /* unwind main stack */
933 dounwind (-1); 959 dounwind (-1);
934 } 960 }
961}
962
963static void
964coro_destruct_perl (pTHX_ struct coro *coro)
965{
966 coro_unwind_stacks (aTHX);
935 967
936 SvREFCNT_dec (GvSV (PL_defgv)); 968 SvREFCNT_dec (GvSV (PL_defgv));
937 SvREFCNT_dec (GvAV (PL_defgv)); 969 SvREFCNT_dec (GvAV (PL_defgv));
938 SvREFCNT_dec (GvSV (PL_errgv)); 970 SvREFCNT_dec (GvSV (PL_errgv));
939 SvREFCNT_dec (PL_defoutgv); 971 SvREFCNT_dec (PL_defoutgv);
940 SvREFCNT_dec (PL_rs); 972 SvREFCNT_dec (PL_rs);
941 SvREFCNT_dec (GvSV (irsgv)); 973 SvREFCNT_dec (GvSV (irsgv));
974 SvREFCNT_dec (GvHV (PL_hintgv));
942 975
943 SvREFCNT_dec (PL_diehook); 976 SvREFCNT_dec (PL_diehook);
944 SvREFCNT_dec (PL_warnhook); 977 SvREFCNT_dec (PL_warnhook);
945 978
946 SvREFCNT_dec (coro->saved_deffh); 979 SvREFCNT_dec (coro->saved_deffh);
964static int 997static int
965runops_trace (pTHX) 998runops_trace (pTHX)
966{ 999{
967 COP *oldcop = 0; 1000 COP *oldcop = 0;
968 int oldcxix = -2; 1001 int oldcxix = -2;
969 struct coro *coro = SvSTATE_current; /* trace cctx is tied to specific coro */
970 coro_cctx *cctx = coro->cctx;
971 1002
972 while ((PL_op = CALL_FPTR (PL_op->op_ppaddr) (aTHX))) 1003 while ((PL_op = CALL_FPTR (PL_op->op_ppaddr) (aTHX)))
973 { 1004 {
974 PERL_ASYNC_CHECK (); 1005 PERL_ASYNC_CHECK ();
975 1006
976 if (cctx->flags & CC_TRACE_ALL) 1007 if (cctx_current->flags & CC_TRACE_ALL)
977 { 1008 {
978 if (PL_op->op_type == OP_LEAVESUB && cctx->flags & CC_TRACE_SUB) 1009 if (PL_op->op_type == OP_LEAVESUB && cctx_current->flags & CC_TRACE_SUB)
979 { 1010 {
980 PERL_CONTEXT *cx = &cxstack[cxstack_ix]; 1011 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
981 SV **bot, **top; 1012 SV **bot, **top;
982 AV *av = newAV (); /* return values */ 1013 AV *av = newAV (); /* return values */
983 SV **cb; 1014 SV **cb;
1020 1051
1021 if (PL_curcop != &PL_compiling) 1052 if (PL_curcop != &PL_compiling)
1022 { 1053 {
1023 SV **cb; 1054 SV **cb;
1024 1055
1025 if (oldcxix != cxstack_ix && cctx->flags & CC_TRACE_SUB) 1056 if (oldcxix != cxstack_ix && cctx_current->flags & CC_TRACE_SUB)
1026 { 1057 {
1027 PERL_CONTEXT *cx = &cxstack[cxstack_ix]; 1058 PERL_CONTEXT *cx = &cxstack[cxstack_ix];
1028 1059
1029 if (CxTYPE (cx) == CXt_SUB && oldcxix < cxstack_ix) 1060 if (CxTYPE (cx) == CXt_SUB && oldcxix < cxstack_ix)
1030 { 1061 {
1053 } 1084 }
1054 1085
1055 oldcxix = cxstack_ix; 1086 oldcxix = cxstack_ix;
1056 } 1087 }
1057 1088
1058 if (cctx->flags & CC_TRACE_LINE) 1089 if (cctx_current->flags & CC_TRACE_LINE)
1059 { 1090 {
1060 dSP; 1091 dSP;
1061 1092
1062 PL_runops = RUNOPS_DEFAULT; 1093 PL_runops = RUNOPS_DEFAULT;
1063 ENTER; 1094 ENTER;
1082 1113
1083 TAINT_NOT; 1114 TAINT_NOT;
1084 return 0; 1115 return 0;
1085} 1116}
1086 1117
1087static struct coro_cctx *cctx_ssl_cctx;
1088static struct CoroSLF cctx_ssl_frame; 1118static struct CoroSLF cctx_ssl_frame;
1089 1119
1090static void 1120static void
1091slf_prepare_set_stacklevel (pTHX_ struct coro_transfer_args *ta) 1121slf_prepare_set_stacklevel (pTHX_ struct coro_transfer_args *ta)
1092{ 1122{
1093 ta->prev = (struct coro *)cctx_ssl_cctx;
1094 ta->next = 0; 1123 ta->prev = 0;
1095} 1124}
1096 1125
1097static int 1126static int
1098slf_check_set_stacklevel (pTHX_ struct CoroSLF *frame) 1127slf_check_set_stacklevel (pTHX_ struct CoroSLF *frame)
1099{ 1128{
1102 return frame->check (aTHX_ frame); /* execute the restored frame - there must be one */ 1131 return frame->check (aTHX_ frame); /* execute the restored frame - there must be one */
1103} 1132}
1104 1133
1105/* initialises PL_top_env and injects a pseudo-slf-call to set the stacklevel */ 1134/* initialises PL_top_env and injects a pseudo-slf-call to set the stacklevel */
1106static void NOINLINE 1135static void NOINLINE
1107cctx_prepare (pTHX_ coro_cctx *cctx) 1136cctx_prepare (pTHX)
1108{ 1137{
1109 PL_top_env = &PL_start_env; 1138 PL_top_env = &PL_start_env;
1110 1139
1111 if (cctx->flags & CC_TRACE) 1140 if (cctx_current->flags & CC_TRACE)
1112 PL_runops = runops_trace; 1141 PL_runops = runops_trace;
1113 1142
1114 /* we already must be executing an SLF op, there is no other valid way 1143 /* we already must be executing an SLF op, there is no other valid way
1115 * that can lead to creation of a new cctx */ 1144 * that can lead to creation of a new cctx */
1116 assert (("FATAL: can't prepare slf-less cctx in Coro module (please report)", 1145 assert (("FATAL: can't prepare slf-less cctx in Coro module (please report)",
1117 slf_frame.prepare && PL_op->op_ppaddr == pp_slf)); 1146 slf_frame.prepare && PL_op->op_ppaddr == pp_slf));
1118 1147
1119 /* we must emulate leaving pp_slf, which is done inside slf_check_set_stacklevel */ 1148 /* we must emulate leaving pp_slf, which is done inside slf_check_set_stacklevel */
1120 cctx_ssl_cctx = cctx;
1121 cctx_ssl_frame = slf_frame; 1149 cctx_ssl_frame = slf_frame;
1122 1150
1123 slf_frame.prepare = slf_prepare_set_stacklevel; 1151 slf_frame.prepare = slf_prepare_set_stacklevel;
1124 slf_frame.check = slf_check_set_stacklevel; 1152 slf_frame.check = slf_check_set_stacklevel;
1125} 1153}
1148 /* normally we would need to skip the entersub here */ 1176 /* normally we would need to skip the entersub here */
1149 /* not doing so will re-execute it, which is exactly what we want */ 1177 /* not doing so will re-execute it, which is exactly what we want */
1150 /* PL_nop = PL_nop->op_next */ 1178 /* PL_nop = PL_nop->op_next */
1151 1179
1152 /* inject a fake subroutine call to cctx_init */ 1180 /* inject a fake subroutine call to cctx_init */
1153 cctx_prepare (aTHX_ (coro_cctx *)arg); 1181 cctx_prepare (aTHX);
1154 1182
1155 /* cctx_run is the alternative tail of transfer() */ 1183 /* cctx_run is the alternative tail of transfer() */
1156 transfer_tail (aTHX); 1184 transfer_tail (aTHX);
1157 1185
1158 /* somebody or something will hit me for both perl_run and PL_restartop */ 1186 /* somebody or something will hit me for both perl_run and PL_restartop */
1166 /* 1194 /*
1167 * If perl-run returns we assume exit() was being called or the coro 1195 * If perl-run returns we assume exit() was being called or the coro
1168 * fell off the end, which seems to be the only valid (non-bug) 1196 * fell off the end, which seems to be the only valid (non-bug)
1169 * reason for perl_run to return. We try to exit by jumping to the 1197 * reason for perl_run to return. We try to exit by jumping to the
1170 * bootstrap-time "top" top_env, as we cannot restore the "main" 1198 * bootstrap-time "top" top_env, as we cannot restore the "main"
1171 * coroutine as Coro has no such concept 1199 * coroutine as Coro has no such concept.
1200 * This actually isn't valid with the pthread backend, but OSes requiring
1201 * that backend are too broken to do it in a standards-compliant way.
1172 */ 1202 */
1173 PL_top_env = main_top_env; 1203 PL_top_env = main_top_env;
1174 JMPENV_JUMP (2); /* I do not feel well about the hardcoded 2 at all */ 1204 JMPENV_JUMP (2); /* I do not feel well about the hardcoded 2 at all */
1175 } 1205 }
1176} 1206}
1253cctx_destroy (coro_cctx *cctx) 1283cctx_destroy (coro_cctx *cctx)
1254{ 1284{
1255 if (!cctx) 1285 if (!cctx)
1256 return; 1286 return;
1257 1287
1288 assert (("FATAL: tried to destroy current cctx", cctx != cctx_current));//D temporary?
1289
1258 --cctx_count; 1290 --cctx_count;
1259 coro_destroy (&cctx->cctx); 1291 coro_destroy (&cctx->cctx);
1260 1292
1261 /* coro_transfer creates new, empty cctx's */ 1293 /* coro_transfer creates new, empty cctx's */
1262 if (cctx->sptr) 1294 if (cctx->sptr)
1325 /* TODO: throwing up here is considered harmful */ 1357 /* TODO: throwing up here is considered harmful */
1326 1358
1327 if (expect_true (prev != next)) 1359 if (expect_true (prev != next))
1328 { 1360 {
1329 if (expect_false (!(prev->flags & (CF_RUNNING | CF_NEW)))) 1361 if (expect_false (!(prev->flags & (CF_RUNNING | CF_NEW))))
1330 croak ("Coro::State::transfer called with non-running/new prev Coro::State, but can only transfer from running or new states,"); 1362 croak ("Coro::State::transfer called with a suspended prev Coro::State, but can only transfer from running or new states,");
1331 1363
1332 if (expect_false (next->flags & CF_RUNNING)) 1364 if (expect_false (next->flags & CF_RUNNING))
1333 croak ("Coro::State::transfer called with running next Coro::State, but can only transfer to inactive states,"); 1365 croak ("Coro::State::transfer called with running next Coro::State, but can only transfer to inactive states,");
1334 1366
1335 if (expect_false (next->flags & CF_DESTROYED)) 1367 if (expect_false (next->flags & CF_DESTROYED))
1347transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx) 1379transfer (pTHX_ struct coro *prev, struct coro *next, int force_cctx)
1348{ 1380{
1349 dSTACKLEVEL; 1381 dSTACKLEVEL;
1350 1382
1351 /* sometimes transfer is only called to set idle_sp */ 1383 /* sometimes transfer is only called to set idle_sp */
1352 if (expect_false (!next)) 1384 if (expect_false (!prev))
1353 { 1385 {
1354 ((coro_cctx *)prev)->idle_sp = STACKLEVEL; 1386 cctx_current->idle_sp = STACKLEVEL;
1355 assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ 1387 assert (cctx_current->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */
1356 } 1388 }
1357 else if (expect_true (prev != next)) 1389 else if (expect_true (prev != next))
1358 { 1390 {
1359 coro_cctx *prev__cctx; 1391 coro_cctx *cctx_prev;
1360 1392
1361 if (expect_false (prev->flags & CF_NEW)) 1393 if (expect_false (prev->flags & CF_NEW))
1362 { 1394 {
1363 /* create a new empty/source context */ 1395 /* create a new empty/source context */
1364 prev->cctx = cctx_new_empty ();
1365 prev->flags &= ~CF_NEW; 1396 prev->flags &= ~CF_NEW;
1366 prev->flags |= CF_RUNNING; 1397 prev->flags |= CF_RUNNING;
1367 } 1398 }
1368 1399
1369 prev->flags &= ~CF_RUNNING; 1400 prev->flags &= ~CF_RUNNING;
1380 coro_setup (aTHX_ next); 1411 coro_setup (aTHX_ next);
1381 } 1412 }
1382 else 1413 else
1383 load_perl (aTHX_ next); 1414 load_perl (aTHX_ next);
1384 1415
1385 prev__cctx = prev->cctx;
1386
1387 /* possibly untie and reuse the cctx */ 1416 /* possibly untie and reuse the cctx */
1388 if (expect_true ( 1417 if (expect_true (
1389 prev__cctx->idle_sp == STACKLEVEL 1418 cctx_current->idle_sp == STACKLEVEL
1390 && !(prev__cctx->flags & CC_TRACE) 1419 && !(cctx_current->flags & CC_TRACE)
1391 && !force_cctx 1420 && !force_cctx
1392 )) 1421 ))
1393 { 1422 {
1394 /* I assume that stacklevel is a stronger indicator than PL_top_env changes */ 1423 /* I assume that stacklevel is a stronger indicator than PL_top_env changes */
1395 assert (("FATAL: current top_env must equal previous top_env in Coro (please report)", PL_top_env == prev__cctx->idle_te)); 1424 assert (("FATAL: current top_env must equal previous top_env in Coro (please report)", PL_top_env == cctx_current->idle_te));
1396 1425
1397 prev->cctx = 0;
1398
1399 /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get */ 1426 /* if the cctx is about to be destroyed we need to make sure we won't see it in cctx_get. */
1400 /* without this the next cctx_get might destroy the prev__cctx while still in use */ 1427 /* without this the next cctx_get might destroy the running cctx while still in use */
1401 if (expect_false (CCTX_EXPIRED (prev__cctx))) 1428 if (expect_false (CCTX_EXPIRED (cctx_current)))
1402 if (!next->cctx) 1429 if (expect_true (!next->cctx))
1403 next->cctx = cctx_get (aTHX); 1430 next->cctx = cctx_get (aTHX);
1404 1431
1405 cctx_put (prev__cctx); 1432 cctx_put (cctx_current);
1406 } 1433 }
1434 else
1435 prev->cctx = cctx_current;
1407 1436
1408 ++next->usecount; 1437 ++next->usecount;
1409 1438
1410 if (expect_true (!next->cctx)) 1439 cctx_prev = cctx_current;
1411 next->cctx = cctx_get (aTHX); 1440 cctx_current = expect_false (next->cctx) ? next->cctx : cctx_get (aTHX);
1412 1441
1413 if (expect_false (prev__cctx != next->cctx)) 1442 next->cctx = 0;
1443
1444 if (expect_false (cctx_prev != cctx_current))
1414 { 1445 {
1415 prev__cctx->top_env = PL_top_env; 1446 cctx_prev->top_env = PL_top_env;
1416 PL_top_env = next->cctx->top_env; 1447 PL_top_env = cctx_current->top_env;
1417 coro_transfer (&prev__cctx->cctx, &next->cctx->cctx); 1448 coro_transfer (&cctx_prev->cctx, &cctx_current->cctx);
1418 } 1449 }
1419 1450
1420 transfer_tail (aTHX); 1451 transfer_tail (aTHX);
1421 } 1452 }
1422} 1453}
1444 --coro_nready; 1475 --coro_nready;
1445 } 1476 }
1446 else 1477 else
1447 coro->flags |= CF_READY; /* make sure it is NOT put into the readyqueue */ 1478 coro->flags |= CF_READY; /* make sure it is NOT put into the readyqueue */
1448 1479
1449 if (coro->mainstack && coro->mainstack != main_mainstack) 1480 if (coro->mainstack
1481 && coro->mainstack != main_mainstack
1482 && coro->slot
1483 && !PL_dirty)
1450 { 1484 {
1451 struct coro temp; 1485 struct coro temp;
1452 1486
1453 assert (("FATAL: tried to destroy currently running coroutine (please report)", !(coro->flags & CF_RUNNING))); 1487 assert (("FATAL: tried to destroy currently running coroutine", coro->mainstack != PL_mainstack));
1454 1488
1455 save_perl (aTHX_ &temp); 1489 save_perl (aTHX_ &temp);
1456 load_perl (aTHX_ coro); 1490 load_perl (aTHX_ coro);
1457 1491
1458 coro_destruct (aTHX_ coro); 1492 coro_destruct_perl (aTHX_ coro);
1459 1493
1460 load_perl (aTHX_ &temp); 1494 load_perl (aTHX_ &temp);
1461 1495
1462 coro->slot = 0; 1496 coro->slot = 0;
1463 } 1497 }
1577{ 1611{
1578 struct coro *coro; 1612 struct coro *coro;
1579 SV *sv_hook; 1613 SV *sv_hook;
1580 void (*xs_hook)(void); 1614 void (*xs_hook)(void);
1581 1615
1582 if (SvROK (coro_sv))
1583 coro_sv = SvRV (coro_sv);
1584
1585 coro = SvSTATE (coro_sv); 1616 coro = SvSTATE (coro_sv);
1586 1617
1587 if (coro->flags & CF_READY) 1618 if (coro->flags & CF_READY)
1588 return 0; 1619 return 0;
1589 1620
1663 } 1694 }
1664 } 1695 }
1665 else 1696 else
1666 { 1697 {
1667 /* nothing to schedule: call the idle handler */ 1698 /* nothing to schedule: call the idle handler */
1699 if (SvROK (sv_idle)
1700 && SvOBJECT (SvRV (sv_idle)))
1701 {
1702 ++coro_nready; /* hack so that api_ready doesn't invoke ready hook */
1703 api_ready (aTHX_ SvRV (sv_idle));
1704 --coro_nready;
1705 }
1706 else
1707 {
1668 dSP; 1708 dSP;
1669 1709
1670 ENTER; 1710 ENTER;
1671 SAVETMPS; 1711 SAVETMPS;
1672 1712
1673 PUSHMARK (SP); 1713 PUSHMARK (SP);
1674 PUTBACK; 1714 PUTBACK;
1675 call_sv (get_sv ("Coro::idle", FALSE), G_VOID | G_DISCARD); 1715 call_sv (sv_idle, G_VOID | G_DISCARD);
1676 1716
1677 FREETMPS; 1717 FREETMPS;
1678 LEAVE; 1718 LEAVE;
1719 }
1679 } 1720 }
1680 } 1721 }
1681} 1722}
1682 1723
1683INLINE void 1724INLINE void
1754static void 1795static void
1755api_trace (pTHX_ SV *coro_sv, int flags) 1796api_trace (pTHX_ SV *coro_sv, int flags)
1756{ 1797{
1757 struct coro *coro = SvSTATE (coro_sv); 1798 struct coro *coro = SvSTATE (coro_sv);
1758 1799
1800 if (coro->flags & CF_RUNNING)
1801 croak ("cannot enable tracing on a running coroutine, caught");
1802
1759 if (flags & CC_TRACE) 1803 if (flags & CC_TRACE)
1760 { 1804 {
1761 if (!coro->cctx) 1805 if (!coro->cctx)
1762 coro->cctx = cctx_new_run (); 1806 coro->cctx = cctx_new_run ();
1763 else if (!(coro->cctx->flags & CC_TRACE)) 1807 else if (!(coro->cctx->flags & CC_TRACE))
1764 croak ("cannot enable tracing on coroutine with custom stack,"); 1808 croak ("cannot enable tracing on coroutine with custom stack, caught");
1765 1809
1766 coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL)); 1810 coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL));
1767 } 1811 }
1768 else if (coro->cctx && coro->cctx->flags & CC_TRACE) 1812 else if (coro->cctx && coro->cctx->flags & CC_TRACE)
1769 { 1813 {
1825 av_push (av_destroy, (SV *)newRV_inc ((SV *)hv)); /* RVinc for perl */ 1869 av_push (av_destroy, (SV *)newRV_inc ((SV *)hv)); /* RVinc for perl */
1826 api_ready (aTHX_ sv_manager); 1870 api_ready (aTHX_ sv_manager);
1827 1871
1828 frame->prepare = prepare_schedule; 1872 frame->prepare = prepare_schedule;
1829 frame->check = slf_check_repeat; 1873 frame->check = slf_check_repeat;
1874
1875 /* as a minor optimisation, we could unwind all stacks here */
1876 /* but that puts extra pressure on pp_slf, and is not worth much */
1877 /*coro_unwind_stacks (aTHX);*/
1830} 1878}
1831 1879
1832/*****************************************************************************/ 1880/*****************************************************************************/
1833/* async pool handler */ 1881/* async pool handler */
1834 1882
2250 } 2298 }
2251 else 2299 else
2252 slf_argc = 0; 2300 slf_argc = 0;
2253 2301
2254 PL_op->op_ppaddr = pp_slf; 2302 PL_op->op_ppaddr = pp_slf;
2255 PL_op->op_type = OP_CUSTOM; /* maybe we should leave it at entersub? */ 2303 /*PL_op->op_type = OP_CUSTOM; /* we do behave like entersub still */
2256 2304
2257 PL_op = (OP *)&slf_restore; 2305 PL_op = (OP *)&slf_restore;
2258} 2306}
2259 2307
2260/*****************************************************************************/ 2308/*****************************************************************************/
2343 SV **ary; 2391 SV **ary;
2344 2392
2345 /* unfortunately, building manually saves memory */ 2393 /* unfortunately, building manually saves memory */
2346 Newx (ary, 2, SV *); 2394 Newx (ary, 2, SV *);
2347 AvALLOC (av) = ary; 2395 AvALLOC (av) = ary;
2396#if PERL_VERSION_ATLEAST (5,10,0)
2348 /*AvARRAY (av) = ary;*/ 2397 AvARRAY (av) = ary;
2398#else
2349 SvPVX ((SV *)av) = (char *)ary; /* 5.8.8 needs this syntax instead of AvARRAY = ary */ 2399 /* 5.8.8 needs this syntax instead of AvARRAY = ary, yet */
2400 /* -DDEBUGGING flags this as a bug, despite it perfectly working */
2401 SvPVX ((SV *)av) = (char *)ary;
2402#endif
2350 AvMAX (av) = 1; 2403 AvMAX (av) = 1;
2351 AvFILLp (av) = 0; 2404 AvFILLp (av) = 0;
2352 ary [0] = newSViv (count); 2405 ary [0] = newSViv (count);
2353 2406
2354 return newRV_noinc ((SV *)av); 2407 return newRV_noinc ((SV *)av);
2724 XSRETURN_EMPTY; 2777 XSRETURN_EMPTY;
2725} 2778}
2726 2779
2727/*****************************************************************************/ 2780/*****************************************************************************/
2728 2781
2782#if CORO_CLONE
2783# include "clone.c"
2784#endif
2785
2729MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_ 2786MODULE = Coro::State PACKAGE = Coro::State PREFIX = api_
2730 2787
2731PROTOTYPES: DISABLE 2788PROTOTYPES: DISABLE
2732 2789
2733BOOT: 2790BOOT:
2736# if CORO_PTHREAD 2793# if CORO_PTHREAD
2737 coro_thx = PERL_GET_CONTEXT; 2794 coro_thx = PERL_GET_CONTEXT;
2738# endif 2795# endif
2739#endif 2796#endif
2740 BOOT_PAGESIZE; 2797 BOOT_PAGESIZE;
2798
2799 cctx_current = cctx_new_empty ();
2741 2800
2742 irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV); 2801 irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV);
2743 stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); 2802 stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO);
2744 2803
2745 orig_sigelem_get = PL_vtbl_sigelem.svt_get; PL_vtbl_sigelem.svt_get = coro_sigelem_get; 2804 orig_sigelem_get = PL_vtbl_sigelem.svt_get; PL_vtbl_sigelem.svt_get = coro_sigelem_get;
2871void 2930void
2872_exit (int code) 2931_exit (int code)
2873 PROTOTYPE: $ 2932 PROTOTYPE: $
2874 CODE: 2933 CODE:
2875 _exit (code); 2934 _exit (code);
2935
2936SV *
2937clone (Coro::State coro)
2938 CODE:
2939{
2940#if CORO_CLONE
2941 struct coro *ncoro = coro_clone (aTHX_ coro);
2942 MAGIC *mg;
2943 /* TODO: too much duplication */
2944 ncoro->hv = newHV ();
2945 mg = sv_magicext ((SV *)ncoro->hv, 0, CORO_MAGIC_type_state, &coro_state_vtbl, (char *)ncoro, 0);
2946 mg->mg_flags |= MGf_DUP;
2947 RETVAL = sv_bless (newRV_noinc ((SV *)ncoro->hv), SvSTASH (coro->hv));
2948#else
2949 croak ("Coro::State->clone has not been configured into this installation of Coro, realised");
2950#endif
2951}
2952 OUTPUT:
2953 RETVAL
2876 2954
2877int 2955int
2878cctx_stacksize (int new_stacksize = 0) 2956cctx_stacksize (int new_stacksize = 0)
2879 PROTOTYPE: ;$ 2957 PROTOTYPE: ;$
2880 CODE: 2958 CODE:
3001 3079
3002SV * 3080SV *
3003has_cctx (Coro::State coro) 3081has_cctx (Coro::State coro)
3004 PROTOTYPE: $ 3082 PROTOTYPE: $
3005 CODE: 3083 CODE:
3006 RETVAL = boolSV (!!coro->cctx); 3084 /* maybe manage the running flag differently */
3085 RETVAL = boolSV (!!coro->cctx || (coro->flags & CF_RUNNING));
3007 OUTPUT: 3086 OUTPUT:
3008 RETVAL 3087 RETVAL
3009 3088
3010int 3089int
3011is_traced (Coro::State coro) 3090is_traced (Coro::State coro)
3031 3110
3032void 3111void
3033force_cctx () 3112force_cctx ()
3034 PROTOTYPE: 3113 PROTOTYPE:
3035 CODE: 3114 CODE:
3036 SvSTATE_current->cctx->idle_sp = 0; 3115 cctx_current->idle_sp = 0;
3037 3116
3038void 3117void
3039swap_defsv (Coro::State self) 3118swap_defsv (Coro::State self)
3040 PROTOTYPE: $ 3119 PROTOTYPE: $
3041 ALIAS: 3120 ALIAS:
3058{ 3137{
3059 int i; 3138 int i;
3060 3139
3061 sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE); 3140 sv_pool_rss = coro_get_sv (aTHX_ "Coro::POOL_RSS" , TRUE);
3062 sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE); 3141 sv_pool_size = coro_get_sv (aTHX_ "Coro::POOL_SIZE" , TRUE);
3063 cv_coro_run = get_cv ( "Coro::_terminate", GV_ADD); 3142 cv_coro_run = get_cv ( "Coro::_coro_run" , GV_ADD);
3064 cv_coro_terminate = get_cv ( "Coro::terminate" , GV_ADD); 3143 cv_coro_terminate = get_cv ( "Coro::terminate" , GV_ADD);
3065 coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); SvREADONLY_on (coro_current); 3144 coro_current = coro_get_sv (aTHX_ "Coro::current" , FALSE); SvREADONLY_on (coro_current);
3066 av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE); 3145 av_async_pool = coro_get_av (aTHX_ "Coro::async_pool", TRUE);
3067 av_destroy = coro_get_av (aTHX_ "Coro::destroy" , TRUE); 3146 av_destroy = coro_get_av (aTHX_ "Coro::destroy" , TRUE);
3068 sv_manager = coro_get_sv (aTHX_ "Coro::manager" , TRUE); 3147 sv_manager = coro_get_sv (aTHX_ "Coro::manager" , TRUE);
3148 sv_idle = coro_get_sv (aTHX_ "Coro::idle" , TRUE);
3069 3149
3070 sv_async_pool_idle = newSVpv ("[async pool idle]", 0); SvREADONLY_on (sv_async_pool_idle); 3150 sv_async_pool_idle = newSVpv ("[async pool idle]", 0); SvREADONLY_on (sv_async_pool_idle);
3071 sv_Coro = newSVpv ("Coro", 0); SvREADONLY_on (sv_Coro); 3151 sv_Coro = newSVpv ("Coro", 0); SvREADONLY_on (sv_Coro);
3072 cv_pool_handler = get_cv ("Coro::pool_handler", GV_ADD); SvREADONLY_on (cv_pool_handler); 3152 cv_pool_handler = get_cv ("Coro::pool_handler", GV_ADD); SvREADONLY_on (cv_pool_handler);
3073 cv_coro_state_new = get_cv ("Coro::State::new", 0); SvREADONLY_on (cv_coro_state_new); 3153 cv_coro_state_new = get_cv ("Coro::State::new", 0); SvREADONLY_on (cv_coro_state_new);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines