Lines Matching refs:th

26  * in Proc. of 51th Programming Symposium, pp.21--28 (2010) (in Japanese).
97 size_t vm_stack_slen; /* length of stack (head of th->stack) */
98 size_t vm_stack_clen; /* length of control frames (tail of th->stack) */
165 #define THREAD_MUST_BE_RUNNING(th) do { \
166 if (!(th)->tag) rb_raise(rb_eThreadError, "not running thread"); \
197 rb_thread_t *th;
199 GetThreadPtr(cont->saved_thread.self, th);
200 if ((th->fiber != cont->self) && fib->status == RUNNING) {
374 cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
378 SET_MACHINE_STACK_END(&th->machine_stack_end);
380 th->machine_register_stack_end = rb_ia64_bsp();
383 if (th->machine_stack_start > th->machine_stack_end) {
384 size = cont->machine_stack_size = th->machine_stack_start - th->machine_stack_end;
385 cont->machine_stack_src = th->machine_stack_end;
388 size = cont->machine_stack_size = th->machine_stack_end - th->machine_stack_start;
389 cont->machine_stack_src = th->machine_stack_start;
404 size = cont->machine_register_stack_size = th->machine_register_stack_end - th->machine_register_stack_start;
405 cont->machine_register_stack_src = th->machine_register_stack_start;
423 cont_save_thread(rb_context_t *cont, rb_thread_t *th)
426 cont->saved_thread = *th;
438 cont_init(rb_context_t *cont, rb_thread_t *th)
441 cont_save_thread(cont, th);
450 rb_thread_t *th = GET_THREAD();
452 THREAD_MUST_BE_RUNNING(th);
455 cont_init(cont, th);
463 rb_thread_t *th = GET_THREAD(), *sth;
466 THREAD_MUST_BE_RUNNING(th);
467 rb_vm_stack_to_heap(th);
473 cont->vm_stack_slen = th->cfp->sp + th->mark_stack_len - th->stack;
474 cont->vm_stack_clen = th->stack + th->stack_size - (VALUE*)th->cfp;
476 MEMCPY(cont->vm_stack, th->stack, VALUE, cont->vm_stack_slen);
477 MEMCPY(cont->vm_stack + cont->vm_stack_slen, (VALUE*)th->cfp, VALUE, cont->vm_stack_clen);
479 cont->vm_stack = ALLOC_N(VALUE, th->stack_size);
480 MEMCPY(cont->vm_stack, th->stack, VALUE, th->stack_size);
484 cont_save_machine_stack(th, cont);
504 rb_thread_t *th = GET_THREAD(), *sth = &cont->saved_thread;
511 th->fiber = sth->fiber;
512 fib = th->fiber ? th->fiber : th->root_fiber;
517 th->stack_size = fcont->cont.saved_thread.stack_size;
518 th->stack = fcont->cont.saved_thread.stack;
521 MEMCPY(th->stack, cont->vm_stack, VALUE, cont->vm_stack_slen);
522 MEMCPY(th->stack + sth->stack_size - cont->vm_stack_clen,
525 MEMCPY(th->stack, cont->vm_stack, VALUE, sth->stack_size);
530 th->stack = sth->stack;
531 th->stack_size = sth->stack_size;
532 th->local_storage = sth->local_storage;
533 th->fiber = cont->self;
536 th->cfp = sth->cfp;
537 th->safe_level = sth->safe_level;
538 th->raised_flag = sth->raised_flag;
539 th->state = sth->state;
540 th->status = sth->status;
541 th->tag = sth->tag;
542 th->protect_tag = sth->protect_tag;
543 th->errinfo = sth->errinfo;
544 th->first_proc = sth->first_proc;
545 th->root_lep = sth->root_lep;
546 th->root_svar = sth->root_svar;
554 rb_thread_t *th = GET_THREAD();
558 th->machine_stack_start = (void*)(((VALUE)ptr & RB_PAGE_MASK) + STACK_UPPER((void *)&ptr, 0, RB_PAGE_SIZE));
657 rb_thread_t *th = GET_THREAD(), *sth = &newfib->cont.saved_thread;
660 fiber_initialize_machine_stack_context(newfib, th->vm->default_params.fiber_machine_stack_size);
665 th->machine_stack_maxsize = sth->machine_stack_maxsize;
673 SET_MACHINE_STACK_END(&th->machine_stack_end);
675 oldfib->cont.machine_stack_size = th->machine_stack_start - th->machine_stack_end;
676 oldfib->cont.machine_stack = th->machine_stack_end;
679 oldfib->cont.machine_stack_size = th->machine_stack_end - th->machine_stack_start;
680 oldfib->cont.machine_stack = th->machine_stack_start;
684 oldfib->cont.saved_thread.machine_stack_start = th->machine_stack_start;
685 th->machine_stack_start = sth->machine_stack_start;
689 if (!newfib->context.uc_stack.ss_sp && th->root_fiber != newfib->cont.self) {
937 rb_thread_t *th = GET_THREAD();
940 if (cont->saved_thread.self != th->self) {
943 if (cont->saved_thread.protect_tag != th->protect_tag) {
950 if (th->fiber != cont->saved_thread.fiber) {
959 th->trace_arg = cont->saved_thread.trace_arg;
1046 rb_thread_t *th = GET_THREAD();
1052 THREAD_MUST_BE_RUNNING(th);
1057 cont_init(&fib->cont, th);
1071 rb_thread_t *th = &cont->saved_thread;
1076 th->stack = 0;
1077 th->stack_size = 0;
1081 th->stack_size = th->vm->default_params.fiber_vm_stack_size / sizeof(VALUE);
1082 th->stack = ALLOC_N(VALUE, th->stack_size);
1084 th->cfp = (void *)(th->stack + th->stack_size);
1085 th->cfp--;
1086 th->cfp->pc = 0;
1087 th->cfp->sp = th->stack + 1;
1089 th->cfp->bp_check = 0;
1091 th->cfp->ep = th->stack;
1092 *th->cfp->ep = VM_ENVVAL_BLOCK_PTR(0);
1093 th->cfp->self = Qnil;
1094 th->cfp->klass = Qnil;
1095 th->cfp->flag = 0;
1096 th->cfp->iseq = 0;
1097 th->cfp->proc = 0;
1098 th->cfp->block_iseq = 0;
1099 th->cfp->me = 0;
1100 th->tag = 0;
1101 th->local_storage = st_init_numtable();
1103 th->first_proc = proc;
1106 MEMCPY(&cont->jmpbuf, &th->root_jmpbuf, rb_jmpbuf_t, 1);
1169 rb_thread_t *th = GET_THREAD();
1175 GetFiberPtr(th->fiber, fib);
1178 TH_PUSH_TAG(th);
1186 th->errinfo = Qnil;
1187 th->root_lep = rb_vm_ep_local_ep(proc->block.ep);
1188 th->root_svar = Qnil;
1191 cont->value = rb_vm_invoke_proc(th, proc, argc, argv, 0);
1197 rb_threadptr_pending_interrupt_enque(th, th->errinfo);
1200 VALUE err = rb_vm_make_jump_tag_but_local_jump(state, th->errinfo);
1202 rb_threadptr_pending_interrupt_enque(th, err);
1204 RUBY_VM_SET_INTERRUPT(th);
1212 root_fiber_alloc(rb_thread_t *th)
1232 rb_thread_t *th = GET_THREAD();
1233 if (th->fiber == 0) {
1235 rb_fiber_t *fib = root_fiber_alloc(th);
1236 th->root_fiber = th->fiber = fib->cont.self;
1238 return th->fiber;
1244 rb_thread_t *th = GET_THREAD();
1247 if (th->fiber) {
1248 GetFiberPtr(th->fiber, fib);
1249 cont_save_thread(&fib->cont, th);
1253 fib = root_fiber_alloc(th);
1254 th->root_fiber = th->fiber = fib->cont.self;
1258 cont_save_machine_stack(th, &fib->cont);
1285 GetFiberPtr(th->fiber, fib);
1302 rb_thread_t *th = GET_THREAD();
1307 if (th->fiber == fibval) {
1314 if (cont->saved_thread.self != th->self) {
1317 else if (cont->saved_thread.protect_tag != th->protect_tag) {
1322 if (th->fiber != fibval) {
1323 GetFiberPtr(th->fiber, fib);
1325 fibval = th->root_fiber;
1329 if (NIL_P(fibval)) fibval = th->root_fiber;
1353 th->trace_arg = cont->saved_thread.trace_arg;
1366 RUBY_VM_CHECK_INTS(th);
1402 rb_thread_t *th;
1405 GetThreadPtr(thval, th);
1406 if (th->root_fiber && th->root_fiber != th->fiber) {
1407 GetFiberPtr(th->root_fiber, fib);
1408 th->local_storage = fib->cont.saved_thread.local_storage;
1553 rb_thread_t *th = GET_THREAD();
1562 SET_MACHINE_STACK_END(&th->machine_stack_end);