vm.c File Reference
`#include "ruby/ruby.h"`
`#include "ruby/vm.h"`
`#include "ruby/st.h"`
`#include "ruby/encoding.h"`
`#include "internal.h"`
`#include "gc.h"`
`#include "vm_core.h"`
`#include "iseq.h"`
`#include "eval_intern.h"`
`#include "vm_insnhelper.h"`
`#include "vm_insnhelper.c"`
`#include "vm_exec.h"`
`#include "vm_exec.c"`
`#include "vm_method.c"`
`#include "vm_eval.c"`
`#include <assert.h>`

Go to the source code of this file.

## Macros

#define | BUFSIZE 0x100
#define | PROCDEBUG 0
#define | ENV_IN_HEAP_P(th, env) (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
#define | ENV_VAL(env) ((env)[1])
#define | OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_, ruby_vm_redefined_flag[bop] = 0)
#define | C(k) add_opt_method(rb_c##k, mid, bop)
#define | vm_free 0
#define | USE_THREAD_DATA_RECYCLE 1
#define | RECYCLE_MAX 64
#define | thread_data_type ruby_threadptr_data_type
#define | REWIND_CFP(expr)

## Functions

static void | thread_free (void *ptr)
void | vm_analysis_operand (int insn, int n, VALUE op)
void | vm_analysis_register (int reg, int isset)
void | vm_analysis_insn (int insn)
RUBY_FUNC_EXPORTED VALUE | rb_vm_make_env_object (rb_thread_t *th, rb_control_frame_t *cfp)
RUBY_FUNC_EXPORTED int | rb_vm_get_sourceline (const rb_control_frame_t *cfp)
void | rb_vm_change_state (void)
static void | vm_clear_global_method_cache (void)
static void | vm_clear_all_inline_method_cache (void)
static void | vm_clear_all_cache ()
void | rb_vm_inc_const_missing_count (void)
static VALUE | rb_vm_set_finish_env (rb_thread_t *th)
static void | vm_set_top_stack (rb_thread_t *th, VALUE iseqval)
static void | vm_set_eval_stack (rb_thread_t *th, VALUE iseqval, const NODE *cref)
static void | vm_set_main_stack (rb_thread_t *th, VALUE iseqval)
rb_control_frame_t * | rb_vm_get_ruby_level_next_cfp (rb_thread_t *th, rb_control_frame_t *cfp)
static rb_control_frame_t * | vm_get_ruby_level_caller_cfp (rb_thread_t *th, rb_control_frame_t *cfp)
void | ruby_vm_at_exit (void(*func)(rb_vm_t *))
| ruby_vm_at_exit registers a function func to be invoked when a VM passed away. More...
static void | ruby_vm_run_at_exit_hooks (rb_vm_t *vm)
static void | env_mark (void *const ptr)
static void | env_free (void *const ptr)
static size_t | env_memsize (const void *ptr)
static VALUE | env_alloc (void)
static VALUE | check_env_value (VALUE envval)
static int | check_env (rb_env_t *const env)
static VALUE | vm_make_env_each (rb_thread_t *const th, rb_control_frame_t *const cfp, VALUE *envptr, VALUE *const endptr)
static int | collect_local_variables_in_iseq (rb_iseq_t *iseq, const VALUE ary)
static int | collect_local_variables_in_env (rb_env_t *env, const VALUE ary)
static int | vm_collect_local_variables_in_heap (rb_thread_t *th, VALUE *dfp, VALUE ary)
void | rb_vm_rewrite_dfp_in_errinfo (rb_thread_t *th, rb_control_frame_t *cfp)
void | rb_vm_stack_to_heap (rb_thread_t *th)
static VALUE | vm_make_proc_from_block (rb_thread_t *th, rb_block_t *block)
VALUE | rb_vm_make_proc (rb_thread_t *th, const rb_block_t *block, VALUE klass)
static VALUE | invoke_block_from_c (rb_thread_t *th, const rb_block_t *block, VALUE self, int argc, const VALUE *argv, const rb_block_t *blockptr, const NODE *cref)
static const rb_block_t * | check_block (rb_thread_t *th)
static VALUE | vm_yield_with_cref (rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref)
static VALUE | vm_yield (rb_thread_t *th, int argc, const VALUE *argv)
VALUE | rb_vm_invoke_proc (rb_thread_t *th, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, const rb_block_t *blockptr)
static rb_control_frame_t * | vm_normal_frame (rb_thread_t *th, rb_control_frame_t *cfp)
static VALUE | vm_cfp_svar_get (rb_thread_t *th, rb_control_frame_t *cfp, VALUE key)
static void | vm_cfp_svar_set (rb_thread_t *th, rb_control_frame_t *cfp, VALUE key, const VALUE val)
static VALUE | vm_svar_get (VALUE key)
static void | vm_svar_set (VALUE key, VALUE val)
VALUE | rb_backref_get (void)
void | rb_backref_set (VALUE val)
VALUE | rb_lastline_get (void)
void | rb_lastline_set (VALUE val)
static int | vm_backtrace_each (rb_thread_t *th, int lev, void(*init)(void *), rb_backtrace_iter_func *iter, void *arg)
static void | vm_backtrace_alloc (void *arg)
static int | vm_backtrace_push (void *arg, VALUE file, int line_no, VALUE name)
static VALUE | vm_backtrace (rb_thread_t *th, int lev)
const char * | rb_sourcefile (void)
int | rb_sourceline (void)
NODE * | rb_vm_cref (void)
VALUE | rb_vm_cbase (void)
static VALUE | make_localjump_error (const char *mesg, VALUE value, int reason)
void | rb_vm_localjump_error (const char *mesg, VALUE value, int reason)
VALUE | rb_vm_make_jump_tag_but_local_jump (int state, VALUE val)
void | rb_vm_jump_tag_but_local_jump (int state, VALUE val)
| NORETURN (static void vm_iter_break(rb_thread_t *th))
static void | vm_iter_break (rb_thread_t *th)
void | rb_iter_break (void)
static void | rb_vm_check_redefinition_opt_method (const rb_method_entry_t *me)
static void | add_opt_method (VALUE klass, ID mid, VALUE bop)
static void | vm_init_redefined_flag (void)
static VALUE | vm_exec (rb_thread_t *th)
VALUE | rb_iseq_eval (VALUE iseqval)
VALUE | rb_iseq_eval_main (VALUE iseqval)
int | rb_thread_method_id_and_class (rb_thread_t *th, ID *idp, VALUE *klassp)
int | rb_frame_method_id_and_class (ID *idp, VALUE *klassp)
VALUE | rb_thread_current_status (const rb_thread_t *th)
VALUE | rb_vm_call_cfunc (VALUE recv, VALUE(*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename)
static int | vm_mark_each_thread_func (st_data_t key, st_data_t value, st_data_t dummy)
static void | mark_event_hooks (rb_event_hook_t *hook)
void | rb_vm_mark (void *ptr)
int | ruby_vm_destruct (rb_vm_t *vm)
static size_t | vm_memsize (const void *ptr)
static void | vm_init2 (rb_vm_t *vm)
static VALUE * | thread_recycle_stack (size_t size)
void | rb_thread_recycle_stack_release (VALUE *stack)
void | rb_thread_mark (void *ptr)
static size_t | thread_memsize (const void *ptr)
VALUE | rb_obj_is_thread (VALUE obj)
static VALUE | thread_alloc (VALUE klass)
static void | th_init (rb_thread_t *th, VALUE self)
static VALUE | ruby_thread_init (VALUE self)
VALUE | rb_thread_alloc (VALUE klass)
static void | vm_define_method (rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, rb_num_t is_singleton, NODE *cref)
static VALUE | m_core_define_method (VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
static VALUE | m_core_define_singleton_method (VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
static VALUE | m_core_set_method_alias (VALUE self, VALUE cbase, VALUE sym1, VALUE sym2)
static VALUE | m_core_set_variable_alias (VALUE self, VALUE sym1, VALUE sym2)
static VALUE | m_core_undef_method (VALUE self, VALUE cbase, VALUE sym)
static VALUE | m_core_set_postexe (VALUE self, VALUE iseqval)
static VALUE | sdr (void)
static VALUE | nsdr (void)
void | Init_VM (void)
void | rb_vm_set_progname (VALUE filename)
struct rb_objspace * | rb_objspace_alloc (void)
void | Init_BareVM (void)
static VALUE | main_to_s (VALUE obj)
VALUE | rb_vm_top_self (void)
void | Init_top_self (void)
VALUE * | ruby_vm_verbose_ptr (rb_vm_t *vm)
VALUE * | ruby_vm_debug_ptr (rb_vm_t *vm)
VALUE * | rb_ruby_verbose_ptr (void)
VALUE * | rb_ruby_debug_ptr (void)

## Variables

VALUE | rb_cRubyVM
VALUE | rb_cThread
VALUE | rb_cEnv
VALUE | rb_mRubyVMFrozenCore
VALUE | ruby_vm_const_missing_count = 0
char | ruby_vm_redefined_flag [BOP_LAST_]
rb_thread_t * | ruby_current_thread = 0
rb_vm_t * | ruby_current_vm = 0
static const rb_data_type_t | env_data_type
static st_table * | vm_opt_method_table = 0
static const rb_data_type_t | vm_data_type
static VALUE * | thread_recycle_stack_slot [RECYCLE_MAX]
static int | thread_recycle_stack_count = 0
const rb_data_type_t | ruby_threadptr_data_type
VALUE * | rb_gc_stack_start
size_t | rb_gc_stack_maxsize

## Macro Definition Documentation

#define BUFSIZE 0x100

Definition at line 32 of file vm.c.

#define C | ( |  | k | ) | add_opt_method(rb_c##k, mid, bop)

#define ENV_IN_HEAP_P | ( |  | th,
|  |  | env
| ) |  | (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))

Definition at line 233 of file vm.c.

Referenced by rb_vm_rewrite_dfp_in_errinfo(), vm_collect_local_variables_in_heap(), and vm_make_env_each().

#define ENV_VAL | ( |  | env | ) | ((env)[1])

Definition at line 235 of file vm.c.

Referenced by vm_collect_local_variables_in_heap(), and vm_make_env_each().

#define OP | ( |  | mid_,
|  |  | bop_
| ) |  | (mid = id##mid_, bop = BOP_##bop_, ruby_vm_redefined_flag[bop] = 0)

Referenced by vm_init_redefined_flag().

#define PROCDEBUG 0

Definition at line 33 of file vm.c.

Referenced by rb_vm_make_env_object(), and rb_vm_make_proc().

#define RECYCLE_MAX 64

Definition at line 1664 of file vm.c.

Referenced by rb_thread_recycle_stack_release().

#define REWIND_CFP | ( |  | expr | ) |

Value:
do { \
rb_thread_t *th__ = GET_THREAD(); \
th__->cfp++; expr; th__->cfp--; \
} while (0)

Definition at line 1955 of file vm.c.

Referenced by m_core_define_method(), m_core_define_singleton_method(), m_core_set_method_alias(), m_core_set_postexe(), m_core_set_variable_alias(), and m_core_undef_method().

#define thread_data_type ruby_threadptr_data_type

Definition at line 1829 of file vm.c.

Referenced by Init_VM(), rb_obj_is_thread(), and thread_alloc().

#define USE_THREAD_DATA_RECYCLE 1

Definition at line 1661 of file vm.c.

#define vm_free 0

Definition at line 1598 of file vm.c.

## Function Documentation

static void add_opt_method | ( | VALUE | klass,
|  | ID | mid,
|  | VALUE | bop
| ) |  |

static

Definition at line 1039 of file vm.c.

References rb_method_entry_struct::def, rb_bug(), rb_id2name(), RCLASS_M_TBL, st_insert, st_lookup, rb_method_definition_struct::type, and VM_METHOD_TYPE_CFUNC.

static const rb_block_t* check_block | ( | rb_thread_t * | th | ) |

inline static

Definition at line 632 of file vm.c.

References rb_thread_struct::cfp, GC_GUARDED_PTR_REF, rb_control_frame_t::lfp, Qnil, and rb_vm_localjump_error().

Referenced by vm_yield(), and vm_yield_with_cref().

static int check_env | ( | rb_env_t *const | env | ) |

static

Definition at line 313 of file vm.c.

References rb_env_t::block, check_env_value(), rb_block_struct::dfp, dp, and rb_block_struct::lfp.

Referenced by check_env_value().

static VALUE check_env_value | ( | VALUE | envval | ) |

static

Definition at line 334 of file vm.c.

References check_env(), env, GetEnvPtr, Qnil, and rb_bug().

Referenced by check_env(), rb_vm_make_env_object(), and rb_vm_make_proc().

static int collect_local_variables_in_env | ( | rb_env_t * | env,
|  | const VALUE | ary
| ) |  |

static

Definition at line 448 of file vm.c.

References rb_env_t::block, collect_local_variables_in_iseq(), GetEnvPtr, rb_block_struct::iseq, and rb_env_t::prev_envval.

Referenced by vm_collect_local_variables_in_heap().

static int collect_local_variables_in_iseq | ( | rb_iseq_t * | iseq,
|  | const VALUE | ary
| ) |  |

static

Definition at line 434 of file vm.c.

References i, ID2SYM, rb_iseq_struct::local_table, rb_iseq_struct::local_table_size, rb_ary_push(), and rb_is_local_id().

Referenced by collect_local_variables_in_env().

static VALUE env_alloc | ( | void |  | ) |

static

Definition at line 299 of file vm.c.

References rb_env_t::block, env, rb_env_t::env, rb_block_struct::iseq, rb_env_t::prev_envval, rb_cEnv, and TypedData_Make_Struct.

Referenced by vm_make_env_each().

static void env_free | ( | void *const | ptr | ) |

static

Definition at line 268 of file vm.c.

References env, rb_env_t::env, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, RUBY_FREE_UNLESS_NULL, and ruby_xfree().

static void env_mark | ( | void *const | ptr | ) |

static

Definition at line 238 of file vm.c.

References rb_env_t::block, BUILTIN_TYPE, env, rb_env_t::env, rb_env_t::env_size, rb_block_struct::iseq, rb_env_t::prev_envval, rb_block_struct::proc, rb_gc_mark_locations, RUBY_GC_INFO, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_UNLESS_NULL, rb_iseq_struct::self, rb_block_struct::self, and T_NODE.

static size_t env_memsize | ( | const void * | ptr | ) |

static

Definition at line 280 of file vm.c.

References env, rb_env_t::env, rb_env_t::env_size, and size.

void Init_BareVM | ( | void |  | ) |

Definition at line 2202 of file vm.c.

References EXIT_FAILURE, Init_native_thread(), malloc(), MEMZERO, rb_vm_struct::objspace, rb_objspace_alloc(), rb_thread_set_current_raw, ruby_thread_init_stack(), th_init(), rb_thread_struct::vm, and vm_init2().

Referenced by ruby_init().

void Init_top_self | ( | void |  | ) |

Definition at line 2242 of file vm.c.

References GET_VM, main_to_s(), rb_vm_struct::mark_object_ary, rb_ary_tmp_new(), rb_cObject, rb_define_singleton_method(), rb_obj_alloc(), rb_vm_top_self(), and rb_vm_struct::top_self.

void Init_VM | ( | void |  | ) |

Definition at line 2074 of file vm.c.

References rb_thread_struct::cfp, CLASS_OF, GET_THREAD, GetISeqPtr, id_core_define_method, id_core_define_singleton_method, id_core_set_method_alias, id_core_set_postexe, id_core_set_variable_alias, id_core_undef_method, rb_control_frame_t::iseq, rb_iseq_struct::iseq_encoded, rb_vm_struct::living_threads, m_core_define_method(), m_core_define_singleton_method(), m_core_set_method_alias(), m_core_set_postexe(), m_core_set_variable_alias(), m_core_undef_method(), rb_vm_struct::main_thread, nsdr(), rb_control_frame_t::pc, Qnil, rb_ary_new(), rb_ary_push(), rb_binding_new(), rb_cBasicObject, rb_cEnv, rb_class_new(), rb_cObject, rb_cRubyVM, rb_cThread, rb_define_class(), rb_define_class_under(), rb_define_const(), rb_define_global_const(), rb_define_method_id(), rb_define_singleton_method(), rb_gc_register_mark_object(), rb_hash_new(), rb_insns_name_array(), rb_iseq_new(), rb_mRubyVMFrozenCore, rb_obj_freeze(), rb_singleton_class(), rb_str_new2(), rb_thread_set_current, rb_undef_alloc_func(), rb_undef_method(), rb_vm_top_self(), RBASIC, ruby_current_vm, rb_vm_struct::running_thread, sdr(), rb_vm_struct::self, rb_control_frame_t::self, rb_thread_struct::self, st_init_numtable, st_insert, T_ICLASS, thread_data_type, rb_thread_struct::thread_id, rb_thread_struct::top_self, rb_thread_struct::top_wrapper, TypedData_Wrap_Struct, rb_thread_struct::vm, and vm_init_redefined_flag().

static VALUE invoke_block_from_c | ( | rb_thread_t * | th,
|  | const rb_block_t * | block,
|  | VALUE | self,
|  | int | argc,
|  | const VALUE * | argv,
|  | const rb_block_t * | blockptr,
|  | const NODE * | cref
| ) |  |

inline static

Definition at line 586 of file vm.c.

References rb_iseq_struct::arg_size, argc, block_proc_is_lambda(), BUILTIN_TYPE, rb_thread_struct::cfp, CHECK_STACK_OVERFLOW, rb_control_frame_t::dfp, rb_block_struct::dfp, GC_GUARDED_PTR, i, rb_block_struct::iseq, rb_iseq_struct::iseq_encoded, rb_block_struct::lfp, rb_iseq_struct::local_size, rb_control_frame_t::me, rb_thread_struct::passed_block, rb_thread_struct::passed_me, rb_block_struct::proc, Qnil, rb_vm_set_finish_env(), rb_control_frame_t::sp, SPECIAL_CONST_P, rb_iseq_struct::stack_max, T_NODE, type, vm_exec(), VM_FRAME_MAGIC_BLOCK, VM_FRAME_MAGIC_LAMBDA, vm_push_frame(), vm_yield_setup_args(), and vm_yield_with_cfunc().

Referenced by rb_vm_invoke_proc(), vm_yield(), and vm_yield_with_cref().

static VALUE m_core_define_method | ( | VALUE | self,
|  | VALUE | cbase,
|  | VALUE | sym,
|  | VALUE | iseqval
| ) |  |

static

Definition at line 1961 of file vm.c.

References GET_THREAD, Qnil, rb_vm_cref(), REWIND_CFP, SYM2ID, and vm_define_method().

Referenced by Init_VM().

static VALUE m_core_define_singleton_method | ( | VALUE | self,
|  | VALUE | cbase,
|  | VALUE | sym,
|  | VALUE | iseqval
| ) |  |

static

Definition at line 1970 of file vm.c.

References GET_THREAD, Qnil, rb_vm_cref(), REWIND_CFP, SYM2ID, and vm_define_method().

Referenced by Init_VM().

static VALUE m_core_set_method_alias | ( | VALUE | self,
|  | VALUE | cbase,
|  | VALUE | sym1,
|  | VALUE | sym2
| ) |  |

static

Definition at line 1979 of file vm.c.

References Qnil, rb_alias(), REWIND_CFP, and SYM2ID.

Referenced by Init_VM().

static VALUE m_core_set_postexe | ( | VALUE | self,
|  | VALUE | iseqval
| ) |  |

static

Definition at line 2007 of file vm.c.

References rb_thread_struct::cfp, GET_THREAD, GetISeqPtr, rb_block_struct::iseq, rb_block_struct::proc, Qnil, rb_bug(), rb_call_end_proc(), rb_cProc, rb_set_end_proc(), rb_vm_get_ruby_level_next_cfp(), rb_vm_make_proc(), REWIND_CFP, and RUBY_VM_GET_BLOCK_PTR_IN_CFP.

Referenced by Init_VM().

static VALUE m_core_set_variable_alias | ( | VALUE | self,
|  | VALUE | sym1,
|  | VALUE | sym2
| ) |  |

static

Definition at line 1988 of file vm.c.

References Qnil, rb_alias_variable(), REWIND_CFP, and SYM2ID.

Referenced by Init_VM().

static VALUE m_core_undef_method | ( | VALUE | self,
|  | VALUE | cbase,
|  | VALUE | sym
| ) |  |

static

Definition at line 1997 of file vm.c.

References INC_VM_STATE_VERSION, Qnil, rb_undef(), REWIND_CFP, and SYM2ID.

Referenced by Init_VM().

static VALUE main_to_s | ( | VALUE | obj | ) |

static

Definition at line 2230 of file vm.c.

References rb_str_new2().

Referenced by Init_top_self().

static VALUE make_localjump_error | ( | const char * | mesg,
|  | VALUE | value,
|  | int | reason
| ) |  |

static

Definition at line 924 of file vm.c.

References CONST_ID, id, ID2SYM, rb_eLocalJumpError, rb_exc_new2(), rb_iv_set(), TAG_BREAK, TAG_NEXT, TAG_REDO, TAG_RETRY, and TAG_RETURN.

Referenced by rb_vm_localjump_error(), and rb_vm_make_jump_tag_but_local_jump().

static void mark_event_hooks | ( | rb_event_hook_t * | hook | ) |

static

Definition at line 1555 of file vm.c.

References rb_event_hook_struct::data, rb_event_hook_struct::next, and rb_gc_mark().

Referenced by rb_thread_mark(), and rb_vm_mark().

NORETURN | ( | static void | vm_iter_breakrb_thread_t *th | ) |

static VALUE nsdr | ( | void |  | ) |

static

Definition at line 2050 of file vm.c.

References free(), i, rb_ary_new(), rb_ary_push(), rb_memerror(), and rb_str_new2().

Referenced by Init_VM().

VALUE rb_backref_get | ( | void |  | ) |

Definition at line 727 of file vm.c.

References vm_svar_get().

Referenced by date__httpdate(), date__iso8601(), date__jisx0301(), date__parse(), date__rfc2822(), date__rfc3339(), date__strptime_internal(), date__xmlschema(), last_match_getter(), last_paren_match_getter(), match_getter(), nucomp_s_convert(), nurat_s_convert(), postmatch_getter(), prematch_getter(), rb_reg_match_m(), rb_reg_s_last_match(), rb_reg_search(), rb_str_rpartition(), rb_str_split_m(), rb_str_sub_bang(), rb_str_subpat(), rb_str_subpat_set(), scan_once(), str_gsub(), string_to_c(), and string_to_r().

void rb_backref_set | ( | VALUE | val | ) |

Definition at line 733 of file vm.c.

References vm_svar_set().

Referenced by date__httpdate(), date__iso8601(), date__jisx0301(), date__parse(), date__rfc2822(), date__rfc3339(), date__strptime_internal(), date__xmlschema(), match_setter(), nucomp_s_convert(), nurat_s_convert(), rb_reg_eqq(), rb_reg_match2(), rb_reg_match_m(), rb_reg_search(), rb_str_index_m(), rb_str_rindex_m(), reg_match_pos(), string_to_c(), and string_to_r().

int rb_frame_method_id_and_class | ( | ID * | idp,
|  | VALUE * | klassp
| ) |  |

Definition at line 1497 of file vm.c.

References GET_THREAD, and rb_thread_method_id_and_class().

VALUE rb_iseq_eval | ( | VALUE | iseqval | ) |

Definition at line 1439 of file vm.c.

References GET_THREAD, vm_exec(), and vm_set_top_stack().

Referenced by iseq_eval(), prelude_eval(), and rb_load_internal().

VALUE rb_iseq_eval_main | ( | VALUE | iseqval | ) |

Definition at line 1453 of file vm.c.

References GET_THREAD, vm_exec(), and vm_set_main_stack().

Referenced by ruby_exec_internal().

void rb_iter_break | ( | void |  | ) |

Definition at line 1018 of file vm.c.

References GET_THREAD, and vm_iter_break().

Referenced by DEFINE_ENUMFUNCS(), find_i(), find_index_i(), find_index_iter_i(), first_i(), lexer_i(), member_i(), take_i(), and take_while_i().

VALUE rb_lastline_get | ( | void |  | ) |

Definition at line 739 of file vm.c.

References vm_svar_get().

Referenced by Init_IO(), rb_io_print(), rb_reg_match2(), and uscore_get().

void rb_lastline_set | ( | VALUE | val | ) |

Definition at line 745 of file vm.c.

References vm_svar_set().

Referenced by argf_gets(), Init_IO(), rb_f_chomp(), rb_f_chop(), rb_f_gsub(), rb_f_sub(), rb_gets(), rb_gzreader_gets(), rb_io_gets_m(), and strio_gets().

VALUE rb_obj_is_thread | ( | VALUE | obj | ) |

Definition at line 1840 of file vm.c.

References Qfalse, Qtrue, rb_typeddata_is_kind_of(), and thread_data_type.

Referenced by rb_objspace_call_finalizer().

struct rb_objspace* rb_objspace_alloc | ( | void |  | ) |

read

Definition at line 410 of file gc.c.

References initial_malloc_limit, malloc(), malloc_limit, ruby_gc_stress, and ruby_initial_gc_stress.

Referenced by Init_BareVM().

VALUE* rb_ruby_debug_ptr | ( | void |  | ) |

Definition at line 2272 of file vm.c.

References GET_VM, and ruby_vm_debug_ptr().

VALUE* rb_ruby_verbose_ptr | ( | void |  | ) |

Definition at line 2266 of file vm.c.

References GET_VM, and ruby_vm_verbose_ptr().

const char* rb_sourcefile | ( | void |  | ) |

Definition at line 858 of file vm.c.

References rb_thread_struct::cfp, rb_iseq_struct::filename, GET_THREAD, rb_control_frame_t::iseq, rb_vm_get_ruby_level_next_cfp(), and RSTRING_PTR.

int rb_sourceline | ( | void |  | ) |

Definition at line 872 of file vm.c.

References rb_thread_struct::cfp, GET_THREAD, rb_vm_get_ruby_level_next_cfp(), and rb_vm_get_sourceline().

Referenced by call_trace_proc(), err_position(), error_pos(), error_print(), eval_string_with_cref(), rb_bug(), rb_exec(), rb_newobj(), setup_exception(), and update_coverage().

VALUE rb_thread_alloc | ( | VALUE | klass | ) |

Definition at line 1904 of file vm.c.

References ruby_thread_init(), and thread_alloc().

Referenced by rb_thread_create(), thread_s_new(), and thread_start().

VALUE rb_thread_current_status | ( | const rb_thread_t * | th | ) |

Definition at line 1503 of file vm.c.

References rb_thread_struct::cfp, rb_method_entry_struct::def, rb_iseq_struct::filename, iseq_catch_table_entry::iseq, rb_control_frame_t::iseq, rb_method_entry_struct::klass, rb_control_frame_t::me, rb_iseq_struct::name, rb_method_definition_struct::original_id, rb_control_frame_t::pc, Qnil, rb_class2name(), rb_id2name(), rb_sprintf(), rb_vm_get_sourceline(), and RSTRING_PTR.

void rb_thread_mark | ( | void * | ptr | ) |

Definition at line 1706 of file vm.c.

References rb_thread_struct::cfp, rb_thread_struct::errinfo, rb_thread_struct::event_hooks, rb_thread_struct::fiber, rb_thread_struct::first_args, rb_thread_struct::first_proc, GET_THREAD, rb_control_frame_t::iseq, rb_thread_struct::last_status, rb_thread_struct::local_storage, rb_thread_struct::local_svar, rb_thread_struct::locking_mutex, rb_thread_struct::machine_regs, rb_thread_struct::machine_stack_end, rb_thread_struct::machine_stack_start, mark_event_hooks(), rb_thread_struct::mark_stack_len, rb_control_frame_t::me, NULL, rb_control_frame_t::proc, rb_objspace::ptr, rb_gc_mark(), rb_gc_mark_locations, rb_gc_mark_machine_stack(), rb_mark_tbl(), rb_thread_struct::root_fiber, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_UNLESS_NULL, RUBY_VM_NORMAL_ISEQ_P, RUBY_VM_PREVIOUS_CONTROL_FRAME, rb_iseq_struct::self, rb_control_frame_t::self, rb_control_frame_t::sp, rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::stat_insn_usage, rb_thread_struct::thgroup, rb_thread_struct::thrown_errinfo, rb_thread_struct::top_self, rb_thread_struct::top_wrapper, and rb_thread_struct::value.

Referenced by cont_mark().

int rb_thread_method_id_and_class | ( | rb_thread_t * | th,
|  | ID * | idp,
|  | VALUE * | klassp
| ) |  |

Definition at line 1467 of file vm.c.

References rb_thread_struct::cfp, CONST_ID, rb_method_entry_struct::def, rb_iseq_struct::defined_method_id, iseq_catch_table_entry::iseq, rb_control_frame_t::iseq, rb_method_entry_struct::klass, rb_iseq_struct::klass, rb_iseq_struct::local_iseq, rb_control_frame_t::me, rb_method_definition_struct::original_id, rb_iseq_struct::parent_iseq, and RUBY_VM_IFUNC_P.

Referenced by call_trace_proc(), and rb_frame_method_id_and_class().

void rb_thread_recycle_stack_release | ( | VALUE * | stack | ) |

Definition at line 1684 of file vm.c.

References RECYCLE_MAX, and ruby_xfree().

Referenced by thread_start_func_2().

VALUE rb_vm_call_cfunc | ( | VALUE | recv,
|  | VALUE(*)(VALUE) | func,
|  | VALUE | arg,
|  | const rb_block_t * | blockptr,
|  | VALUE | filename
| ) |  |

Definition at line 1527 of file vm.c.

References arg, rb_thread_struct::cfp, DATA_PTR, GET_THREAD, Qnil, rb_iseq_new(), rb_control_frame_t::sp, VM_FRAME_MAGIC_TOP, vm_pop_frame(), and vm_push_frame().

Referenced by rb_require_safe(), and ruby_init_ext().

VALUE rb_vm_cbase | ( | void |  | ) |

Definition at line 910 of file vm.c.

References rb_thread_struct::cfp, rb_control_frame_t::dfp, GET_THREAD, rb_control_frame_t::iseq, rb_control_frame_t::lfp, rb_eRuntimeError, rb_raise(), rb_vm_get_ruby_level_next_cfp(), and vm_get_cbase().

Referenced by rb_f_autoload(), rb_f_autoload_p(), and rb_undef().

void rb_vm_change_state | ( | void |  | ) |

Definition at line 63 of file vm.c.

References INC_VM_STATE_VERSION.

Referenced by rb_clear_cache(), rb_clear_cache_by_class(), rb_clear_cache_by_id(), rb_clear_cache_for_undef(), rb_const_remove(), and rb_const_set().

static void rb_vm_check_redefinition_opt_method | ( | const rb_method_entry_t * | me | ) |

static

Definition at line 1028 of file vm.c.

References rb_method_entry_struct::def, ruby_vm_redefined_flag, st_lookup, rb_method_definition_struct::type, and VM_METHOD_TYPE_CFUNC.

NODE* rb_vm_cref | ( | void |  | ) |

Definition at line 886 of file vm.c.

References rb_thread_struct::cfp, rb_control_frame_t::dfp, GET_THREAD, rb_control_frame_t::iseq, rb_control_frame_t::lfp, rb_eRuntimeError, rb_raise(), rb_vm_get_ruby_level_next_cfp(), and vm_get_cref().

Referenced by m_core_define_method(), m_core_define_singleton_method(), rb_mod_nesting(), and rb_mod_s_constants().

rb_control_frame_t* rb_vm_get_ruby_level_next_cfp | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp
| ) |  |

Definition at line 169 of file vm.c.

References rb_control_frame_t::iseq, RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P, RUBY_VM_NORMAL_ISEQ_P, and RUBY_VM_PREVIOUS_CONTROL_FRAME.

Referenced by eval_string_with_cref(), m_core_set_postexe(), rb_add_method(), rb_binding_new(), rb_sourcefile(), rb_sourceline(), rb_vm_cbase(), rb_vm_cref(), and rb_vm_stack_to_heap().

int rb_vm_get_sourceline | ( | const rb_control_frame_t * | cfp | ) |

Definition at line 753 of file vm.c.

References i, rb_iseq_struct::insn_info_size, rb_iseq_struct::insn_info_table, rb_control_frame_t::iseq, rb_iseq_struct::iseq_encoded, iseq_insn_info_entry::line_no, rb_control_frame_t::pc, iseq_insn_info_entry::position, and RUBY_VM_NORMAL_ISEQ_P.

Referenced by control_frame_dump(), rb_add_method(), rb_binding_new(), rb_sourceline(), rb_thread_current_status(), and vm_backtrace_each().

void rb_vm_inc_const_missing_count | ( | void |  | ) |

Definition at line 88 of file vm.c.

References ruby_vm_const_missing_count.

Referenced by rb_const_get_0().

VALUE rb_vm_invoke_proc | ( | rb_thread_t * | th,
|  | rb_proc_t * | proc,
|  | VALUE | self,
|  | int | argc,
|  | const VALUE * | argv,
|  | const rb_block_t * | blockptr
| ) |  |

Definition at line 658 of file vm.c.

References rb_proc_t::block, EXEC_TAG, invoke_block_from_c(), rb_proc_t::is_from_method, JUMP_TAG, Qundef, rb_thread_struct::safe_level, rb_proc_t::safe_level, TH_POP_TAG, and TH_PUSH_TAG.

Referenced by proc_call(), rb_fiber_start(), rb_proc_call(), rb_proc_call_with_block(), thread_start_func_2(), vm_call0(), vm_call_bmethod(), and vm_call_method().

void rb_vm_jump_tag_but_local_jump | ( | int | state,
|  | VALUE | val
| ) |  |

Definition at line 995 of file vm.c.

References JUMP_TAG, Qnil, rb_exc_raise(), and rb_vm_make_jump_tag_but_local_jump().

Referenced by rb_eval_cmd(), and rb_load_internal().

void rb_vm_localjump_error | ( | const char * | mesg,
|  | VALUE | value,
|  | int | reason
| ) |  |

Definition at line 956 of file vm.c.

