Ruby
2.0.0p247(2013-06-27revision41674)
|
#include "ruby/ruby.h"
#include "internal.h"
#include "vm_core.h"
#include "gc.h"
#include "eval_intern.h"
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 |
typedef struct rb_fiber_struct | rb_fiber_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 FIBER_USE_NATIVE 0 |
Definition at line 38 of file cont.c.
Referenced by fiber_store().
#define GetContPtr | ( | obj, | |
ptr | |||
) | TypedData_Get_Struct((obj), rb_context_t, &cont_data_type, (ptr)) |
Definition at line 125 of file cont.c.
Referenced by rb_cont_call().
Definition at line 128 of file cont.c.
Referenced by cont_restore_thread(), fiber_link_join(), fiber_store(), fiber_switch(), rb_cont_call(), rb_fiber_alive_p(), rb_fiber_m_transfer(), rb_fiber_reset_root_local_storage(), rb_fiber_resume(), rb_fiber_start(), and return_fiber().
#define STACK_PAD_SIZE 1024 |
Referenced by cont_restore_0().
#define THREAD_MUST_BE_RUNNING | ( | th | ) |
Definition at line 135 of file cont.c.
Referenced by cont_capture(), cont_new(), and fiber_t_alloc().
typedef struct rb_context_struct rb_context_t |
typedef struct rb_fiber_struct rb_fiber_t |
enum context_type |
enum fiber_status |
Definition at line 430 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(), GET_THREAD(), rb_context_struct::jmpbuf, rb_thread_struct::mark_stack_len, MEMCPY, Qnil, rb_cContinuation, rb_exc_raise(), rb_vm_stack_to_heap(), ruby_setjmp, rb_context_struct::saved_thread, rb_context_struct::self, rb_control_frame_struct::sp, rb_thread_struct::stack, rb_thread_struct::stack_size, th, THREAD_MUST_BE_RUNNING, rb_context_struct::value, value, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.
Referenced by rb_callcc().
Definition at line 187 of file cont.c.
References rb_fiber_struct::cont, CONTINUATION_CONTEXT, GET_THREAD(), rb_context_struct::machine_stack, ptr, 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::self, rb_thread_struct::stack, rb_context_struct::type, and rb_context_struct::vm_stack.
Referenced by fiber_free().
|
static |
Definition at line 408 of file cont.c.
References cont_save_thread(), rb_thread_struct::local_storage, and rb_context_struct::saved_thread.
Referenced by cont_new(), and fiber_t_alloc().
Definition at line 140 of file cont.c.
References rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_thread_struct::fiber, GetThreadPtr, rb_context_struct::machine_stack, rb_context_struct::machine_stack_size, ptr, rb_gc_mark(), rb_gc_mark_locations, rb_thread_mark(), RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUNNING, rb_context_struct::saved_thread, rb_context_struct::self, rb_thread_struct::self, rb_thread_struct::stack_size, rb_fiber_struct::status, th, 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 fiber_mark().
Definition at line 240 of file cont.c.
References rb_fiber_struct::cont, rb_context_struct::machine_stack, rb_context_struct::machine_stack_size, n, ptr, rb_context_struct::saved_thread, 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 fiber_memsize().
|
static |
Definition at line 416 of file cont.c.
References rb_fiber_struct::cont, cont_init(), GET_THREAD(), rb_context_struct::self, th, THREAD_MUST_BE_RUNNING, and TypedData_Make_Struct.
Referenced by cont_capture().
|
static |
Definition at line 744 of file cont.c.
References ALLOCA_N, cont_restore_1(), end, rb_context_struct::machine_stack_size, rb_context_struct::machine_stack_src, and STACK_PAD_SIZE.
Referenced by fiber_switch(), and rb_cont_call().
|
static |
Definition at line 676 of file cont.c.
References buf, cont_restore_thread(), FLUSH_REGISTER_WINDOWS, rb_context_struct::jmpbuf, rb_context_struct::machine_stack, rb_context_struct::machine_stack_size, rb_context_struct::machine_stack_src, MEMCPY, and ruby_longjmp.
Referenced by cont_restore_0().
|
static |
Definition at line 472 of file cont.c.
References rb_thread_struct::cfp, rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_thread_struct::errinfo, rb_thread_struct::fiber, rb_thread_struct::first_proc, GET_THREAD(), GetFiberPtr, rb_thread_struct::local_storage, MEMCPY, rb_thread_struct::protect_tag, rb_thread_struct::raised_flag, rb_thread_struct::root_fiber, rb_thread_struct::root_lep, rb_thread_struct::root_svar, rb_thread_struct::safe_level, rb_context_struct::saved_thread, rb_context_struct::self, rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::state, rb_thread_struct::status, rb_vm_tag::tag, rb_thread_struct::tag, th, rb_context_struct::type, 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 344 of file cont.c.
References ALLOC_N, FLUSH_REGISTER_WINDOWS, rb_context_struct::machine_stack, rb_thread_struct::machine_stack_end, rb_context_struct::machine_stack_size, rb_context_struct::machine_stack_src, rb_thread_struct::machine_stack_start, MEMCPY, REALLOC_N, SET_MACHINE_STACK_END, and size.
Referenced by cont_capture(), and fiber_store().
|
static |
Definition at line 393 of file cont.c.
References rb_thread_struct::machine_stack_end, rb_thread_struct::machine_stack_start, rb_context_struct::saved_thread, and th.
Referenced by cont_init(), and fiber_store().
Definition at line 1007 of file cont.c.
References TypedData_Wrap_Struct.
Referenced by Init_Cont(), rb_fiber_new(), and root_fiber_alloc().
Definition at line 301 of file cont.c.
References rb_fiber_struct::cont, cont_free(), fiber_link_remove(), rb_thread_struct::local_storage, ptr, ROOT_FIBER_CONTEXT, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, rb_context_struct::saved_thread, st_free_table(), and rb_context_struct::type.
Definition at line 1037 of file cont.c.
References ALLOC_N, rb_control_frame_struct::block_iseq, rb_thread_struct::cfp, rb_fiber_struct::cont, rb_vm_struct::default_params, rb_control_frame_struct::ep, fiber_link_join(), fiber_t_alloc(), rb_vm_struct::fiber_vm_stack_size, rb_thread_struct::first_proc, rb_control_frame_struct::flag, rb_control_frame_struct::iseq, rb_context_struct::jmpbuf, rb_control_frame_struct::klass, rb_thread_struct::local_storage, rb_control_frame_struct::me, MEMCPY, rb_control_frame_struct::pc, rb_control_frame_struct::proc, proc, Qnil, rb_thread_struct::root_jmpbuf, rb_context_struct::saved_thread, rb_control_frame_struct::self, rb_control_frame_struct::sp, st_init_numtable(), rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::tag, rb_thread_struct::vm, VM_ENVVAL_BLOCK_PTR, and rb_context_struct::vm_stack.
Referenced by rb_fiber_init(), and rb_fiber_new().
|
static |
Definition at line 280 of file cont.c.
References GetFiberPtr, rb_fiber_struct::next_fiber, rb_fiber_struct::prev_fiber, and rb_fiber_current().
Referenced by fiber_init().
|
static |
Definition at line 294 of file cont.c.
References rb_fiber_struct::next_fiber, and rb_fiber_struct::prev_fiber.
Referenced by fiber_free().
Definition at line 268 of file cont.c.
References rb_fiber_struct::cont, cont_mark(), rb_fiber_struct::prev, ptr, rb_gc_mark(), RUBY_MARK_ENTER, and RUBY_MARK_LEAVE.
Definition at line 318 of file cont.c.
References rb_fiber_struct::cont, cont_memsize(), rb_thread_struct::local_storage, ptr, ROOT_FIBER_CONTEXT, rb_context_struct::saved_thread, size, st_memsize(), and rb_context_struct::type.
|
static |
Definition at line 1212 of file cont.c.
References rb_context_struct::argc, rb_fiber_struct::cont, cont_save_machine_stack(), cont_save_thread(), rb_thread_struct::fiber, FIBER_USE_NATIVE, GET_THREAD(), GetFiberPtr, rb_context_struct::jmpbuf, rb_context_struct::machine_stack, NULL, Qundef, rb_bug(), rb_exc_raise(), rb_thread_struct::root_fiber, root_fiber_alloc(), ruby_setjmp, rb_context_struct::self, and rb_context_struct::value.
Referenced by fiber_switch().
Definition at line 1267 of file cont.c.
References rb_context_struct::argc, argc, rb_fiber_struct::cont, cont_restore_0(), rb_thread_struct::fiber, fiber_store(), GET_THREAD(), GetFiberPtr, make_passing_arg(), NIL_P(), rb_fiber_struct::prev, rb_thread_struct::protect_tag, Qundef, rb_bug(), rb_eFiberError, rb_exc_new2(), rb_exc_raise(), rb_fiber_current(), rb_raise(), rb_thread_struct::root_fiber, RUBY_VM_CHECK_INTS, rb_context_struct::saved_thread, rb_thread_struct::self, rb_fiber_struct::status, TERMINATED, rb_thread_struct::trace_arg, rb_context_struct::value, and value.
Referenced by rb_fiber_resume(), and rb_fiber_transfer().
|
static |
Definition at line 1013 of file cont.c.
References ALLOC, rb_fiber_struct::cont, cont_init(), CREATED, DATA_PTR(), FIBER_CONTEXT, GET_THREAD(), memset(), rb_fiber_struct::prev, Qnil, rb_eRuntimeError, rb_raise(), rb_context_struct::self, rb_fiber_struct::status, THREAD_MUST_BE_RUNNING, and rb_context_struct::type.
Referenced by fiber_init(), and root_fiber_alloc().
Definition at line 1520 of file cont.c.
References fiber_alloc(), GET_THREAD(), info, rb_thread_struct::machine_stack_end, 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(), and SET_MACHINE_STACK_END.
Definition at line 875 of file cont.c.
References Qnil, and rb_ary_new4().
Referenced by fiber_switch(), and rb_cont_call().
NOINLINE | ( | static VALUE | cont_capturevolatile int *stat | ) |
NOINLINE | ( | NORETURN(static void cont_restore_1(rb_context_t *)) | ) |
NORETURN | ( | NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *)) | ) |
Definition at line 861 of file cont.c.
References cont_capture(), rb_yield(), and val.
Referenced by ruby_Init_Continuation_body().
Definition at line 904 of file cont.c.
References rb_context_struct::argc, argc, rb_fiber_struct::cont, cont_restore_0(), rb_thread_struct::fiber, GET_THREAD(), GetContPtr, GetFiberPtr, make_passing_arg(), rb_thread_struct::protect_tag, Qnil, rb_eRuntimeError, rb_raise(), 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 1392 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().
Definition at line 1200 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::fiber, GET_THREAD(), rb_thread_struct::root_fiber, root_fiber_alloc(), and rb_context_struct::self.
Referenced by fiber_link_join(), fiber_switch(), get_next_values(), next_init(), rb_fiber_s_current(), and return_fiber().
Definition at line 1084 of file cont.c.
References fiber_init(), and rb_block_proc().
Referenced by Init_Cont().
Definition at line 1466 of file cont.c.
References GetFiberPtr, rb_fiber_transfer(), and rb_fiber_struct::transfered.
Referenced by ruby_Init_Fiber_as_Coroutine().
Definition at line 1090 of file cont.c.
References fiber_alloc(), fiber_init(), func, rb_cFiber, and rb_proc_new().
Referenced by next_init().
Definition at line 1370 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::fiber, GetFiberPtr, GetThreadPtr, rb_thread_struct::local_storage, rb_thread_struct::root_fiber, rb_context_struct::saved_thread, and th.
Referenced by ruby_vm_destruct().
Definition at line 1348 of file cont.c.
References rb_fiber_struct::cont, fiber_switch(), GetFiberPtr, rb_fiber_struct::prev, Qnil, rb_eFiberError, rb_raise(), ROOT_FIBER_CONTEXT, rb_fiber_struct::transfered, and rb_context_struct::type.
Referenced by get_next_values(), and rb_fiber_m_resume().
Definition at line 1499 of file cont.c.
References rb_fiber_current().
Referenced by ruby_Init_Fiber_as_Coroutine().
Definition at line 1137 of file cont.c.
References rb_context_struct::argc, argc, args, argv, rb_proc_t::block, rb_fiber_struct::cont, rb_block_struct::ep, err, rb_thread_struct::errinfo, EXEC_TAG, rb_thread_struct::fiber, rb_thread_struct::first_proc, GET_THREAD(), GetFiberPtr, GetProcPtr, NIL_P(), proc, Qnil, RARRAY_PTR(), rb_bug(), rb_fiber_terminate(), rb_threadptr_pending_interrupt_enque(), rb_vm_ep_local_ep(), rb_vm_invoke_proc(), rb_vm_make_jump_tag_but_local_jump(), rb_thread_struct::root_lep, rb_thread_struct::root_svar, RUBY_VM_SET_INTERRUPT, RUNNING, rb_context_struct::saved_thread, state, rb_fiber_struct::status, TAG_FATAL, TAG_RAISE, TH_POP_TAG, TH_PUSH_TAG, and rb_context_struct::value.
|
static |
Definition at line 1121 of file cont.c.
References rb_fiber_struct::cont, rb_context_struct::machine_stack, rb_context_struct::machine_stack_size, NULL, rb_fiber_transfer(), return_fiber(), rb_fiber_struct::status, TERMINATED, rb_context_struct::value, and value.
Referenced by rb_fiber_start().
Definition at line 1342 of file cont.c.
References fiber_switch().
Referenced by rb_fiber_m_transfer(), rb_fiber_terminate(), and rb_fiber_yield().
Definition at line 1364 of file cont.c.
References rb_fiber_transfer(), and return_fiber().
Referenced by next_i(), next_ii(), and rb_fiber_s_yield().
Definition at line 333 of file cont.c.
References Qfalse, Qtrue, and rb_typeddata_is_kind_of().
Referenced by rb_objspace_call_finalizer().
Definition at line 1096 of file cont.c.
References GET_THREAD(), GetFiberPtr, NIL_P(), rb_fiber_struct::prev, Qnil, rb_eFiberError, rb_fiber_current(), rb_raise(), and rb_thread_struct::root_fiber.
Referenced by rb_fiber_terminate(), and rb_fiber_yield().
|
static |
Definition at line 1182 of file cont.c.
References rb_fiber_struct::cont, fiber_alloc(), fiber_t_alloc(), rb_fiber_struct::next_fiber, rb_fiber_struct::prev_fiber, rb_cFiber, ROOT_FIBER_CONTEXT, RUNNING, rb_fiber_struct::status, and rb_context_struct::type.
Referenced by fiber_store(), and rb_fiber_current().
Definition at line 1548 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().
Definition at line 1559 of file cont.c.
References rb_cFiber, rb_define_method(), rb_define_singleton_method(), rb_fiber_alive_p(), rb_fiber_m_transfer(), and rb_fiber_s_current().
Referenced by Init_fiber().
|
static |
|
static |
|
static |
Definition at line 121 of file cont.c.
Referenced by cont_capture(), and ruby_Init_Continuation_body().
|
static |
Definition at line 122 of file cont.c.
Referenced by Init_Cont(), rb_fiber_new(), root_fiber_alloc(), and ruby_Init_Fiber_as_Coroutine().
|
static |
Definition at line 123 of file cont.c.
Referenced by fiber_switch(), Init_Cont(), rb_fiber_resume(), and return_fiber().