Ruby
3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
|
#include "ruby/internal/config.h"
#include <unistd.h>
#include <sys/mman.h>
#include <COROUTINE_H>
#include "eval_intern.h"
#include "gc.h"
#include "internal.h"
#include "internal/cont.h"
#include "internal/proc.h"
#include "internal/warnings.h"
#include "ruby/fiber/scheduler.h"
#include "mjit.h"
#include "vm_core.h"
#include "id_table.h"
#include "ractor_core.h"
Go to the source code of this file.
Data Structures | |
struct | cont_saved_vm_stack |
struct | fiber_pool_stack |
struct | fiber_pool_vacancy |
struct | fiber_pool_allocation |
struct | fiber_pool |
struct | rb_context_struct |
struct | rb_fiber_struct |
Macros | |
#define | RB_PAGE_SIZE (pagesize) |
#define | RB_PAGE_MASK (~(RB_PAGE_SIZE - 1)) |
#define | CAPTURE_JUST_VALID_VM_STACK 1 |
#define | FIBER_POOL_INITIAL_SIZE 32 |
#define | FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 1024 |
#define | FIBER_CREATED_P(fiber) ((fiber)->status == FIBER_CREATED) |
#define | FIBER_RESUMED_P(fiber) ((fiber)->status == FIBER_RESUMED) |
#define | FIBER_SUSPENDED_P(fiber) ((fiber)->status == FIBER_SUSPENDED) |
#define | FIBER_TERMINATED_P(fiber) ((fiber)->status == FIBER_TERMINATED) |
#define | FIBER_RUNNABLE_P(fiber) (FIBER_CREATED_P(fiber) || FIBER_SUSPENDED_P(fiber)) |
#define | FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON) |
#define | ERRNOMSG strerror(errno) |
#define | THREAD_MUST_BE_RUNNING(th) |
#define | STACK_PAD_SIZE 1024 |
Typedefs | |
typedef struct rb_context_struct | rb_context_t |
typedef VALUE | e_proc(VALUE) |
Enumerations | |
enum | context_type { CONTINUATION_CONTEXT = 0, FIBER_CONTEXT = 1 } |
enum | fiber_status { FIBER_CREATED, FIBER_RESUMED, FIBER_SUSPENDED, FIBER_TERMINATED } |
#define FIBER_CREATED_P | ( | fiber | ) | ((fiber)->status == FIBER_CREATED) |
#define FIBER_RESUMED_P | ( | fiber | ) | ((fiber)->status == FIBER_RESUMED) |
#define FIBER_RUNNABLE_P | ( | fiber | ) | (FIBER_CREATED_P(fiber) || FIBER_SUSPENDED_P(fiber)) |
#define FIBER_SUSPENDED_P | ( | fiber | ) | ((fiber)->status == FIBER_SUSPENDED) |
#define FIBER_TERMINATED_P | ( | fiber | ) | ((fiber)->status == FIBER_TERMINATED) |
#define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1)) |
#define STACK_PAD_SIZE 1024 |
#define THREAD_MUST_BE_RUNNING | ( | th | ) |
typedef struct rb_context_struct rb_context_t |
enum context_type |
enum fiber_status |
void Init_Cont | ( | void | ) |
Definition at line 3050 of file cont.c.
References rb_vm_struct::default_params, rb_vm_struct::fiber_machine_stack_size, rb_vm_struct::fiber_vm_stack_size, GET_THREAD, rb_thread_struct::vm, and fiber_pool::vm_stack_size.
NOINLINE | ( | NORETURN(static void cont_restore_1(rb_context_t *)) | ) |
NOINLINE | ( | static VALUE | cont_capturevolatile int *volatile stat | ) |
NOINLINE | ( | static void | fiber_setcontextrb_fiber_t *new_fiber, rb_fiber_t *old_fiber | ) |
NORETURN | ( | NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *)) | ) |
NORETURN | ( | static VALUE | rb_cont_callint argc, VALUE *argv, VALUE contval | ) |
Definition at line 2473 of file cont.c.
References FIBER_TERMINATED_P.
void rb_fiber_close | ( | rb_fiber_t * | fiber | ) |
void rb_fiber_init_mjit_cont | ( | struct rb_fiber_struct * | fiber | ) |
void rb_fiber_mark_self | ( | const rb_fiber_t * | fiber | ) |
Definition at line 1015 of file cont.c.
References rb_fiber_struct::cont, rb_execution_context_mark(), rb_gc_mark_movable(), rb_context_struct::saved_ec, and rb_context_struct::self.
VALUE rb_fiber_new | ( | rb_block_call_func_t | func, |
VALUE | obj | ||
) |
void rb_fiber_reset_root_local_storage | ( | rb_thread_t * | th | ) |
Definition at line 2457 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::ec, rb_execution_context_struct::fiber_ptr, rb_execution_context_struct::local_storage, rb_thread_struct::root_fiber, and rb_context_struct::saved_ec.
Referenced by ruby_vm_destruct().
Definition at line 2439 of file cont.c.
References argc, argv, rb_fiber_resume_kw(), and RB_NO_KEYWORDS.
Definition at line 2408 of file cont.c.
Referenced by rb_fiber_resume().
void rb_fiber_start | ( | rb_fiber_t * | fiber | ) |
Definition at line 2038 of file cont.c.
References rb_context_struct::argc, argc, argv, rb_fiber_struct::blocking, rb_thread_struct::blocking, rb_fiber_struct::cont, rb_thread_struct::ec, EC_EXEC_TAG, EC_POP_TAG, EC_PUSH_TAG, err, rb_execution_context_struct::errinfo, EXEC_EVENT_HOOK, FIBER_RESUMED_P, rb_fiber_struct::first_proc, GET_EC, GetProcPtr, rb_context_struct::kw_splat, Qfalse, Qnil, RARRAY_CONST_PTR, rb_threadptr_pending_interrupt_enque(), rb_vm_invoke_proc(), rb_vm_make_jump_tag_but_local_jump(), rb_vm_proc_local_ep(), rb_execution_context_struct::root_lep, rb_execution_context_struct::root_svar, RUBY_EVENT_FIBER_SWITCH, rb_context_struct::saved_ec, rb_thread_struct::self, TAG_FATAL, TAG_NONE, TAG_RAISE, rb_execution_context_struct::thread_ptr, TRUE, rb_context_struct::value, VAR_FROM_MEMORY, VM_ASSERT, and VM_BLOCK_HANDLER_NONE.
rb_thread_t* rb_fiber_threadptr | ( | const rb_fiber_t * | fiber | ) |
Definition at line 876 of file cont.c.
References rb_fiber_struct::cont, rb_context_struct::saved_ec, and rb_execution_context_struct::thread_ptr.
void rb_fiber_update_self | ( | rb_fiber_t * | fiber | ) |
Definition at line 1004 of file cont.c.
References rb_fiber_struct::cont, rb_execution_context_update(), rb_gc_location(), rb_context_struct::saved_ec, and rb_context_struct::self.
unsigned int rb_fiberptr_blocking | ( | struct rb_fiber_struct * | fiber | ) |
Definition at line 1179 of file cont.c.
References rb_fiber_struct::blocking.
VALUE rb_fiberptr_self | ( | struct rb_fiber_struct * | fiber | ) |
Definition at line 1173 of file cont.c.
References rb_fiber_struct::cont, and rb_context_struct::self.
Definition at line 1084 of file cont.c.
References rb_typeddata_is_kind_of(), and RBOOL.
void rb_threadptr_root_fiber_release | ( | rb_thread_t * | th | ) |
Definition at line 2129 of file cont.c.
References rb_fiber_struct::cont, rb_thread_struct::ec, FIBER_CONTEXT, rb_execution_context_struct::fiber_ptr, GET_EC, rb_thread_struct::root_fiber, rb_context_struct::self, rb_context_struct::type, and VM_ASSERT.
void rb_threadptr_root_fiber_setup | ( | rb_thread_t * | th | ) |
Definition at line 2110 of file cont.c.
References rb_fiber_struct::blocking, rb_fiber_struct::cont, FIBER_CONTEXT, rb_execution_context_struct::fiber_ptr, MEMZERO, rb_bug(), ruby_mimmalloc(), rb_context_struct::saved_ec, strerror(), rb_execution_context_struct::thread_ptr, and rb_context_struct::type.
void rb_threadptr_root_fiber_terminate | ( | rb_thread_t * | th | ) |
Definition at line 2149 of file cont.c.
References rb_thread_struct::ec, rb_execution_context_struct::fiber_ptr, FIBER_TERMINATED, and rb_ec_clear_vm_stack().
void ruby_Init_Continuation_body | ( | void | ) |
Definition at line 3122 of file cont.c.
Referenced by Init_continuation().
Definition at line 1580 of file cont.c.
References GET_VM, NULL, st_init_numtable(), st_insert(), and UNLIKELY.