References make_localjump_error(), and rb_exc_raise().

Referenced by check_block(), rb_need_block(), vm_invoke_block(), and vm_throw().

VALUE rb_vm_make_env_object | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp
| ) |  |

Definition at line 473 of file vm.c.

References check_env_value(), rb_control_frame_t::dfp, rb_control_frame_t::lfp, PROCDEBUG, RUBY_VM_PREVIOUS_CONTROL_FRAME, VM_FRAME_MAGIC_FINISH, VM_FRAME_TYPE, and vm_make_env_each().

Referenced by eval_string_with_cref(), rb_binding_new(), rb_vm_make_proc(), rb_vm_stack_to_heap(), and vm_set_main_stack().

VALUE rb_vm_make_jump_tag_but_local_jump | ( | int | state,
|  | VALUE | val
| ) |  |

Definition at line 963 of file vm.c.

References GET_THREAD, make_localjump_error(), Qnil, Qundef, result, TAG_BREAK, TAG_NEXT, TAG_REDO, TAG_RETRY, and TAG_RETURN.

Referenced by rb_fiber_start(), rb_vm_jump_tag_but_local_jump(), and thread_join().

VALUE rb_vm_make_proc | ( | rb_thread_t * | th,
|  | const rb_block_t * | block,
|  | VALUE | klass
| ) |  |

