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.152 by root, Thu Sep 20 12:02:25 2007 UTC vs.
Revision 1.156 by root, Fri Sep 21 01:10:55 2007 UTC

210 210
211/* for Coro.pm */ 211/* for Coro.pm */
212static SV *coro_current; 212static SV *coro_current;
213static AV *coro_ready [PRIO_MAX-PRIO_MIN+1]; 213static AV *coro_ready [PRIO_MAX-PRIO_MIN+1];
214static int coro_nready; 214static int coro_nready;
215static struct coro *first; 215static struct coro *coro_first;
216 216
217/** lowlevel stuff **********************************************************/ 217/** lowlevel stuff **********************************************************/
218 218
219static AV * 219static AV *
220coro_clone_padlist (pTHX_ CV *cv) 220coro_clone_padlist (pTHX_ CV *cv)
455# define coro_init_stacks init_stacks 455# define coro_init_stacks init_stacks
456#else 456#else
457static void 457static void
458coro_init_stacks (pTHX) 458coro_init_stacks (pTHX)
459{ 459{
460 PL_curstackinfo = new_stackinfo(128, 1024/sizeof(PERL_CONTEXT)); 460 PL_curstackinfo = new_stackinfo(64, 6);
461 PL_curstackinfo->si_type = PERLSI_MAIN; 461 PL_curstackinfo->si_type = PERLSI_MAIN;
462 PL_curstack = PL_curstackinfo->si_stack; 462 PL_curstack = PL_curstackinfo->si_stack;
463 PL_mainstack = PL_curstack; /* remember in case we switch stacks */ 463 PL_mainstack = PL_curstack; /* remember in case we switch stacks */
464 464
465 PL_stack_base = AvARRAY(PL_curstack); 465 PL_stack_base = AvARRAY(PL_curstack);
466 PL_stack_sp = PL_stack_base; 466 PL_stack_sp = PL_stack_base;
467 PL_stack_max = PL_stack_base + AvMAX(PL_curstack); 467 PL_stack_max = PL_stack_base + AvMAX(PL_curstack);
468 468
469 New(50,PL_tmps_stack,128,SV*); 469 New(50,PL_tmps_stack,64,SV*);
470 PL_tmps_floor = -1; 470 PL_tmps_floor = -1;
471 PL_tmps_ix = -1; 471 PL_tmps_ix = -1;
472 PL_tmps_max = 128; 472 PL_tmps_max = 64;
473 473
474 New(54,PL_markstack,32,I32); 474 New(54,PL_markstack,16,I32);
475 PL_markstack_ptr = PL_markstack; 475 PL_markstack_ptr = PL_markstack;
476 PL_markstack_max = PL_markstack + 32; 476 PL_markstack_max = PL_markstack + 16;
477 477
478#ifdef SET_MARK_OFFSET 478#ifdef SET_MARK_OFFSET
479 SET_MARK_OFFSET; 479 SET_MARK_OFFSET;
480#endif 480#endif
481 481
482 New(54,PL_scopestack,32,I32); 482 New(54,PL_scopestack,16,I32);
483 PL_scopestack_ix = 0; 483 PL_scopestack_ix = 0;
484 PL_scopestack_max = 32; 484 PL_scopestack_max = 16;
485 485
486 New(54,PL_savestack,64,ANY); 486 New(54,PL_savestack,64,ANY);
487 PL_savestack_ix = 0; 487 PL_savestack_ix = 0;
488 PL_savestack_max = 64; 488 PL_savestack_max = 64;
489 489
490#if !PERL_VERSION_ATLEAST (5,9,0) 490#if !PERL_VERSION_ATLEAST (5,9,0)
491 New(54,PL_retstack,16,OP*); 491 New(54,PL_retstack,4,OP*);
492 PL_retstack_ix = 0; 492 PL_retstack_ix = 0;
493 PL_retstack_max = 16; 493 PL_retstack_max = 4;
494#endif 494#endif
495} 495}
496#endif 496#endif
497 497
498/* 498/*
547{ 547{
548 size_t rss = sizeof (coro); 548 size_t rss = sizeof (coro);
549 549
550 if (coro->mainstack) 550 if (coro->mainstack)
551 { 551 {
552 if (coro->flags & CF_RUNNING)
553 {
554 #define VAR(name,type)coro->name = PL_ ## name;
555 # include "state.h"
556 #undef VAR
557 }
558
552 rss += sizeof (coro->curstackinfo); 559 rss += sizeof (coro->curstackinfo);
553 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *); 560 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *);
554 rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT); 561 rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT);
555
556 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *); 562 rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *);
557
558 rss += coro->tmps_max * sizeof (SV *); 563 rss += coro->tmps_max * sizeof (SV *);
559
560 rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32); 564 rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32);
561
562 rss += coro->scopestack_max * sizeof (I32); 565 rss += coro->scopestack_max * sizeof (I32);
563
564 rss += coro->savestack_max * sizeof (ANY); 566 rss += coro->savestack_max * sizeof (ANY);
565 567
566#if !PERL_VERSION_ATLEAST (5,9,0) 568#if !PERL_VERSION_ATLEAST (5,9,0)
567 rss += coro->retstack_max * sizeof (OP *); 569 rss += coro->retstack_max * sizeof (OP *);
568#endif 570#endif
929 cctx_destroy (coro->cctx); 931 cctx_destroy (coro->cctx);
930 SvREFCNT_dec (coro->args); 932 SvREFCNT_dec (coro->args);
931 933
932 if (coro->next) coro->next->prev = coro->prev; 934 if (coro->next) coro->next->prev = coro->prev;
933 if (coro->prev) coro->prev->next = coro->next; 935 if (coro->prev) coro->prev->next = coro->next;
934 if (coro == first) first = coro->next; 936 if (coro == coro_first) coro_first = coro->next;
935 937
936 return 1; 938 return 1;
937} 939}
938 940
939static int 941static int
1247 Newz (0, coro, 1, struct coro); 1249 Newz (0, coro, 1, struct coro);
1248 coro->args = newAV (); 1250 coro->args = newAV ();
1249 coro->save = CORO_SAVE_DEF; 1251 coro->save = CORO_SAVE_DEF;
1250 coro->flags = CF_NEW; 1252 coro->flags = CF_NEW;
1251 1253
1252 if (first) first->prev = coro; 1254 if (coro_first) coro_first->prev = coro;
1253 coro->next = first; 1255 coro->next = coro_first;
1254 first = coro; 1256 coro_first = coro;
1255 1257
1256 coro->hv = hv = newHV (); 1258 coro->hv = hv = newHV ();
1257 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP; 1259 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP;
1258 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 1260 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
1259 1261
1368void 1370void
1369list () 1371list ()
1370 PPCODE: 1372 PPCODE:
1371{ 1373{
1372 struct coro *coro; 1374 struct coro *coro;
1373 for (coro = first; coro; coro = coro->next) 1375 for (coro = coro_first; coro; coro = coro->next)
1374 if (coro->hv) 1376 if (coro->hv)
1375 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv))); 1377 XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv)));
1376} 1378}
1377 1379
1378void 1380void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines