static void cont_restore_1(rb_context_t *cont) { cont_restore_thread(cont); /* restore machine stack */ #ifdef _M_AMD64 { /* workaround for x64 SEH */ jmp_buf buf; setjmp(buf); ((_JUMP_BUFFER*)(&cont->jmpbuf))->Frame = ((_JUMP_BUFFER*)(&buf))->Frame; } #endif if (cont->machine_stack_src) { FLUSH_REGISTER_WINDOWS; MEMCPY(cont->machine_stack_src, cont->machine_stack, VALUE, cont->machine_stack_size); } #ifdef __ia64 if (cont->machine_register_stack_src) { MEMCPY(cont->machine_register_stack_src, cont->machine_register_stack, VALUE, cont->machine_register_stack_size); } #endif ruby_longjmp(cont->jmpbuf, 1); }
static void cont_restore_1(rb_context_t *cont) { rb_thread_t *th = GET_THREAD(), *sth = &cont->saved_thread; /* restore thread context */ if (cont->type == CONTINUATION_CONTEXT) { /* continuation */ VALUE fib; th->fiber = sth->fiber; fib = th->fiber ? th->fiber : th->root_fiber; if (fib) { rb_fiber_t *fcont; GetFiberPtr(fib, fcont); th->stack_size = fcont->cont.saved_thread.stack_size; th->stack = fcont->cont.saved_thread.stack; } #ifdef CAPTURE_JUST_VALID_VM_STACK MEMCPY(th->stack, cont->vm_stack, VALUE, cont->vm_stack_slen); MEMCPY(th->stack + sth->stack_size - cont->vm_stack_clen, cont->vm_stack + cont->vm_stack_slen, VALUE, cont->vm_stack_clen); #else MEMCPY(th->stack, cont->vm_stack, VALUE, sth->stack_size); #endif } else { /* fiber */ th->stack = sth->stack; th->stack_size = sth->stack_size; th->local_storage = sth->local_storage; th->fiber = cont->self; } th->cfp = sth->cfp; th->safe_level = sth->safe_level; th->raised_flag = sth->raised_flag; th->state = sth->state; th->status = sth->status; th->tag = sth->tag; th->protect_tag = sth->protect_tag; th->errinfo = sth->errinfo; th->first_proc = sth->first_proc; /* restore machine stack */ #ifdef _M_AMD64 { /* workaround for x64 SEH */ jmp_buf buf; setjmp(buf); ((_JUMP_BUFFER*)(&cont->jmpbuf))->Frame = ((_JUMP_BUFFER*)(&buf))->Frame; } #endif if (cont->machine_stack_src) { FLUSH_REGISTER_WINDOWS; MEMCPY(cont->machine_stack_src, cont->machine_stack, VALUE, cont->machine_stack_size); } #ifdef __ia64 if (cont->machine_register_stack_src) { MEMCPY(cont->machine_register_stack_src, cont->machine_register_stack, VALUE, cont->machine_register_stack_size); } #endif ruby_longjmp(cont->jmpbuf, 1); }