Definition at line 535 of file vm.c.

References rb_proc_t::block, rb_proc_t::blockprocval, check_env_value(), rb_block_struct::dfp, rb_proc_t::envval, GC_GUARDED_PTR, GC_GUARDED_PTR_REF, GetProcPtr, rb_block_struct::iseq, rb_control_frame_t::lfp, rb_block_struct::lfp, p, rb_block_struct::proc, PROCDEBUG, rb_bug(), rb_proc_alloc(), rb_vm_make_env_object(), RUBY_VM_GET_CFP_FROM_BLOCK_PTR, rb_thread_struct::safe_level, rb_proc_t::safe_level, rb_block_struct::self, rb_thread_struct::stack, rb_thread_struct::stack_size, vm_make_proc_from_block(), and VMDEBUG.

Referenced by m_core_set_postexe(), proc_new(), vm_callee_setup_arg_complex(), vm_make_proc_from_block(), vm_yield_setup_block_args(), and vm_yield_with_cfunc().

void rb_vm_mark | ( | void * | ptr | ) |

Definition at line 1564 of file vm.c.

References rb_vm_struct::cmd, rb_vm_struct::coverages, rb_vm_struct::event_hooks, i, rb_vm_struct::living_threads, rb_vm_struct::load_path, rb_vm_struct::loaded_features, rb_vm_struct::loading_table, mark_event_hooks(), rb_vm_struct::mark_object_ary, rb_gc_mark(), rb_gc_mark_locations, rb_mark_tbl(), RUBY_GC_INFO, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_UNLESS_NULL, RUBY_NSIG, ruby_special_error_count, rb_vm_struct::special_exceptions, st_foreach, rb_vm_struct::thgroup_default, rb_vm_struct::top_self, rb_vm_struct::trap_list, and vm_mark_each_thread_func().

