Ruby
2.4.2p198(2017-09-14revision59899)
|
Go to the source code of this file.
Data Structures | |
struct | rb_context_struct |
struct | rb_fiber_struct |
Macros | |
#define | FIBER_USE_NATIVE 0 |
#define | CAPTURE_JUST_VALID_VM_STACK 1 |
#define | GetContPtr(obj, ptr) TypedData_Get_Struct((obj), rb_context_t, &cont_data_type, (ptr)) |
#define | GetFiberPtr(obj, ptr) |
#define | THREAD_MUST_BE_RUNNING(th) |
#define | STACK_PAD_SIZE 1024 |
Typedefs | |
typedef struct rb_context_struct | rb_context_t |
Enumerations | |
enum | context_type { CONTINUATION_CONTEXT = 0, FIBER_CONTEXT = 1, ROOT_FIBER_CONTEXT = 2 } |
enum | fiber_status { CREATED, RUNNING, TERMINATED } |
Variables | |
static const rb_data_type_t | cont_data_type |
static const rb_data_type_t | fiber_data_type |
static VALUE | rb_cContinuation |
static VALUE | rb_cFiber |
static VALUE | rb_eFiberError |
#define GetContPtr | ( | obj, | |
ptr | |||
) | TypedData_Get_Struct((obj), rb_context_t, &cont_data_type, (ptr)) |
Definition at line 156 of file cont.c.
Referenced by rb_cont_call().
#define GetFiberPtr | ( | obj, | |
ptr | |||
) |
Definition at line 159 of file cont.c.
Referenced by rb_fiber_alive_p(), rb_fiber_m_transfer(), rb_fiber_resume(), and rb_fiber_transfer().
#define STACK_PAD_SIZE 1024 |
Referenced by cont_restore_0().
#define THREAD_MUST_BE_RUNNING | ( | th | ) |
Definition at line 166 of file cont.c.
Referenced by cont_capture(), cont_new(), and fiber_t_alloc().
typedef struct rb_context_struct rb_context_t |
enum context_type |
enum fiber_status |
|
static |
Definition at line 473 of file cont.c.
References ALLOC_N, rb_context_struct::argc, rb_thread_struct::cfp, rb_fiber_struct::cont, cont_new(), cont_save_machine_stack(), rb_context_struct::ensure_array, rb_thread_struct::ensure_list, rb_ensure_list::entry, GET_THREAD, rb_context_struct::jmpbuf, rb_ensure_entry::marker, MEMCPY, rb_ensure_list::next, NULL, Qnil, rb_ary_tmp_new(), rb_cContinuation, rb_exc_raise(), rb_vm_stack_to_heap(), ruby_setjmp, rb_context_struct::saved_thread, rb_context_struct::self, size, rb_control_frame_struct::sp, rb_thread_struct::stack, rb_thread_struct::stack_size, THREAD_MUST_BE_RUNNING, rb_context_struct::value, VAR_INITIALIZED, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.
Referenced by rb_callcc().
|
static |
Definition at line 219 of file cont.c.
References rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_context_struct::ensure_array, rb_thread_struct::fiber, GET_THREAD, rb_context_struct::machine, rb_bug(), ROOT_FIBER_CONTEXT, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, RUBY_FREE_UNLESS_NULL, ruby_xfree(), rb_context_struct::saved_thread, rb_context_struct::stack, rb_thread_struct::stack, rb_context_struct::type, and rb_context_struct::vm_stack.
Referenced by cont_save_machine_stack(), and fiber_free().
|
static |
Definition at line 446 of file cont.c.
References cont_save_thread(), rb_thread_struct::fiber, rb_thread_struct::local_storage, rb_thread_struct::local_storage_recursive_hash, rb_thread_struct::local_storage_recursive_hash_for_trace, rb_thread_struct::machine, Qnil, rb_context_struct::saved_thread, rb_thread_struct::self, and rb_thread_struct::stack_maxsize.
Referenced by cont_new(), and fiber_t_alloc().
|
static |
Definition at line 171 of file cont.c.
References rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_thread_struct::fiber, GetThreadPtr, rb_context_struct::machine, rb_gc_mark(), rb_gc_mark_locations(), rb_thread_mark(), RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUNNING, rb_context_struct::saved_thread, rb_thread_struct::self, rb_context_struct::stack, rb_context_struct::stack_size, rb_thread_struct::stack_size, rb_fiber_struct::status, rb_context_struct::type, rb_context_struct::value, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.
Referenced by cont_save_machine_stack(), and fiber_mark().
|
static |
Definition at line 274 of file cont.c.
References rb_fiber_struct::cont, rb_context_struct::machine, rb_context_struct::saved_thread, size, rb_context_struct::stack, rb_context_struct::stack_size, rb_thread_struct::stack_size, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.
Referenced by cont_save_machine_stack(), and fiber_memsize().
|
static |
Definition at line 459 of file cont.c.
References rb_fiber_struct::cont, cont_init(), GET_THREAD, rb_context_struct::self, THREAD_MUST_BE_RUNNING, and TypedData_Make_Struct.
Referenced by cont_capture().
|
static |
Definition at line 813 of file cont.c.
References ALLOCA_N, cont_restore_1(), rb_context_struct::machine, STACK_PAD_SIZE, rb_context_struct::stack_size, and rb_context_struct::stack_src.
Referenced by cont_restore_1(), fiber_store(), fiber_switch(), and rb_cont_call().
|
static |
Definition at line 745 of file cont.c.
References buf, C, rb_fiber_struct::cont, cont_restore_0(), cont_restore_thread(), f, FLUSH_REGISTER_WINDOWS, rb_context_struct::jmpbuf, rb_context_struct::machine, MEMCPY, NOINLINE(), NORETURN(), ruby_longjmp, rb_context_struct::stack, rb_context_struct::stack_size, and rb_context_struct::stack_src.
Referenced by cont_restore_0(), and cont_restore_thread().
|
inlinestatic |
Definition at line 531 of file cont.c.
References rb_thread_struct::cfp, rb_fiber_struct::cont, cont_restore_1(), CONTINUATION_CONTEXT, rb_vm_struct::default_params, rb_thread_struct::ensure_list, rb_thread_struct::errinfo, errno, rb_thread_struct::fiber, rb_vm_struct::fiber_machine_stack_size, rb_thread_struct::first_proc, GET_THREAD, rb_thread_struct::local_storage, rb_thread_struct::local_storage_recursive_hash, rb_thread_struct::local_storage_recursive_hash_for_trace, rb_context_struct::machine, rb_thread_struct::machine, MEMCPY, NOINLINE(), NORETURN(), NULL, rb_thread_struct::protect_tag, rb_thread_struct::raised_flag, rb_bug(), rb_eFiberError, rb_fiber_start(), rb_gc(), rb_raise(), rb_thread_struct::root_fiber, rb_thread_struct::root_lep, rb_thread_struct::root_svar, RUNNING, rb_thread_struct::safe_level, rb_context_struct::saved_thread, SET_MACHINE_STACK_END, size, rb_context_struct::stack, rb_thread_struct::stack, STACK_DIR_UPPER, rb_thread_struct::stack_end, STACK_GROW_DIR_DETECTION, rb_thread_struct::stack_maxsize, rb_context_struct::stack_size, rb_thread_struct::stack_size, rb_thread_struct::stack_start, STACK_UPPER, rb_thread_struct::state, rb_fiber_struct::status, rb_thread_struct::status, strerror(), rb_vm_tag::tag, rb_thread_struct::tag, TERMINATED, THREAD_RUNNABLE, rb_context_struct::type, rb_thread_struct::vm, VM_ASSERT, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.
Referenced by cont_restore_1().
|
static |
Definition at line 362 of file cont.c.
References ALLOC_N, cont_free(), cont_mark(), cont_memsize(), FLUSH_REGISTER_WINDOWS, rb_context_struct::machine, rb_thread_struct::machine, MEMCPY, REALLOC_N, RUBY_TYPED_FREE_IMMEDIATELY, SET_MACHINE_STACK_END, size, rb_context_struct::stack, rb_thread_struct::stack_end, rb_context_struct::stack_size, rb_context_struct::stack_src, and rb_thread_struct::stack_start.
Referenced by cont_capture(), and fiber_store().
|
inlinestatic |
Definition at line 412 of file cont.c.
References rb_thread_struct::cfp, rb_thread_struct::ensure_list, rb_thread_struct::errinfo, rb_thread_struct::first_proc, rb_thread_struct::local_storage, rb_thread_struct::machine, rb_thread_struct::protect_tag, rb_thread_struct::raised_flag, rb_thread_struct::root_lep, rb_thread_struct::root_svar, rb_thread_struct::safe_level, rb_context_struct::saved_thread, rb_thread_struct::stack, rb_thread_struct::stack_end, rb_thread_struct::stack_size, rb_thread_struct::stack_start, rb_thread_struct::state, rb_thread_struct::status, rb_thread_struct::tag, and rb_thread_struct::trace_arg.
Referenced by cont_init(), and fiber_store().
Definition at line 1167 of file cont.c.
References TypedData_Wrap_Struct.
Referenced by Init_Cont(), rb_fiber_new(), and root_fiber_alloc().
|
inlinestatic |
Definition at line 1326 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::fiber, GET_THREAD, NULL, root_fiber_alloc(), rb_context_struct::saved_thread, and rb_thread_struct::stack.
Referenced by fiber_switch(), rb_fiber_current(), and return_fiber().
|
static |
Definition at line 320 of file cont.c.
References rb_fiber_struct::cont, cont_free(), rb_thread_struct::local_storage, ROOT_FIBER_CONTEXT, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, rb_context_struct::saved_thread, st_free_table, and rb_context_struct::type.
Referenced by rb_cont_call().
Definition at line 1208 of file cont.c.
References ALLOC_N, rb_thread_struct::cfp, rb_fiber_struct::cont, rb_vm_struct::default_params, fiber_t_alloc(), rb_vm_struct::fiber_vm_stack_size, rb_thread_struct::first_proc, GET_THREAD, rb_context_struct::jmpbuf, rb_thread_struct::local_storage, rb_thread_struct::local_storage_recursive_hash, rb_thread_struct::local_storage_recursive_hash_for_trace, MEMCPY, NULL, Qnil, rb_vm_push_frame(), rb_thread_struct::root_jmpbuf, rb_context_struct::saved_thread, st_init_numtable, rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::tag, rb_thread_struct::vm, VM_BLOCK_HANDLER_NONE, VM_ENV_FLAG_LOCAL, VM_FRAME_FLAG_CFRAME, VM_FRAME_FLAG_FINISH, VM_FRAME_MAGIC_DUMMY, and rb_context_struct::vm_stack.
Referenced by rb_fiber_init(), and rb_fiber_new().
|
static |
Definition at line 308 of file cont.c.
References rb_fiber_struct::cont, cont_mark(), rb_fiber_struct::prev, rb_fiber_mark_self(), RUBY_MARK_ENTER, and RUBY_MARK_LEAVE.
Referenced by rb_cont_call().
|
static |
Definition at line 336 of file cont.c.
References rb_fiber_struct::cont, cont_memsize(), rb_thread_struct::local_storage, NULL, ROOT_FIBER_CONTEXT, rb_context_struct::saved_thread, size, st_memsize(), and rb_context_struct::type.
Referenced by rb_cont_call().
|
inlinestatic |
Definition at line 1364 of file cont.c.
References rb_context_struct::argc, rb_fiber_struct::cont, cont_restore_0(), cont_save_machine_stack(), cont_save_thread(), rb_thread_struct::fiber, rb_context_struct::jmpbuf, rb_context_struct::machine, NULL, Qundef, rb_bug(), rb_exc_raise(), root_fiber_alloc(), ruby_setjmp, rb_context_struct::stack, and rb_context_struct::value.
Referenced by fiber_switch().
|
inlinestatic |
Definition at line 1424 of file cont.c.
References rb_context_struct::argc, rb_fiber_struct::cont, cont_restore_0(), EXEC_EVENT_HOOK, rb_thread_struct::fiber, fiber_current(), fiber_store(), GET_THREAD, make_passing_arg(), rb_fiber_struct::prev, rb_thread_struct::protect_tag, Qnil, rb_eFiberError, rb_exc_new2, rb_exc_raise(), rb_raise(), rb_thread_struct::root_fiber, RUBY_EVENT_FIBER_SWITCH, RUBY_VM_CHECK_INTS, rb_context_struct::saved_thread, rb_thread_struct::self, rb_fiber_struct::status, TERMINATED, rb_thread_struct::trace_arg, and rb_context_struct::value.
Referenced by get_event_id(), rb_fiber_m_transfer(), rb_fiber_resume(), rb_fiber_terminate(), rb_fiber_transfer(), rb_fiber_yield(), and symbol2event_flag().
|
static |
Definition at line 1173 of file cont.c.
References rb_fiber_struct::cont, cont_init(), CREATED, DATA_PTR, FIBER_CONTEXT, GET_THREAD, NULL, rb_fiber_struct::prev, rb_eRuntimeError, rb_raise(), rb_vm_push_frame(), rb_context_struct::self, rb_fiber_struct::status, THREAD_MUST_BE_RUNNING, rb_context_struct::type, and ZALLOC.
Referenced by fiber_init(), and root_fiber_alloc().
void Init_Cont | ( | void | ) |
Definition at line 1677 of file cont.c.
References fiber_alloc(), GET_THREAD, rb_thread_struct::machine, rb_cFiber, rb_cObject, rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_eFiberError, rb_eStandardError, rb_fiber_init(), rb_fiber_m_resume(), rb_fiber_s_yield(), RUBY_SYMBOL_EXPORT_BEGIN, SET_MACHINE_STACK_END, and rb_thread_struct::stack_end.
Definition at line 962 of file cont.c.
References Qnil, and rb_ary_new4.
Referenced by fiber_switch(), and rb_cont_call().
NOINLINE | ( | static VALUE | cont_capturevolatile int *volatile stat | ) |
Referenced by cont_restore_1(), and cont_restore_thread().
NOINLINE | ( | NORETURN(static void cont_restore_1(rb_context_t *)) | ) |
NORETURN | ( | NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *)) | ) |
Referenced by cont_restore_1(), and cont_restore_thread().
Definition at line 948 of file cont.c.
References cont_capture(), rb_yield(), and val.
Referenced by ruby_Init_Continuation_body().
Definition at line 1065 of file cont.c.
References rb_context_struct::argc, rb_fiber_struct::cont, cont_restore_0(), rb_context_struct::ensure_array, rb_thread_struct::ensure_list, rb_thread_struct::fiber, fiber_free(), fiber_mark(), fiber_memsize(), GET_THREAD, GetContPtr, make_passing_arg(), rb_thread_struct::protect_tag, Qnil, rb_eRuntimeError, rb_raise(), rollback_ensure_stack(), rb_context_struct::saved_thread, rb_thread_struct::self, rb_thread_struct::trace_arg, and rb_context_struct::value.
Referenced by ruby_Init_Continuation_body().
Definition at line 1549 of file cont.c.
References GetFiberPtr, Qfalse, Qtrue, rb_fiber_struct::status, and TERMINATED.
Referenced by get_next_values(), and ruby_Init_Fiber_as_Coroutine().
VALUE rb_fiber_current | ( | void | ) |
Definition at line 1358 of file cont.c.
References rb_fiber_struct::cont, fiber_current(), and rb_context_struct::self.
Referenced by get_next_values(), next_init(), and rb_fiber_s_current().
Definition at line 1252 of file cont.c.
References fiber_init(), and rb_block_proc().
Referenced by Init_Cont().
Definition at line 1623 of file cont.c.
References fiber_switch(), GetFiberPtr, and rb_fiber_struct::transferred.
Referenced by ruby_Init_Fiber_as_Coroutine().
void rb_fiber_mark_self | ( | rb_fiber_t * | fib | ) |
Definition at line 301 of file cont.c.
References rb_fiber_struct::cont, rb_gc_mark(), and rb_context_struct::self.
Referenced by fiber_mark(), rb_thread_mark(), and rb_thread_recycle_stack_release().
Definition at line 1258 of file cont.c.
References fiber_alloc(), fiber_init(), func, rb_cFiber, rb_fiber_terminate(), and rb_proc_new().
Referenced by next_init().
void rb_fiber_reset_root_local_storage | ( | VALUE | thval | ) |
Definition at line 1529 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::fiber, GetThreadPtr, rb_thread_struct::local_storage, rb_thread_struct::root_fiber, and rb_context_struct::saved_thread.
Referenced by ruby_vm_destruct().
Definition at line 1507 of file cont.c.
References rb_fiber_struct::cont, fiber_switch(), GetFiberPtr, rb_fiber_struct::prev, rb_eFiberError, rb_raise(), ROOT_FIBER_CONTEXT, rb_fiber_struct::transferred, and rb_context_struct::type.
Referenced by get_next_values(), and rb_fiber_m_resume().
Definition at line 1656 of file cont.c.
References rb_fiber_current().
Referenced by ruby_Init_Fiber_as_Coroutine().
void rb_fiber_start | ( | void | ) |
Definition at line 1266 of file cont.c.
References rb_context_struct::argc, argv, err, rb_thread_struct::errinfo, EXEC_EVENT_HOOK, EXEC_TAG, rb_thread_struct::fiber, rb_thread_struct::first_proc, GET_THREAD, GetProcPtr, NIL_P, Qfalse, Qnil, RARRAY_CONST_PTR, rb_bug(), rb_fiber_terminate(), rb_threadptr_pending_interrupt_enque(), rb_vm_invoke_proc(), rb_vm_make_jump_tag_but_local_jump(), rb_vm_proc_local_ep(), rb_thread_struct::root_lep, rb_thread_struct::root_svar, RUBY_EVENT_FIBER_SWITCH, RUBY_VM_SET_INTERRUPT, RUNNING, rb_context_struct::saved_thread, rb_thread_struct::self, rb_fiber_struct::status, TAG_FATAL, TAG_RAISE, TH_POP_TAG, TH_PUSH_TAG, rb_context_struct::value, VAR_FROM_MEMORY, and VM_BLOCK_HANDLER_NONE.
Referenced by cont_restore_thread().
|
static |
Definition at line 1490 of file cont.c.
References rb_fiber_struct::cont, fiber_switch(), rb_context_struct::machine, NULL, return_fiber(), rb_context_struct::stack, rb_context_struct::stack_size, rb_fiber_struct::status, TERMINATED, and rb_context_struct::value.
Referenced by rb_fiber_new(), and rb_fiber_start().
Definition at line 1482 of file cont.c.
References fiber_switch(), and GetFiberPtr.
Definition at line 1523 of file cont.c.
References fiber_switch(), and return_fiber().
Referenced by next_i(), next_ii(), and rb_fiber_s_yield().
Definition at line 351 of file cont.c.
References Qfalse, Qtrue, and rb_typeddata_is_kind_of().
Referenced by rb_objspace_call_finalizer().
rb_control_frame_t* rb_vm_push_frame | ( | rb_thread_t * | th, |
const rb_iseq_t * | iseq, | ||
VALUE | type, | ||
VALUE | self, | ||
VALUE | specval, | ||
VALUE | cref_or_me, | ||
const VALUE * | pc, | ||
VALUE * | sp, | ||
int | local_size, | ||
int | stack_max | ||
) |
Definition at line 226 of file vm_insnhelper.c.
References vm_push_frame().
Referenced by fiber_init(), and fiber_t_alloc().
|
inlinestatic |
Definition at line 1338 of file cont.c.
References fiber_current(), GET_THREAD, NULL, rb_fiber_struct::prev, rb_eFiberError, and rb_raise().
Referenced by rb_fiber_terminate(), and rb_fiber_yield().
|
inlinestatic |
Definition at line 998 of file cont.c.
References ANYARGS, rb_ensure_entry::data2, rb_ensure_entry::e_proc, rb_ensure_list::entry, func, lookup_rollback_func(), rb_ensure_entry::marker, rb_ensure_list::next, Qundef, rb_eRuntimeError, and rb_raise().
Referenced by rb_cont_call().
|
static |
Definition at line 1308 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::fiber, fiber_alloc(), fiber_t_alloc(), rb_cFiber, rb_thread_struct::root_fiber, ROOT_FIBER_CONTEXT, RUNNING, rb_fiber_struct::status, and rb_context_struct::type.
Referenced by fiber_current(), and fiber_store().
RUBY_SYMBOL_EXPORT_BEGIN void ruby_Init_Continuation_body | ( | void | ) |
Definition at line 1703 of file cont.c.
References CLASS_OF, rb_callcc(), rb_cContinuation, rb_cObject, rb_cont_call(), rb_define_class(), rb_define_global_function(), rb_define_method(), rb_undef_alloc_func(), and rb_undef_method().
Referenced by Init_continuation().
void ruby_Init_Fiber_as_Coroutine | ( | void | ) |
Definition at line 1714 of file cont.c.
References rb_cFiber, rb_define_method(), rb_define_singleton_method(), rb_fiber_alive_p(), rb_fiber_m_transfer(), rb_fiber_s_current(), and RUBY_SYMBOL_EXPORT_END.
Referenced by Init_fiber().
void ruby_register_rollback_func_for_ensure | ( | VALUE(*)(ANYARGS) | ensure_func, |
VALUE(*)(ANYARGS) | rollback_func | ||
) |
Definition at line 977 of file cont.c.
References GET_VM, NULL, st_data_t, st_init_numtable, st_insert, and UNLIKELY.
Referenced by Init_Hash().
|
static |
|
static |
|
static |
Definition at line 152 of file cont.c.
Referenced by cont_capture(), and ruby_Init_Continuation_body().
|
static |
Definition at line 153 of file cont.c.
Referenced by Init_Cont(), rb_fiber_new(), root_fiber_alloc(), and ruby_Init_Fiber_as_Coroutine().
|
static |
Definition at line 154 of file cont.c.
Referenced by cont_restore_thread(), fiber_switch(), Init_Cont(), rb_fiber_resume(), and return_fiber().