… | |
… | |
142 | #define NOINLINE attribute ((noinline)) |
142 | #define NOINLINE attribute ((noinline)) |
143 | |
143 | |
144 | #include "CoroAPI.h" |
144 | #include "CoroAPI.h" |
145 | |
145 | |
146 | #ifdef USE_ITHREADS |
146 | #ifdef USE_ITHREADS |
|
|
147 | |
147 | static perl_mutex coro_lock; |
148 | static perl_mutex coro_lock; |
148 | # define LOCK do { MUTEX_LOCK (&coro_lock); } while (0) |
149 | # define LOCK do { MUTEX_LOCK (&coro_lock); } while (0) |
149 | # define UNLOCK do { MUTEX_UNLOCK (&coro_lock); } while (0) |
150 | # define UNLOCK do { MUTEX_UNLOCK (&coro_lock); } while (0) |
|
|
151 | # if CORO_PTHREAD |
|
|
152 | static void *coro_thx; |
|
|
153 | # endif |
|
|
154 | |
150 | #else |
155 | #else |
|
|
156 | |
151 | # define LOCK (void)0 |
157 | # define LOCK (void)0 |
152 | # define UNLOCK (void)0 |
158 | # define UNLOCK (void)0 |
|
|
159 | |
153 | #endif |
160 | #endif |
|
|
161 | |
|
|
162 | # undef LOCK |
|
|
163 | # define LOCK (void)0 |
|
|
164 | # undef UNLOCK |
|
|
165 | # define UNLOCK (void)0 |
154 | |
166 | |
155 | /* helper storage struct for Coro::AIO */ |
167 | /* helper storage struct for Coro::AIO */ |
156 | struct io_state |
168 | struct io_state |
157 | { |
169 | { |
158 | AV *res; |
170 | AV *res; |
… | |
… | |
169 | static struct CoroAPI coroapi; |
181 | static struct CoroAPI coroapi; |
170 | static AV *main_mainstack; /* used to differentiate between $main and others */ |
182 | static AV *main_mainstack; /* used to differentiate between $main and others */ |
171 | static JMPENV *main_top_env; |
183 | static JMPENV *main_top_env; |
172 | static HV *coro_state_stash, *coro_stash; |
184 | static HV *coro_state_stash, *coro_stash; |
173 | static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ |
185 | static volatile SV *coro_mortal; /* will be freed/thrown after next transfer */ |
|
|
186 | static volatile struct coro *transfer_next; |
|
|
187 | |
|
|
188 | struct transfer_args |
|
|
189 | { |
|
|
190 | struct coro *prev, *next; |
|
|
191 | }; |
174 | |
192 | |
175 | static GV *irsgv; /* $/ */ |
193 | static GV *irsgv; /* $/ */ |
176 | static GV *stdoutgv; /* *STDOUT */ |
194 | static GV *stdoutgv; /* *STDOUT */ |
177 | static SV *rv_diehook; |
195 | static SV *rv_diehook; |
178 | static SV *rv_warnhook; |
196 | static SV *rv_warnhook; |
… | |
… | |
280 | #define PRIO_MIN -4 |
298 | #define PRIO_MIN -4 |
281 | |
299 | |
282 | /* for Coro.pm */ |
300 | /* for Coro.pm */ |
283 | static SV *coro_current; |
301 | static SV *coro_current; |
284 | static SV *coro_readyhook; |
302 | static SV *coro_readyhook; |
285 | static AV *coro_ready [PRIO_MAX-PRIO_MIN+1]; |
303 | static AV *coro_ready [PRIO_MAX - PRIO_MIN + 1]; |
286 | static int coro_nready; |
304 | static int coro_nready; |
287 | static struct coro *coro_first; |
305 | static struct coro *coro_first; |
288 | |
306 | |
289 | /** lowlevel stuff **********************************************************/ |
307 | /** lowlevel stuff **********************************************************/ |
290 | |
308 | |
… | |
… | |
822 | PL_rs = newSVsv (GvSV (irsgv)); |
840 | PL_rs = newSVsv (GvSV (irsgv)); |
823 | PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv); |
841 | PL_defoutgv = (GV *)SvREFCNT_inc_NN (stdoutgv); |
824 | |
842 | |
825 | { |
843 | { |
826 | dSP; |
844 | dSP; |
827 | LOGOP myop; |
845 | UNOP myop; |
828 | |
846 | |
829 | Zero (&myop, 1, LOGOP); |
847 | Zero (&myop, 1, UNOP); |
830 | myop.op_next = Nullop; |
848 | myop.op_next = Nullop; |
831 | myop.op_flags = OPf_WANT_VOID; |
849 | myop.op_flags = OPf_WANT_VOID; |
832 | |
850 | |
833 | PUSHMARK (SP); |
851 | PUSHMARK (SP); |
834 | XPUSHs (sv_2mortal (av_shift (GvAV (PL_defgv)))); |
852 | XPUSHs (sv_2mortal (av_shift (GvAV (PL_defgv)))); |
… | |
… | |
838 | SPAGAIN; |
856 | SPAGAIN; |
839 | } |
857 | } |
840 | |
858 | |
841 | /* this newly created coroutine might be run on an existing cctx which most |
859 | /* this newly created coroutine might be run on an existing cctx which most |
842 | * likely was suspended in set_stacklevel, called from entersub. |
860 | * likely was suspended in set_stacklevel, called from entersub. |
843 | * set_stacklevl doesn't do anything on return, but entersub does LEAVE, |
861 | * set_stacklevel doesn't do anything on return, but entersub does LEAVE, |
844 | * so we ENTER here for symmetry |
862 | * so we ENTER here for symmetry. |
845 | */ |
863 | */ |
846 | ENTER; |
864 | ENTER; |
847 | } |
865 | } |
848 | |
866 | |
849 | static void |
867 | static void |
… | |
… | |
1014 | |
1032 | |
1015 | TAINT_NOT; |
1033 | TAINT_NOT; |
1016 | return 0; |
1034 | return 0; |
1017 | } |
1035 | } |
1018 | |
1036 | |
|
|
1037 | static void |
|
|
1038 | prepare_set_stacklevel (struct transfer_args *ta, struct coro_cctx *cctx) |
|
|
1039 | { |
|
|
1040 | ta->prev = (struct coro *)cctx; |
|
|
1041 | ta->next = 0; |
|
|
1042 | } |
|
|
1043 | |
1019 | /* inject a fake call to Coro::State::_cctx_init into the execution */ |
1044 | /* inject a fake call to Coro::State::_cctx_init into the execution */ |
1020 | /* _cctx_init should be careful, as it could be called at almost any time */ |
1045 | /* _cctx_init should be careful, as it could be called at almost any time */ |
1021 | /* during execution of a perl program */ |
1046 | /* during execution of a perl program */ |
|
|
1047 | /* also initialises PL_top_env */ |
1022 | static void NOINLINE |
1048 | static void NOINLINE |
1023 | cctx_prepare (pTHX_ coro_cctx *cctx) |
1049 | cctx_prepare (pTHX_ coro_cctx *cctx) |
1024 | { |
1050 | { |
1025 | dSP; |
1051 | dSP; |
1026 | LOGOP myop; |
1052 | UNOP myop; |
1027 | |
1053 | |
1028 | PL_top_env = &PL_start_env; |
1054 | PL_top_env = &PL_start_env; |
1029 | |
1055 | |
1030 | if (cctx->flags & CC_TRACE) |
1056 | if (cctx->flags & CC_TRACE) |
1031 | PL_runops = runops_trace; |
1057 | PL_runops = runops_trace; |
1032 | |
1058 | |
1033 | Zero (&myop, 1, LOGOP); |
1059 | Zero (&myop, 1, UNOP); |
1034 | myop.op_next = PL_op; |
1060 | myop.op_next = PL_op; |
1035 | myop.op_flags = OPf_WANT_VOID | OPf_STACKED; |
1061 | myop.op_flags = OPf_WANT_VOID | OPf_STACKED; |
1036 | |
1062 | |
1037 | PUSHMARK (SP); |
1063 | PUSHMARK (SP); |
1038 | EXTEND (SP, 2); |
1064 | EXTEND (SP, 2); |
1039 | PUSHs (sv_2mortal (newSViv (PTR2IV (cctx)))); |
1065 | PUSHs (sv_2mortal (newSViv ((IV)cctx))); |
1040 | PUSHs ((SV *)get_cv ("Coro::State::_cctx_init", FALSE)); |
1066 | PUSHs ((SV *)get_cv ("Coro::State::_cctx_init", FALSE)); |
1041 | PUTBACK; |
1067 | PUTBACK; |
1042 | PL_op = (OP *)&myop; |
1068 | PL_op = (OP *)&myop; |
1043 | PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); |
1069 | PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); |
1044 | SPAGAIN; |
1070 | SPAGAIN; |
1045 | } |
1071 | } |
1046 | |
1072 | |
|
|
1073 | /* the tail of transfer: execute stuff we can onyl do afetr a transfer */ |
|
|
1074 | static void |
|
|
1075 | transfer_tail (void) |
|
|
1076 | { |
|
|
1077 | struct coro *next = (struct coro *)transfer_next; |
|
|
1078 | transfer_next = 0; //D for temporary assertion in transfer |
|
|
1079 | assert (("FATAL ERROR: internal error 1067 in Coro module, please report", next));//D |
|
|
1080 | |
|
|
1081 | free_coro_mortal (aTHX); |
|
|
1082 | UNLOCK; |
|
|
1083 | |
|
|
1084 | if (expect_false (next->throw)) |
|
|
1085 | { |
|
|
1086 | SV *exception = sv_2mortal (next->throw); |
|
|
1087 | |
|
|
1088 | next->throw = 0; |
|
|
1089 | sv_setsv (ERRSV, exception); |
|
|
1090 | croak (0); |
|
|
1091 | } |
|
|
1092 | } |
|
|
1093 | |
1047 | /* |
1094 | /* |
1048 | * this is a _very_ stripped down perl interpreter ;) |
1095 | * this is a _very_ stripped down perl interpreter ;) |
1049 | */ |
1096 | */ |
1050 | static void |
1097 | static void |
1051 | cctx_run (void *arg) |
1098 | cctx_run (void *arg) |
1052 | { |
1099 | { |
|
|
1100 | #ifdef USE_ITHREADS |
|
|
1101 | # if CORO_PTHREAD |
|
|
1102 | PERL_SET_CONTEXT (coro_thx); |
|
|
1103 | # endif |
|
|
1104 | #endif |
|
|
1105 | { |
1053 | dTHX; |
1106 | dTHX; |
1054 | |
1107 | |
1055 | /* cctx_run is the alternative tail of transfer(), so unlock here. */ |
1108 | /* entersub called ENTER, but we never 'returned', undo that here */ |
1056 | UNLOCK; |
1109 | LEAVE; |
1057 | |
1110 | |
1058 | /* we now skip the entersub that lead to transfer() */ |
1111 | /* we now skip the entersub that did lead to transfer() */ |
1059 | PL_op = PL_op->op_next; |
1112 | PL_op = PL_op->op_next; |
1060 | |
1113 | |
1061 | /* inject a fake subroutine call to cctx_init */ |
1114 | /* inject a fake subroutine call to cctx_init */ |
1062 | cctx_prepare (aTHX_ (coro_cctx *)arg); |
1115 | cctx_prepare (aTHX_ (coro_cctx *)arg); |
1063 | |
1116 | |
|
|
1117 | /* cctx_run is the alternative tail of transfer() */ |
|
|
1118 | transfer_tail (); |
|
|
1119 | |
1064 | /* somebody or something will hit me for both perl_run and PL_restartop */ |
1120 | /* somebody or something will hit me for both perl_run and PL_restartop */ |
1065 | PL_restartop = PL_op; |
1121 | PL_restartop = PL_op; |
1066 | perl_run (PL_curinterp); |
1122 | perl_run (PL_curinterp); |
1067 | |
1123 | |
1068 | /* |
1124 | /* |
1069 | * If perl-run returns we assume exit() was being called or the coro |
1125 | * If perl-run returns we assume exit() was being called or the coro |
1070 | * fell off the end, which seems to be the only valid (non-bug) |
1126 | * fell off the end, which seems to be the only valid (non-bug) |
1071 | * reason for perl_run to return. We try to exit by jumping to the |
1127 | * reason for perl_run to return. We try to exit by jumping to the |
1072 | * bootstrap-time "top" top_env, as we cannot restore the "main" |
1128 | * bootstrap-time "top" top_env, as we cannot restore the "main" |
1073 | * coroutine as Coro has no such concept |
1129 | * coroutine as Coro has no such concept |
1074 | */ |
1130 | */ |
1075 | PL_top_env = main_top_env; |
1131 | PL_top_env = main_top_env; |
1076 | JMPENV_JUMP (2); /* I do not feel well about the hardcoded 2 at all */ |
1132 | JMPENV_JUMP (2); /* I do not feel well about the hardcoded 2 at all */ |
|
|
1133 | } |
1077 | } |
1134 | } |
1078 | |
1135 | |
1079 | static coro_cctx * |
1136 | static coro_cctx * |
1080 | cctx_new () |
1137 | cctx_new () |
1081 | { |
1138 | { |
1082 | coro_cctx *cctx; |
1139 | coro_cctx *cctx; |
|
|
1140 | |
|
|
1141 | ++cctx_count; |
|
|
1142 | New (0, cctx, 1, coro_cctx); |
|
|
1143 | |
|
|
1144 | cctx->gen = cctx_gen; |
|
|
1145 | cctx->flags = 0; |
|
|
1146 | cctx->idle_sp = 0; /* can be accessed by transfer between cctx_run and set_stacklevel, on throw */ |
|
|
1147 | |
|
|
1148 | return cctx; |
|
|
1149 | } |
|
|
1150 | |
|
|
1151 | /* create a new cctx only suitable as source */ |
|
|
1152 | static coro_cctx * |
|
|
1153 | cctx_new_empty () |
|
|
1154 | { |
|
|
1155 | coro_cctx *cctx = cctx_new (); |
|
|
1156 | |
|
|
1157 | cctx->sptr = 0; |
|
|
1158 | coro_create (&cctx->cctx, 0, 0, 0, 0); |
|
|
1159 | |
|
|
1160 | return cctx; |
|
|
1161 | } |
|
|
1162 | |
|
|
1163 | /* create a new cctx suitable as destination/running a perl interpreter */ |
|
|
1164 | static coro_cctx * |
|
|
1165 | cctx_new_run () |
|
|
1166 | { |
|
|
1167 | coro_cctx *cctx = cctx_new (); |
1083 | void *stack_start; |
1168 | void *stack_start; |
1084 | size_t stack_size; |
1169 | size_t stack_size; |
1085 | |
|
|
1086 | ++cctx_count; |
|
|
1087 | Newz (0, cctx, 1, coro_cctx); |
|
|
1088 | |
|
|
1089 | cctx->gen = cctx_gen; |
|
|
1090 | |
1170 | |
1091 | #if HAVE_MMAP |
1171 | #if HAVE_MMAP |
1092 | cctx->ssize = ((cctx_stacksize * sizeof (long) + PAGESIZE - 1) / PAGESIZE + CORO_STACKGUARD) * PAGESIZE; |
1172 | cctx->ssize = ((cctx_stacksize * sizeof (long) + PAGESIZE - 1) / PAGESIZE + CORO_STACKGUARD) * PAGESIZE; |
1093 | /* mmap supposedly does allocate-on-write for us */ |
1173 | /* mmap supposedly does allocate-on-write for us */ |
1094 | cctx->sptr = mmap (0, cctx->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); |
1174 | cctx->sptr = mmap (0, cctx->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); |
… | |
… | |
1167 | return cctx; |
1247 | return cctx; |
1168 | |
1248 | |
1169 | cctx_destroy (cctx); |
1249 | cctx_destroy (cctx); |
1170 | } |
1250 | } |
1171 | |
1251 | |
1172 | return cctx_new (); |
1252 | return cctx_new_run (); |
1173 | } |
1253 | } |
1174 | |
1254 | |
1175 | static void |
1255 | static void |
1176 | cctx_put (coro_cctx *cctx) |
1256 | cctx_put (coro_cctx *cctx) |
1177 | { |
1257 | { |
… | |
… | |
1227 | ((coro_cctx *)prev)->idle_sp = STACKLEVEL; |
1307 | ((coro_cctx *)prev)->idle_sp = STACKLEVEL; |
1228 | assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ |
1308 | assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ |
1229 | } |
1309 | } |
1230 | else if (expect_true (prev != next)) |
1310 | else if (expect_true (prev != next)) |
1231 | { |
1311 | { |
1232 | static volatile int has_throw; |
|
|
1233 | coro_cctx *prev__cctx; |
1312 | coro_cctx *prev__cctx; |
1234 | |
1313 | |
1235 | if (expect_false (prev->flags & CF_NEW)) |
1314 | if (expect_false (prev->flags & CF_NEW)) |
1236 | { |
1315 | { |
1237 | /* create a new empty/source context */ |
1316 | /* create a new empty/source context */ |
1238 | ++cctx_count; |
1317 | prev->cctx = cctx_new_empty (); |
1239 | New (0, prev->cctx, 1, coro_cctx); |
|
|
1240 | prev->cctx->sptr = 0; |
|
|
1241 | coro_create (&prev->cctx->cctx, 0, 0, 0, 0); |
|
|
1242 | |
|
|
1243 | prev->flags &= ~CF_NEW; |
1318 | prev->flags &= ~CF_NEW; |
1244 | prev->flags |= CF_RUNNING; |
1319 | prev->flags |= CF_RUNNING; |
1245 | } |
1320 | } |
1246 | |
1321 | |
1247 | prev->flags &= ~CF_RUNNING; |
1322 | prev->flags &= ~CF_RUNNING; |
… | |
… | |
1262 | else |
1337 | else |
1263 | load_perl (aTHX_ next); |
1338 | load_perl (aTHX_ next); |
1264 | |
1339 | |
1265 | prev__cctx = prev->cctx; |
1340 | prev__cctx = prev->cctx; |
1266 | |
1341 | |
1267 | /* possibly "free" the cctx */ |
1342 | /* possibly untie and reuse the cctx */ |
1268 | if (expect_true ( |
1343 | if (expect_true ( |
1269 | prev__cctx->idle_sp == STACKLEVEL |
1344 | prev__cctx->idle_sp == STACKLEVEL |
1270 | && !(prev__cctx->flags & CC_TRACE) |
1345 | && !(prev__cctx->flags & CC_TRACE) |
1271 | && !force_cctx |
1346 | && !force_cctx |
1272 | )) |
1347 | )) |
… | |
… | |
1288 | ++next->usecount; |
1363 | ++next->usecount; |
1289 | |
1364 | |
1290 | if (expect_true (!next->cctx)) |
1365 | if (expect_true (!next->cctx)) |
1291 | next->cctx = cctx_get (aTHX); |
1366 | next->cctx = cctx_get (aTHX); |
1292 | |
1367 | |
1293 | has_throw = !!next->throw; |
1368 | assert (("FATAL ERROR: internal error 1352 in Coro, please report", !transfer_next));//D |
|
|
1369 | transfer_next = next; |
1294 | |
1370 | |
1295 | if (expect_false (prev__cctx != next->cctx)) |
1371 | if (expect_false (prev__cctx != next->cctx)) |
1296 | { |
1372 | { |
1297 | prev__cctx->top_env = PL_top_env; |
1373 | prev__cctx->top_env = PL_top_env; |
1298 | PL_top_env = next->cctx->top_env; |
1374 | PL_top_env = next->cctx->top_env; |
1299 | coro_transfer (&prev__cctx->cctx, &next->cctx->cctx); |
1375 | coro_transfer (&prev__cctx->cctx, &next->cctx->cctx); |
1300 | } |
1376 | } |
1301 | |
1377 | |
1302 | free_coro_mortal (aTHX); |
1378 | transfer_tail (); |
1303 | UNLOCK; |
|
|
1304 | |
|
|
1305 | if (expect_false (has_throw)) |
|
|
1306 | { |
|
|
1307 | struct coro *coro = SvSTATE (coro_current); |
|
|
1308 | |
|
|
1309 | if (coro->throw) |
|
|
1310 | { |
|
|
1311 | SV *exception = coro->throw; |
|
|
1312 | coro->throw = 0; |
|
|
1313 | sv_setsv (ERRSV, exception); |
|
|
1314 | croak (0); |
|
|
1315 | } |
|
|
1316 | } |
|
|
1317 | } |
1379 | } |
1318 | } |
1380 | } |
1319 | |
|
|
1320 | struct transfer_args |
|
|
1321 | { |
|
|
1322 | struct coro *prev, *next; |
|
|
1323 | }; |
|
|
1324 | |
1381 | |
1325 | #define TRANSFER(ta, force_cctx) transfer (aTHX_ (ta).prev, (ta).next, (force_cctx)) |
1382 | #define TRANSFER(ta, force_cctx) transfer (aTHX_ (ta).prev, (ta).next, (force_cctx)) |
1326 | #define TRANSFER_CHECK(ta) transfer_check (aTHX_ (ta).prev, (ta).next) |
1383 | #define TRANSFER_CHECK(ta) transfer_check (aTHX_ (ta).prev, (ta).next) |
1327 | |
1384 | |
1328 | /** high level stuff ********************************************************/ |
1385 | /** high level stuff ********************************************************/ |
… | |
… | |
1540 | /* cannot transfer to destroyed coros, skip and look for next */ |
1597 | /* cannot transfer to destroyed coros, skip and look for next */ |
1541 | if (expect_false (ta->next->flags & CF_DESTROYED)) |
1598 | if (expect_false (ta->next->flags & CF_DESTROYED)) |
1542 | { |
1599 | { |
1543 | UNLOCK; |
1600 | UNLOCK; |
1544 | SvREFCNT_dec (next_sv); |
1601 | SvREFCNT_dec (next_sv); |
1545 | /* coro_nready is already taken care of by destroy */ |
1602 | /* coro_nready has already been taken care of by destroy */ |
1546 | continue; |
1603 | continue; |
1547 | } |
1604 | } |
1548 | |
1605 | |
1549 | --coro_nready; |
1606 | --coro_nready; |
1550 | UNLOCK; |
1607 | UNLOCK; |
… | |
… | |
1635 | struct coro *coro = SvSTATE (coro_sv); |
1692 | struct coro *coro = SvSTATE (coro_sv); |
1636 | |
1693 | |
1637 | if (flags & CC_TRACE) |
1694 | if (flags & CC_TRACE) |
1638 | { |
1695 | { |
1639 | if (!coro->cctx) |
1696 | if (!coro->cctx) |
1640 | coro->cctx = cctx_new (); |
1697 | coro->cctx = cctx_new_run (); |
1641 | else if (!(coro->cctx->flags & CC_TRACE)) |
1698 | else if (!(coro->cctx->flags & CC_TRACE)) |
1642 | croak ("cannot enable tracing on coroutine with custom stack"); |
1699 | croak ("cannot enable tracing on coroutine with custom stack"); |
1643 | |
1700 | |
1644 | coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL)); |
1701 | coro->cctx->flags |= CC_NOREUSE | (flags & (CC_TRACE | CC_TRACE_ALL)); |
1645 | } |
1702 | } |
… | |
… | |
1754 | |
1811 | |
1755 | BOOT: |
1812 | BOOT: |
1756 | { |
1813 | { |
1757 | #ifdef USE_ITHREADS |
1814 | #ifdef USE_ITHREADS |
1758 | MUTEX_INIT (&coro_lock); |
1815 | MUTEX_INIT (&coro_lock); |
|
|
1816 | # if CORO_PTHREAD |
|
|
1817 | coro_thx = PERL_GET_CONTEXT; |
|
|
1818 | # endif |
1759 | #endif |
1819 | #endif |
1760 | BOOT_PAGESIZE; |
1820 | BOOT_PAGESIZE; |
1761 | |
1821 | |
1762 | irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV); |
1822 | irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV); |
1763 | stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); |
1823 | stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); |
… | |
… | |
1844 | |
1904 | |
1845 | PUTBACK; |
1905 | PUTBACK; |
1846 | switch (ix) |
1906 | switch (ix) |
1847 | { |
1907 | { |
1848 | case 0: |
1908 | case 0: |
1849 | ta.prev = (struct coro *)INT2PTR (coro_cctx *, SvIV (ST (0))); |
1909 | prepare_set_stacklevel (&ta, (struct coro_cctx *)SvIV (ST (0))); |
1850 | ta.next = 0; |
|
|
1851 | break; |
1910 | break; |
1852 | |
1911 | |
1853 | case 1: |
1912 | case 1: |
1854 | if (items != 2) |
1913 | if (items != 2) |
1855 | croak ("Coro::State::transfer (prev, next) expects two arguments, not %d", items); |
1914 | croak ("Coro::State::transfer (prev, next) expects two arguments, not %d", items); |
… | |
… | |
1994 | is_destroyed = CF_DESTROYED |
2053 | is_destroyed = CF_DESTROYED |
1995 | CODE: |
2054 | CODE: |
1996 | RETVAL = boolSV (coro->flags & ix); |
2055 | RETVAL = boolSV (coro->flags & ix); |
1997 | OUTPUT: |
2056 | OUTPUT: |
1998 | RETVAL |
2057 | RETVAL |
|
|
2058 | |
|
|
2059 | void |
|
|
2060 | throw (Coro::State self, SV *throw = &PL_sv_undef) |
|
|
2061 | PROTOTYPE: $;$ |
|
|
2062 | CODE: |
|
|
2063 | SvREFCNT_dec (self->throw); |
|
|
2064 | self->throw = SvOK (throw) ? newSVsv (throw) : 0; |
1999 | |
2065 | |
2000 | void |
2066 | void |
2001 | api_trace (SV *coro, int flags = CC_TRACE | CC_TRACE_SUB) |
2067 | api_trace (SV *coro, int flags = CC_TRACE | CC_TRACE_SUB) |
2002 | |
2068 | |
2003 | SV * |
2069 | SV * |
… | |
… | |
2147 | CODE: |
2213 | CODE: |
2148 | RETVAL = coro_nready; |
2214 | RETVAL = coro_nready; |
2149 | OUTPUT: |
2215 | OUTPUT: |
2150 | RETVAL |
2216 | RETVAL |
2151 | |
2217 | |
2152 | void |
|
|
2153 | throw (Coro::State self, SV *throw = &PL_sv_undef) |
|
|
2154 | PROTOTYPE: $;$ |
|
|
2155 | CODE: |
|
|
2156 | SvREFCNT_dec (self->throw); |
|
|
2157 | self->throw = SvOK (throw) ? newSVsv (throw) : 0; |
|
|
2158 | |
|
|
2159 | # for async_pool speedup |
2218 | # for async_pool speedup |
2160 | void |
2219 | void |
2161 | _pool_1 (SV *cb) |
2220 | _pool_1 (SV *cb) |
2162 | CODE: |
2221 | CODE: |
2163 | { |
2222 | { |