Referenced by gc_marks().

void rb_vm_rewrite_dfp_in_errinfo | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp
| ) |  |

Definition at line 492 of file vm.c.

References CLASS_OF, rb_control_frame_t::dfp, rb_env_t::env, ENV_IN_HEAP_P, GET_THROWOBJ_CATCH_POINT, GetEnvPtr, rb_control_frame_t::iseq, rb_env_t::local_size, rb_cEnv, RB_TYPE_P, RUBY_VM_NORMAL_ISEQ_P, SET_THROWOBJ_CATCH_POINT, T_NODE, and rb_iseq_struct::type.

Referenced by proc_new(), and vm_make_env_each().

static VALUE rb_vm_set_finish_env | ( | rb_thread_t * | th | ) |

inline static

Definition at line 96 of file vm.c.

References rb_thread_struct::cfp, finish_insn_seq, rb_control_frame_t::lfp, rb_control_frame_t::pc, Qnil, Qtrue, rb_control_frame_t::sp, VM_FRAME_MAGIC_FINISH, and vm_push_frame().

Referenced by invoke_block_from_c(), vm_set_eval_stack(), and vm_set_top_stack().

void rb_vm_set_progname | ( | VALUE | filename | ) |

Definition at line 2189 of file vm.c.

References rb_iseq_struct::filename, GET_VM, rb_control_frame_t::iseq, rb_thread_struct::stack, and rb_thread_struct::stack_size.

Referenced by load_file_internal(), process_options(), and ruby_script().

void rb_vm_stack_to_heap | ( | rb_thread_t * | th | ) |

Definition at line 514 of file vm.c.

References rb_thread_struct::cfp, rb_vm_get_ruby_level_next_cfp(), rb_vm_make_env_object(), and RUBY_VM_PREVIOUS_CONTROL_FRAME.

Referenced by cont_capture().

VALUE rb_vm_top_self | ( | void |  | ) |

Definition at line 2236 of file vm.c.

References GET_VM.

Referenced by Init_eval(), Init_eval_method(), Init_top_self(), Init_VM(), rb_eval_cmd(), rb_eval_string(), rb_eval_string_wrap(), rb_load_internal(), rb_require_safe(), require_libraries(), ruby_init_ext(), and ruby_thread_init().

static VALUE ruby_thread_init | ( | VALUE | self | ) |

static

Definition at line 1889 of file vm.c.

References GET_THREAD, GetThreadPtr, rb_vm_top_self(), th_init(), rb_thread_struct::top_self, rb_thread_struct::top_wrapper, and rb_thread_struct::vm.

Referenced by rb_thread_alloc().

void ruby_vm_at_exit | ( | void(*)(ruby_vm_t *) | func | ) |

ruby_vm_at_exit registers a function func to be invoked when a VM passed away.

Functions registered this way runs in reverse order of registration, just like END {} block does. The difference is its timing to be triggered. ruby_vm_at_exit functions runs when a VM passed away, while END {} blocks runs just before a VM is passing away.

You cannot register a function to another VM than where you are in. So where to register is intuitive, omitted. OTOH the argument func cannot know which VM it is in because at the time of invocation, the VM has already died and there is no execution context. The VM itself is passed as the first argument to it.

Parameters

  [in] | func | the function to register.

Definition at line 205 of file vm.c.

References at_exit, func, GET_VM, and rb_ary_push().

VALUE* ruby_vm_debug_ptr | ( | rb_vm_t * | vm | ) |

Definition at line 2260 of file vm.c.

References rb_vm_struct::debug.

Referenced by rb_ruby_debug_ptr().

int ruby_vm_destruct | ( | rb_vm_t * | vm | ) |

Definition at line 1601 of file vm.c.

References rb_vm_struct::living_threads, rb_vm_struct::main_thread, rb_vm_struct::objspace, rb_fiber_reset_root_local_storage(), rb_gc_force_recycle(), rb_objspace_free(), rb_vm_gvl_destroy(), RUBY_FREE_ENTER, RUBY_FREE_LEAVE, ruby_vm_run_at_exit_hooks(), ruby_xfree(), rb_vm_struct::self, rb_thread_struct::self, st_free_table, and thread_free().

Referenced by ruby_cleanup().

static void ruby_vm_run_at_exit_hooks | ( | rb_vm_t * | vm | ) |

static

Definition at line 211 of file vm.c.

References rb_vm_struct::at_exit, func, RARRAY_LEN, rb_ary_free(), and rb_ary_pop().

Referenced by ruby_vm_destruct().

VALUE* ruby_vm_verbose_ptr | ( | rb_vm_t * | vm | ) |

Definition at line 2254 of file vm.c.

References rb_vm_struct::verbose.

Referenced by rb_ruby_verbose_ptr().

static VALUE sdr | ( | void |  | ) |

static

Definition at line 2042 of file vm.c.

References Qnil, and rb_vm_bugreport().

Referenced by Init_VM().

static void th_init | ( | rb_thread_t * | th,
|  | VALUE | self
| ) |  |

static

Definition at line 1865 of file vm.c.

References ALT_STACK_SIZE, rb_thread_struct::cfp, rb_thread_struct::errinfo, rb_thread_struct::last_status, malloc(), Qnil, RUBY_VM_THREAD_STACK_SIZE, rb_thread_struct::self, rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::status, thread_recycle_stack(), THREAD_RUNNABLE, VM_FRAME_MAGIC_TOP, vm_push_frame(), and rb_thread_struct::waiting_fd.

Referenced by Init_BareVM(), and ruby_thread_init().

static VALUE thread_alloc | ( | VALUE | klass | ) |

static

Definition at line 1851 of file vm.c.

References thread_data_type, TypedData_Make_Struct, and TypedData_Wrap_Struct.

Referenced by rb_thread_alloc().

static void thread_free | ( | void * | ptr | ) |

static

Definition at line 1769 of file vm.c.

References free(), rb_thread_struct::keeping_mutexes, rb_thread_struct::local_storage, rb_thread_struct::locking_mutex, rb_vm_struct::main_thread, NULL, rb_objspace::ptr, Qfalse, rb_bug(), rb_thread_struct::root_fiber, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, RUBY_FREE_UNLESS_NULL, RUBY_GC_INFO, ruby_xfree(), st_free_table, rb_thread_struct::stack, and rb_thread_struct::vm.

Referenced by ruby_vm_destruct().

static size_t thread_memsize | ( | const void * | ptr | ) |

static

Definition at line 1810 of file vm.c.

References rb_thread_struct::local_storage, rb_objspace::ptr, rb_thread_struct::root_fiber, size, st_memsize(), and rb_thread_struct::stack_size.

static VALUE* thread_recycle_stack | ( | size_t | size | ) |

static

Definition at line 1669 of file vm.c.

References ALLOC_N, and thread_recycle_stack_count.

Referenced by th_init().

void vm_analysis_insn | ( | int | insn | ) |

void vm_analysis_operand | ( | int | insn,
|  | int | n,
|  | VALUE | op
| ) |  |

void vm_analysis_register | ( | int | reg,
|  | int | isset
| ) |  |

static VALUE vm_backtrace | ( | rb_thread_t * | th,
|  | int | lev
| ) |  |

inline static

Definition at line 845 of file vm.c.

References Qnil, rb_ary_new(), rb_ary_reverse(), vm_backtrace_alloc(), vm_backtrace_each(), and vm_backtrace_push().

static void vm_backtrace_alloc | ( | void * | arg | ) |

static

Definition at line 820 of file vm.c.

References arg, and rb_ary_new().

Referenced by vm_backtrace().

static int vm_backtrace_each | ( | rb_thread_t * | th,
|  | int | lev,
|  | void(*)(void *) | init,
|  | rb_backtrace_iter_func * | iter,
|  | void * | arg
| ) |  |

static

Definition at line 776 of file vm.c.

References arg, rb_method_entry_struct::called_id, rb_thread_struct::cfp, rb_method_entry_struct::def, FALSE, rb_iseq_struct::filename, id, ID_ALLOCATOR, init, rb_control_frame_t::iseq, rb_control_frame_t::me, rb_iseq_struct::name, NIL_P, rb_method_definition_struct::original_id, rb_control_frame_t::pc, rb_vm_struct::progname, Qnil, rb_id2str(), rb_vm_get_sourceline(), ruby_engine_name, RUBY_VM_NEXT_CONTROL_FRAME, RUBYVM_CFUNC_FRAME_P, rb_thread_struct::stack, rb_thread_struct::stack_size, TRUE, and rb_thread_struct::vm.

Referenced by vm_backtrace().

static int vm_backtrace_push | ( | void * | arg,
|  | VALUE | file,
|  | int | line_no,
|  | VALUE | name
| ) |  |

static

Definition at line 827 of file vm.c.

References arg, rb_ary_push(), rb_enc_compatible(), rb_enc_sprintf(), and RSTRING_PTR.

Referenced by vm_backtrace().

static VALUE vm_cfp_svar_get | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp,
|  | VALUE | key
| ) |  |

static

Definition at line 699 of file vm.c.

References rb_control_frame_t::lfp, lfp_svar_get(), and vm_normal_frame().

Referenced by vm_svar_get().

static void vm_cfp_svar_set | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp,
|  | VALUE | key,
|  | const VALUE | val
| ) |  |

static

Definition at line 706 of file vm.c.

References rb_control_frame_t::lfp, lfp_svar_set(), and vm_normal_frame().

Referenced by vm_svar_set().

static void vm_clear_all_cache | ( | void |  | ) |

static

Definition at line 80 of file vm.c.

References ruby_vm_global_state_version, vm_clear_all_inline_method_cache(), and vm_clear_global_method_cache().

static void vm_clear_all_inline_method_cache | ( | void |  | ) |

static

Definition at line 71 of file vm.c.

Referenced by vm_clear_all_cache().

static void vm_clear_global_method_cache | ( | void |  | ) |

static

Referenced by vm_clear_all_cache().

static int vm_collect_local_variables_in_heap | ( | rb_thread_t * | th,
|  | VALUE * | dfp,
|  | VALUE | ary
| ) |  |

static

Definition at line 459 of file vm.c.

References collect_local_variables_in_env(), env, ENV_IN_HEAP_P, ENV_VAL, and GetEnvPtr.

static void vm_define_method | ( | rb_thread_t * | th,
|  | VALUE | obj,
|  | ID | id,
|  | VALUE | iseqval,
|  | rb_num_t | is_singleton,
|  | NODE * | cref
| ) |  |

static

Definition at line 1912 of file vm.c.

References COPY_CREF, FIXNUM_P, GetISeqPtr, id, INC_VM_STATE_VERSION, NIL_P, NOEX_MODFUNC, NOEX_PUBLIC, rb_add_method(), rb_check_frozen, rb_eTypeError, RB_GC_GUARD, rb_id2name(), rb_iseq_clone(), rb_obj_classname(), rb_raise(), rb_singleton_class(), SYMBOL_P, and VM_METHOD_TYPE_ISEQ.

Referenced by m_core_define_method(), and m_core_define_singleton_method().

static VALUE vm_exec | ( | rb_thread_t * | th | ) |

static

Definition at line 1209 of file vm.c.

References rb_control_frame_t::bp, rb_method_entry_struct::called_id, rb_iseq_struct::catch_table, rb_iseq_struct::catch_table_size, iseq_catch_table_entry::CATCH_TYPE_BREAK, iseq_catch_table_entry::CATCH_TYPE_ENSURE, iseq_catch_table_entry::CATCH_TYPE_NEXT, iseq_catch_table_entry::CATCH_TYPE_REDO, iseq_catch_table_entry::CATCH_TYPE_RESCUE, iseq_catch_table_entry::CATCH_TYPE_RETRY, rb_thread_struct::cfp, iseq_catch_table_entry::cont, rb_control_frame_t::dfp, iseq_catch_table_entry::end, err, rb_thread_struct::errinfo, EXEC_EVENT_HOOK, EXEC_TAG, finish_insn_seq, GET_THROWOBJ_CATCH_POINT, GET_THROWOBJ_VAL, GetISeqPtr, i, iseq_catch_table_entry::iseq, rb_control_frame_t::iseq, rb_iseq_struct::iseq_encoded, JUMP_TAG, rb_method_entry_struct::klass, rb_control_frame_t::lfp, rb_iseq_struct::local_size, rb_control_frame_t::me, NULL, rb_control_frame_t::pc, Qnil, result, RUBY_EVENT_C_RETURN, RUBY_EVENT_END, RUBY_EVENT_RETURN, RUBY_VM_PREVIOUS_CONTROL_FRAME, rb_control_frame_t::self, SET_THROWOBJ_CATCH_POINT, SET_THROWOBJ_STATE, iseq_catch_table_entry::sp, rb_control_frame_t::sp, iseq_catch_table_entry::start, rb_thread_struct::state, TAG_BREAK, TAG_NEXT, TAG_RAISE, TAG_REDO, TAG_RETRY, TAG_RETURN, TH_POP_TAG, TH_POP_TAG2, TH_PUSH_TAG, iseq_catch_table_entry::type, type, UNLIKELY, vm_exec_core(), VM_FRAME_MAGIC_BLOCK, VM_FRAME_MAGIC_CFUNC, VM_FRAME_MAGIC_CLASS, VM_FRAME_MAGIC_FINISH, VM_FRAME_MAGIC_METHOD, VM_FRAME_TYPE, vm_pop_frame(), and vm_push_frame().

Referenced by invoke_block_from_c(), rb_iseq_eval(), and rb_iseq_eval_main().

static rb_control_frame_t* vm_get_ruby_level_caller_cfp | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp
| ) |  |

static

Definition at line 181 of file vm.c.

References rb_control_frame_t::flag, rb_control_frame_t::iseq, RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P, RUBY_VM_NORMAL_ISEQ_P, RUBY_VM_PREVIOUS_CONTROL_FRAME, and VM_FRAME_FLAG_PASSED.

Referenced by rb_current_realfilepath(), rb_f_block_given_p(), and rb_f_local_variables().

static void vm_init2 | ( | rb_vm_t * | vm | ) |

static

Definition at line 1651 of file vm.c.

References rb_vm_struct::at_exit, RArray::basic, RBasic::flags, RBasic::klass, MEMZERO, RARRAY_EMBED_FLAG, RARRAY_EMBED_LEN_MASK, rb_vm_struct::src_encoding_index, and T_ARRAY.

Referenced by Init_BareVM().

static void vm_init_redefined_flag | ( | void |  | ) |

static

Definition at line 1052 of file vm.c.

References AREF, C, DIV, LE, MOD, OP, and st_init_numtable.

Referenced by Init_VM().

static void vm_iter_break | ( | rb_thread_t * | th | ) |

static

Definition at line 1007 of file vm.c.

References rb_thread_struct::cfp, rb_control_frame_t::dfp, rb_thread_struct::errinfo, GC_GUARDED_PTR_REF, NEW_THROW_OBJECT, Qnil, rb_thread_struct::state, TAG_BREAK, and TH_JUMP_TAG.

Referenced by rb_iter_break().

static VALUE vm_make_env_each | ( | rb_thread_t *const | th,
|  | rb_control_frame_t *const | cfp,
|  | VALUE * | envptr,
|  | VALUE *const | endptr
| ) |  |

static

Definition at line 347 of file vm.c.

References ALLOC_N, rb_env_t::block, rb_control_frame_t::dfp, rb_block_struct::dfp, dp, env, rb_env_t::env, env_alloc(), ENV_IN_HEAP_P, rb_env_t::env_size, ENV_VAL, GC_GUARDED_PTR, GC_GUARDED_PTR_REF, GetEnvPtr, i, rb_control_frame_t::iseq, rb_block_struct::iseq, rb_control_frame_t::lfp, rb_block_struct::lfp, rb_iseq_struct::local_size, rb_env_t::local_size, rb_env_t::prev_envval, rb_bug(), rb_vm_rewrite_dfp_in_errinfo(), RUBY_VM_NORMAL_ISEQ_P, SDR, rb_control_frame_t::self, rb_block_struct::self, and rb_thread_struct::stack.

Referenced by rb_vm_make_env_object().

static VALUE vm_make_proc_from_block | ( | rb_thread_t * | th,
|  | rb_block_t * | block
| ) |  |

static

Definition at line 526 of file vm.c.

References rb_block_struct::proc, rb_cProc, and rb_vm_make_proc().

Referenced by rb_vm_make_proc().

static int vm_mark_each_thread_func | ( | st_data_t | key,
|  | st_data_t | value,
|  | st_data_t | dummy
| ) |  |

static

Definition at line 1547 of file vm.c.

References rb_gc_mark(), and ST_CONTINUE.

Referenced by rb_vm_mark().

static size_t vm_memsize | ( | const void * | ptr | ) |

static

Definition at line 1634 of file vm.c.

References rb_vm_struct::living_threads, rb_objspace::ptr, and st_memsize().

static rb_control_frame_t* vm_normal_frame | ( | rb_thread_t * | th,
|  | rb_control_frame_t * | cfp
| ) |  |

static

Definition at line 687 of file vm.c.

References rb_control_frame_t::pc, RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P, and RUBY_VM_PREVIOUS_CONTROL_FRAME.

Referenced by vm_cfp_svar_get(), and vm_cfp_svar_set().

static void vm_set_eval_stack | ( | rb_thread_t * | th,
|  | VALUE | iseqval,
|  | const NODE * | cref
| ) |  |

static

Definition at line 126 of file vm.c.

References rb_thread_struct::base_block, rb_thread_struct::cfp, CHECK_STACK_OVERFLOW, rb_control_frame_t::dfp, rb_block_struct::dfp, GC_GUARDED_PTR, GetISeqPtr, rb_iseq_struct::iseq_encoded, rb_block_struct::lfp, rb_iseq_struct::local_size, rb_vm_set_finish_env(), rb_block_struct::self, rb_control_frame_t::sp, rb_iseq_struct::stack_max, VM_FRAME_MAGIC_EVAL, and vm_push_frame().

Referenced by vm_set_main_stack().

static void vm_set_main_stack | ( | rb_thread_t * | th,
|  | VALUE | iseqval
| ) |  |

static

Definition at line 146 of file vm.c.

References rb_thread_struct::base_block, rb_env_t::block, rb_thread_struct::cfp, CHECK_STACK_OVERFLOW, env, rb_binding_t::env, GetBindingPtr, GetEnvPtr, GetISeqPtr, rb_iseq_struct::local_size, rb_cObject, rb_const_get(), rb_intern, rb_vm_make_env_object(), rb_iseq_struct::stack_max, and vm_set_eval_stack().

Referenced by rb_iseq_eval_main().

static void vm_set_top_stack | ( | rb_thread_t * | th,
|  | VALUE | iseqval
| ) |  |

static

Definition at line 106 of file vm.c.

References rb_thread_struct::cfp, CHECK_STACK_OVERFLOW, GetISeqPtr, rb_iseq_struct::iseq_encoded, rb_iseq_struct::local_size, rb_eTypeError, rb_raise(), rb_vm_set_finish_env(), rb_control_frame_t::sp, rb_iseq_struct::stack_max, rb_thread_struct::top_self, rb_iseq_struct::type, VM_FRAME_MAGIC_TOP, and vm_push_frame().

Referenced by rb_iseq_eval().

static VALUE vm_svar_get | ( | VALUE | key | ) |

static

Definition at line 713 of file vm.c.

References rb_thread_struct::cfp, GET_THREAD, and vm_cfp_svar_get().

Referenced by rb_backref_get(), and rb_lastline_get().

static void vm_svar_set | ( | VALUE | key,
|  | VALUE | val
| ) |  |

static

Definition at line 720 of file vm.c.

References rb_thread_struct::cfp, GET_THREAD, and vm_cfp_svar_set().

Referenced by rb_backref_set(), and rb_lastline_set().

static VALUE vm_yield | ( | rb_thread_t * | th,
|  | int | argc,
|  | const VALUE * | argv
| ) |  |

inline static

Definition at line 651 of file vm.c.

References check_block(), invoke_block_from_c(), and rb_block_struct::self.

static VALUE vm_yield_with_cref | ( | rb_thread_t * | th,
|  | int | argc,
|  | const VALUE * | argv,
|  | const NODE * | cref
| ) |  |

inline static

Definition at line 644 of file vm.c.

References check_block(), invoke_block_from_c(), and rb_block_struct::self.

## Variable Documentation

const rb_data_type_t env_data_type

static

Initial value:
= {
"VM/env",
{env_mark, env_free, env_memsize,},
}

Definition at line 293 of file vm.c.

VALUE rb_cEnv

Definition at line 37 of file vm.c.

Referenced by env_alloc(), Init_VM(), and rb_vm_rewrite_dfp_in_errinfo().

VALUE rb_cRubyVM

Definition at line 35 of file vm.c.

Referenced by Init_ISeq(), and Init_VM().

VALUE rb_cThread

Definition at line 36 of file vm.c.

size_t rb_gc_stack_maxsize

VALUE* rb_gc_stack_start

VALUE rb_mRubyVMFrozenCore

Definition at line 38 of file vm.c.

Referenced by Init_VM(), and thread_exec_event_hooks().

rb_thread_t* ruby_current_thread = 0

Definition at line 44 of file vm.c.

rb_vm_t* ruby_current_vm = 0

Definition at line 45 of file vm.c.

Referenced by Init_VM().

const rb_data_type_t ruby_threadptr_data_type

Initial value:
= {
"VM/thread",
{
rb_thread_mark,
thread_free,
thread_memsize,
},
}

Definition at line 1830 of file vm.c.

VALUE ruby_vm_const_missing_count = 0

Definition at line 40 of file vm.c.

Referenced by rb_vm_inc_const_missing_count().

char ruby_vm_redefined_flag[BOP_LAST_]

Definition at line 42 of file vm.c.

Referenced by rb_vm_check_redefinition_opt_method().

int thread_recycle_stack_count = 0

static

Definition at line 1666 of file vm.c.

Referenced by thread_recycle_stack().

VALUE* thread_recycle_stack_slot[RECYCLE_MAX]

static

Definition at line 1665 of file vm.c.

const rb_data_type_t vm_data_type

static

Initial value:
= {
"VM",
{rb_vm_mark, vm_free, vm_memsize,},
}

Definition at line 1645 of file vm.c.

st_table* vm_opt_method_table = 0

static

Definition at line 1025 of file vm.c.