Ruby  2.1.10p492(2016-04-01revision54464)
Macros | Functions | Variables
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 "probes.h"
#include "probes_helper.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 S(s)   sym_##s = ID2SYM(rb_intern_const(#s))
 
#define SET(name, attr)
 
#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 SET(name)   rb_hash_aset(result, ID2SYM(rb_intern(#name)), SIZET2NUM(vm->default_params.name));
 
#define USE_THREAD_DATA_RECYCLE   1
 
#define RECYCLE_MAX   64
 
#define thread_data_type   ruby_threadptr_data_type
 
#define REWIND_CFP(expr)
 

Functions

static VALUEVM_EP_LEP (VALUE *ep)
 
VALUErb_vm_ep_local_ep (VALUE *ep)
 
static VALUEVM_CF_LEP (rb_control_frame_t *cfp)
 
static VALUEVM_CF_PREV_EP (rb_control_frame_t *cfp)
 
static rb_block_tVM_CF_BLOCK_PTR (rb_control_frame_t *cfp)
 
rb_block_trb_vm_control_frame_block_ptr (rb_control_frame_t *cfp)
 
static VALUE vm_invoke_proc (rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class, int argc, const VALUE *argv, const rb_block_t *blockptr)
 
rb_serial_t rb_next_class_serial (void)
 
static void thread_free (void *ptr)
 
void rb_vm_inc_const_missing_count (void)
 
static VALUE vm_stat (int argc, VALUE *argv, VALUE self)
 
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, rb_block_t *base_block)
 
static void vm_set_main_stack (rb_thread_t *th, VALUE iseqval)
 
rb_control_frame_trb_vm_get_binding_creatable_next_cfp (rb_thread_t *th, const rb_control_frame_t *cfp)
 
rb_control_frame_trb_vm_get_ruby_level_next_cfp (rb_thread_t *th, const rb_control_frame_t *cfp)
 
static rb_control_frame_tvm_get_ruby_level_caller_cfp (rb_thread_t *th, rb_control_frame_t *cfp)
 
void rb_vm_pop_cfunc_frame (void)
 
void rb_vm_rewind_cfp (rb_thread_t *th, rb_control_frame_t *cfp)
 
void rb_frame_pop (void)
 
void ruby_vm_at_exit (void(*func)(rb_vm_t *))
 
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 *ep, VALUE ary)
 
static void vm_rewrite_ep_in_errinfo (rb_thread_t *th)
 
static VALUE vm_make_proc_from_block (rb_thread_t *th, rb_block_t *block)
 
static VALUE vm_make_env_object (rb_thread_t *th, rb_control_frame_t *cfp, VALUE *blockprocptr)
 
VALUE rb_vm_make_env_object (rb_thread_t *th, rb_control_frame_t *cfp)
 
void rb_vm_stack_to_heap (rb_thread_t *th)
 
VALUE rb_vm_make_proc (rb_thread_t *th, const rb_block_t *block, VALUE klass)
 
VALUE rb_vm_make_binding (rb_thread_t *th, const rb_control_frame_t *src_cfp)
 
VALUErb_binding_add_dynavars (rb_binding_t *bind, int dyncount, const ID *dynvars)
 
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, VALUE defined_class)
 
static const rb_block_tcheck_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)
 
static VALUE vm_yield_with_block (rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr)
 
VALUE rb_vm_invoke_proc (rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, const rb_block_t *blockptr)
 
static rb_control_frame_tvm_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)
 
VALUE rb_sourcefilename (void)
 
const char * rb_sourcefile (void)
 
int rb_sourceline (void)
 
NODErb_vm_cref (void)
 
NODErb_vm_cref_in_context (VALUE self)
 
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)
 
 NORETURN (static void vm_iter_break(rb_thread_t *th, VALUE val))
 
static void vm_iter_break (rb_thread_t *th, VALUE val)
 
void rb_iter_break (void)
 
void rb_iter_break_value (VALUE val)
 
static int vm_redefinition_check_flag (VALUE klass)
 
static void rb_vm_check_redefinition_opt_method (const rb_method_entry_t *me, VALUE klass)
 
static int check_redefined_method (st_data_t key, st_data_t value, st_data_t data)
 
void rb_vm_check_redefinition_by_prepend (VALUE klass)
 
static void add_opt_method (VALUE klass, ID mid, VALUE bop)
 
static void vm_init_redefined_flag (void)
 
static void hook_before_rewind (rb_thread_t *th, rb_control_frame_t *cfp, int will_finish_vm_exec)
 
static VALUE vm_exec (rb_thread_t *th)
 
VALUE rb_iseq_eval (VALUE iseqval)
 
VALUE rb_iseq_eval_main (VALUE iseqval)
 
int rb_vm_control_frame_id_and_class (const rb_control_frame_t *cfp, ID *idp, VALUE *klassp)
 
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)
 
void rb_vm_trace_mark_event_hooks (rb_hook_list_t *hooks)
 
void rb_vm_mark (void *ptr)
 
int rb_vm_add_root_module (ID id, VALUE module)
 
int ruby_vm_destruct (rb_vm_t *vm)
 
static size_t vm_memsize (const void *ptr)
 
static VALUE vm_default_params (void)
 
static size_t get_param (const char *name, size_t default_value, size_t min_value)
 
static void check_machine_stack_size (size_t *sizep)
 
static void vm_default_params_setup (rb_vm_t *vm)
 
static void vm_init2 (rb_vm_t *vm)
 
static VALUEthread_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)
 
static VALUE core_hash_merge_ary (VALUE hash, VALUE ary)
 
static VALUE core_hash_from_ary (VALUE ary)
 
static VALUE core_hash_merge_kwd (int argc, VALUE *argv)
 
static VALUE core_hash_merge (VALUE hash, long argc, const VALUE *argv)
 
static VALUE m_core_hash_from_ary (VALUE self, VALUE ary)
 
static VALUE m_core_hash_merge_ary (VALUE self, VALUE hash, VALUE ary)
 
static VALUE m_core_hash_merge_ptr (int argc, VALUE *argv, VALUE recv)
 
static int kwmerge_ii (st_data_t *key, st_data_t *value, st_data_t arg, int existing)
 
static int kwmerge_i (VALUE key, VALUE value, VALUE hash)
 
static int kwcheck_i (VALUE key, VALUE value, VALUE hash)
 
static VALUE m_core_hash_merge_kwd (int argc, VALUE *argv, VALUE recv)
 
static VALUE sdr (void)
 
static VALUE nsdr (void)
 
void Init_VM (void)
 
void rb_vm_set_progname (VALUE filename)
 
struct rb_objspacerb_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)
 
VALUEruby_vm_verbose_ptr (rb_vm_t *vm)
 
VALUEruby_vm_debug_ptr (rb_vm_t *vm)
 
VALUErb_ruby_verbose_ptr (void)
 
VALUErb_ruby_debug_ptr (void)
 
VALUE rb_insn_operand_intern (rb_iseq_t *iseq, VALUE insn, int op_no, VALUE op, int len, size_t pos, VALUE *pnop, VALUE child)
 

Variables

static rb_serial_t ruby_vm_global_method_state = 1
 
static rb_serial_t ruby_vm_global_constant_state = 1
 
static rb_serial_t ruby_vm_class_serial = 1
 
VALUE rb_cRubyVM
 
VALUE rb_cThread
 
VALUE rb_cEnv
 
VALUE rb_mRubyVMFrozenCore
 
VALUE ruby_vm_const_missing_count = 0
 
short ruby_vm_redefined_flag [BOP_LAST_]
 
rb_thread_truby_current_thread = 0
 
rb_vm_truby_current_vm = 0
 
rb_event_flag_t ruby_vm_event_flags
 
static const rb_data_type_t env_data_type
 
static st_tablevm_opt_method_table = 0
 
static const rb_data_type_t vm_data_type
 
static VALUEthread_recycle_stack_slot [RECYCLE_MAX]
 
static int thread_recycle_stack_count = 0
 
const rb_data_type_t ruby_threadptr_data_type
 
VALUErb_gc_stack_start
 
size_t rb_gc_stack_maxsize
 
void(* ruby_vm_collect_usage_func_insn )(int insn) = NULL
 
void(* ruby_vm_collect_usage_func_operand )(int insn, int n, VALUE op) = NULL
 
void(* ruby_vm_collect_usage_func_register )(int reg, int isset) = NULL
 

Macro Definition Documentation

#define BUFSIZE   0x100

Definition at line 88 of file vm.c.

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

Referenced by vm_init_redefined_flag().

#define ENV_IN_HEAP_P (   th,
  env 
)    (!((th)->stack <= (env) && (env) < ((th)->stack + (th)->stack_size)))
#define ENV_VAL (   env)    ((env)[1])

Definition at line 347 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 89 of file vm.c.

Referenced by rb_vm_make_proc(), and vm_make_env_object().

#define RECYCLE_MAX   64

Definition at line 1975 of file vm.c.

Referenced by rb_thread_recycle_stack_release().

#define REWIND_CFP (   expr)
Value:
do { \
VALUE *const curr_sp = (th__->cfp++)->sp; \
VALUE *const saved_sp = th__->cfp->sp; \
th__->cfp->sp = curr_sp; \
(th__->cfp--)->sp = saved_sp; \
} while (0)
struct rb_thread_struct rb_thread_t
unsigned long VALUE
Definition: ripper.y:88
expr expr keyword_or expr
Definition: ripper.y:1292
static rb_thread_t * GET_THREAD(void)
Definition: vm_core.h:929

Definition at line 2276 of file vm.c.

Referenced by m_core_define_method(), m_core_define_singleton_method(), m_core_hash_from_ary(), m_core_hash_merge_ary(), m_core_hash_merge_kwd(), m_core_hash_merge_ptr(), m_core_set_method_alias(), m_core_set_variable_alias(), and m_core_undef_method().

#define S (   s)    sym_##s = ID2SYM(rb_intern_const(#s))

Referenced by vm_stat().

#define SET (   name,
  attr 
)
Value:
if (key == sym_##name) \
else if (hash != Qnil) \
rb_hash_aset(hash, sym_##name, SERIALT2NUM(attr));
#define SERIALT2NUM
return
Definition: bigdecimal.c:5946
VALUE hash
Definition: tkutil.c:267
#define Qnil
Definition: enum.c:67
static int VALUE key
Definition: tkutil.c:265
else
Definition: enum.c:452
rb_hash_aset(hash, RARRAY_AREF(key_value_pair, 0), RARRAY_AREF(key_value_pair, 1))
VALUE name
Definition: enum.c:572
#define thread_data_type   ruby_threadptr_data_type

Definition at line 2147 of file vm.c.

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

#define USE_THREAD_DATA_RECYCLE   1

Definition at line 1972 of file vm.c.

#define vm_free   0

Definition at line 1819 of file vm.c.

Function Documentation

static void add_opt_method ( VALUE  klass,
ID  mid,
VALUE  bop 
)
static
static const rb_block_t* check_block ( rb_thread_t th)
inlinestatic
static int check_env ( rb_env_t *const  env)
static

Definition at line 426 of file vm.c.

References rb_env_t::block, check_env_value(), dp, rb_block_struct::ep, and rb_env_t::prev_envval.

Referenced by check_env_value().

static VALUE check_env_value ( VALUE  envval)
static

Definition at line 442 of file vm.c.

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

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

static void check_machine_stack_size ( size_t *  sizep)
static

Definition at line 1914 of file vm.c.

References size.

Referenced by vm_default_params_setup().

static int check_redefined_method ( st_data_t  key,
st_data_t  value,
st_data_t  data 
)
static
static int collect_local_variables_in_env ( rb_env_t env,
const VALUE  ary 
)
static
static int collect_local_variables_in_iseq ( rb_iseq_t iseq,
const VALUE  ary 
)
static
static VALUE core_hash_from_ary ( VALUE  ary)
static
static VALUE core_hash_merge ( VALUE  hash,
long  argc,
const VALUE argv 
)
static

Definition at line 2343 of file vm.c.

References argc, assert, hash, i, and rb_hash_aset().

Referenced by core_hash_merge_ary(), and m_core_hash_merge_ptr().

static VALUE core_hash_merge_ary ( VALUE  hash,
VALUE  ary 
)
static

Definition at line 2382 of file vm.c.

References core_hash_merge(), hash, RARRAY_CONST_PTR, and RARRAY_LEN.

Referenced by core_hash_from_ary(), and m_core_hash_merge_ary().

static VALUE core_hash_merge_kwd ( int  argc,
VALUE argv 
)
static

Definition at line 2432 of file vm.c.

References hash, kwcheck_i(), kwmerge_i(), rb_check_arity, rb_convert_type(), rb_hash_foreach(), and T_HASH.

Referenced by m_core_hash_merge_kwd().

static VALUE env_alloc ( void  )
static
static void env_free ( void *const  ptr)
static

Definition at line 380 of file vm.c.

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

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

Definition at line 392 of file vm.c.

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

static size_t get_param ( const char *  name,
size_t  default_value,
size_t  min_value 
)
static

Definition at line 1897 of file vm.c.

References getenv, PRIdSIZE, result, RUBY_VM_SIZE_ALIGN, and val.

Referenced by vm_default_params_setup().

static void hook_before_rewind ( rb_thread_t th,
rb_control_frame_t cfp,
int  will_finish_vm_exec 
)
static
void Init_BareVM ( void  )
void Init_top_self ( void  )
void Init_VM ( void  )

Definition at line 2492 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_hash_from_ary, id_core_hash_merge_ary, id_core_hash_merge_kwd, id_core_hash_merge_ptr, id_core_set_method_alias, id_core_set_postexe, id_core_set_variable_alias, id_core_undef_method, Init_vm_backtrace(), rb_control_frame_struct::iseq, rb_iseq_struct::iseq_encoded, rb_control_frame_struct::klass, klass, rb_vm_struct::living_threads, m_core_define_method(), m_core_define_singleton_method(), m_core_hash_from_ary(), m_core_hash_merge_ary(), m_core_hash_merge_kwd(), m_core_hash_merge_ptr(), m_core_set_method_alias(), m_core_set_postexe(), m_core_set_variable_alias(), m_core_undef_method(), rb_vm_struct::main_thread, nsdr(), opts, rb_control_frame_struct::pc, Qnil, rb_ary_new(), rb_ary_push(), rb_binding_new(), rb_block_lambda(), rb_block_proc(), 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_iv_set(), 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, RBASIC_CLEAR_CLASS, RCLASS_SET_SUPER(), ruby_current_vm, rb_vm_struct::running_thread, sdr(), rb_vm_struct::self, rb_control_frame_struct::self, rb_thread_struct::self, st_data_t, st_init_numtable(), st_insert(), T_ICLASS, th, 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, vm_default_params(), vm_init_redefined_flag(), VM_PROFILE_ATEXIT, vm_stat(), and void.

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,
VALUE  defined_class 
)
inlinestatic
static int kwcheck_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static

Definition at line 2417 of file vm.c.

References Check_Type(), ST_CONTINUE, SYMBOL_P, and T_SYMBOL.

Referenced by core_hash_merge_kwd().

static int kwmerge_i ( VALUE  key,
VALUE  value,
VALUE  hash 
)
static
static int kwmerge_ii ( st_data_t key,
st_data_t value,
st_data_t  arg,
int  existing 
)
static

Definition at line 2399 of file vm.c.

References arg, ST_CONTINUE, and ST_STOP.

Referenced by kwmerge_i().

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

Definition at line 2286 of file vm.c.

References GET_THREAD(), rb_vm_cref(), REWIND_CFP, sym, 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 2295 of file vm.c.

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

Referenced by Init_VM().

static VALUE m_core_hash_from_ary ( VALUE  self,
VALUE  ary 
)
static

Definition at line 2355 of file vm.c.

References core_hash_from_ary(), hash, and REWIND_CFP.

Referenced by Init_VM().

static VALUE m_core_hash_merge_ary ( VALUE  self,
VALUE  hash,
VALUE  ary 
)
static

Definition at line 2375 of file vm.c.

References core_hash_merge_ary(), hash, and REWIND_CFP.

Referenced by Init_VM().

static VALUE m_core_hash_merge_kwd ( int  argc,
VALUE argv,
VALUE  recv 
)
static

Definition at line 2424 of file vm.c.

References core_hash_merge_kwd(), hash, and REWIND_CFP.

Referenced by Init_VM().

static VALUE m_core_hash_merge_ptr ( int  argc,
VALUE argv,
VALUE  recv 
)
static

Definition at line 2389 of file vm.c.

References core_hash_merge(), hash, and REWIND_CFP.

Referenced by Init_VM().

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

Definition at line 2304 of file vm.c.

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

Referenced by Init_VM().

static VALUE m_core_set_postexe ( VALUE  self)
static

Definition at line 2332 of file vm.c.

References Qnil, rb_block_proc(), rb_call_end_proc(), and rb_set_end_proc().

Referenced by Init_VM().

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

Definition at line 2313 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 2322 of file vm.c.

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

Referenced by Init_VM().

static VALUE main_to_s ( VALUE  obj)
static

Definition at line 2828 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
NORETURN ( static void   vm_iter_breakrb_thread_t *th, VALUE val)
static VALUE nsdr ( void  )
static

Definition at line 2462 of file vm.c.

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

Referenced by Init_VM().

VALUE rb_backref_get ( void  )
void rb_backref_set ( VALUE  val)
VALUE* rb_binding_add_dynavars ( rb_binding_t bind,
int  dyncount,
const ID dynvars 
)
int rb_frame_method_id_and_class ( ID idp,
VALUE klassp 
)

Definition at line 1706 of file vm.c.

References GET_THREAD(), and rb_thread_method_id_and_class().

void rb_frame_pop ( void  )

Definition at line 309 of file vm.c.

References GET_THREAD(), th, and vm_pop_frame().

VALUE rb_insn_operand_intern ( rb_iseq_t iseq,
VALUE  insn,
int  op_no,
VALUE  op,
int  len,
size_t  pos,
VALUE pnop,
VALUE  child 
)
VALUE rb_iseq_eval ( VALUE  iseqval)

Definition at line 1646 of file vm.c.

References GET_THREAD(), RB_GC_GUARD(), th, val, vm_exec(), and vm_set_top_stack().

Referenced by iseq_eval(), and rb_load_internal0().

VALUE rb_iseq_eval_main ( VALUE  iseqval)

Definition at line 1659 of file vm.c.

References GET_THREAD(), RB_GC_GUARD(), th, val, vm_exec(), and vm_set_main_stack().

Referenced by ruby_exec_internal().

void rb_iter_break ( void  )

Definition at line 1154 of file vm.c.

References GET_THREAD(), Qnil, and vm_iter_break().

Referenced by DEFINE_ENUMFUNCS(), and if().

void rb_iter_break_value ( VALUE  val)

Definition at line 1160 of file vm.c.

References GET_THREAD(), and vm_iter_break().

Referenced by if().

VALUE rb_lastline_get ( void  )

Definition at line 959 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)
rb_serial_t rb_next_class_serial ( void  )

Definition at line 92 of file vm.c.

References NEXT_CLASS_SERIAL.

Referenced by class_alloc(), and rb_class_clear_method_cache().

VALUE rb_obj_is_thread ( VALUE  obj)

Definition at line 2159 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  )
VALUE* rb_ruby_debug_ptr ( void  )

Definition at line 2871 of file vm.c.

References GET_VM, and ruby_vm_debug_ptr().

VALUE* rb_ruby_verbose_ptr ( void  )

Definition at line 2865 of file vm.c.

References GET_VM, and ruby_vm_verbose_ptr().

const char* rb_sourcefile ( void  )
VALUE rb_sourcefilename ( void  )
int rb_sourceline ( void  )
VALUE rb_thread_alloc ( VALUE  klass)

Definition at line 2233 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)
void rb_thread_mark ( void ptr)
int rb_thread_method_id_and_class ( rb_thread_t th,
ID idp,
VALUE klassp 
)
void rb_thread_recycle_stack_release ( VALUE stack)

Definition at line 1996 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 
)
VALUE rb_vm_cbase ( void  )
void rb_vm_check_redefinition_by_prepend ( VALUE  klass)
static void rb_vm_check_redefinition_opt_method ( const rb_method_entry_t me,
VALUE  klass 
)
static
rb_block_t* rb_vm_control_frame_block_ptr ( rb_control_frame_t cfp)

Definition at line 59 of file vm.c.

References VM_CF_BLOCK_PTR().

Referenced by proc_new(), rb_block_arity(), rb_block_given_p(), and rb_mod_refine().

int rb_vm_control_frame_id_and_class ( const rb_control_frame_t cfp,
ID idp,
VALUE klassp 
)
NODE* rb_vm_cref ( void  )
NODE* rb_vm_cref_in_context ( VALUE  self)
VALUE* rb_vm_ep_local_ep ( VALUE ep)

Definition at line 34 of file vm.c.

References VM_EP_LEP().

Referenced by rb_fiber_start(), and thread_start_func_2().

rb_control_frame_t* rb_vm_get_binding_creatable_next_cfp ( rb_thread_t th,
const rb_control_frame_t cfp 
)
rb_control_frame_t* rb_vm_get_ruby_level_next_cfp ( rb_thread_t th,
const rb_control_frame_t cfp 
)
void rb_vm_inc_const_missing_count ( void  )

Definition at line 111 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,
int  argc,
const VALUE argv,
const rb_block_t blockptr 
)
void rb_vm_jump_tag_but_local_jump ( int  state)

Definition at line 1133 of file vm.c.

References exc, JUMP_TAG, NIL_P(), Qundef, rb_exc_raise(), and rb_vm_make_jump_tag_but_local_jump().

Referenced by rb_load_internal0().

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

Definition at line 1094 of file vm.c.

References exc, make_localjump_error(), and rb_exc_raise().

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

VALUE rb_vm_make_binding ( rb_thread_t th,
const rb_control_frame_t src_cfp 
)
VALUE rb_vm_make_env_object ( rb_thread_t th,
rb_control_frame_t cfp 
)

Definition at line 577 of file vm.c.

References vm_make_env_object().

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

VALUE rb_vm_make_jump_tag_but_local_jump ( int  state,
VALUE  val 
)
VALUE rb_vm_make_proc ( rb_thread_t th,
const rb_block_t block,
VALUE  klass 
)
void rb_vm_mark ( void ptr)
void rb_vm_pop_cfunc_frame ( void  )
void rb_vm_rewind_cfp ( rb_thread_t th,
rb_control_frame_t cfp 
)
void rb_vm_set_progname ( VALUE  filename)
void rb_vm_stack_to_heap ( rb_thread_t th)
VALUE rb_vm_top_self ( void  )
void rb_vm_trace_mark_event_hooks ( rb_hook_list_t hooks)
static VALUE ruby_thread_init ( VALUE  self)
static
void ruby_vm_at_exit ( void(*)(rb_vm_t *)  func)

Definition at line 318 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 2859 of file vm.c.

References rb_vm_struct::debug.

Referenced by rb_ruby_debug_ptr().

int ruby_vm_destruct ( rb_vm_t vm)
static void ruby_vm_run_at_exit_hooks ( rb_vm_t vm)
static

Definition at line 324 of file vm.c.

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

Referenced by ruby_vm_destruct().

VALUE* ruby_vm_verbose_ptr ( rb_vm_t vm)

Definition at line 2853 of file vm.c.

References rb_vm_struct::verbose.

Referenced by rb_ruby_verbose_ptr().

static VALUE sdr ( void  )
static

Definition at line 2454 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
static VALUE thread_alloc ( VALUE  klass)
static

Definition at line 2170 of file vm.c.

References obj, th, thread_data_type, TypedData_Make_Struct, and TypedData_Wrap_Struct.

Referenced by rb_thread_alloc().

static void thread_free ( void ptr)
static
static size_t thread_memsize ( const void ptr)
static
static VALUE* thread_recycle_stack ( size_t  size)
static

Definition at line 1980 of file vm.c.

References ALLOC_N, and thread_recycle_stack_count.

Referenced by th_init().

static rb_block_t* VM_CF_BLOCK_PTR ( rb_control_frame_t cfp)
inlinestatic
static VALUE* VM_CF_LEP ( rb_control_frame_t cfp)
inlinestatic
static VALUE* VM_CF_PREV_EP ( rb_control_frame_t cfp)
inlinestatic

Definition at line 46 of file vm.c.

References VM_EP_PREV_EP.

Referenced by rb_f_local_variables(), and vm_iter_break().

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

Definition at line 919 of file vm.c.

References lep_svar_get(), VM_CF_LEP(), 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 926 of file vm.c.

References lep_svar_set(), VM_CF_LEP(), and vm_normal_frame().

Referenced by vm_svar_set().

static int vm_collect_local_variables_in_heap ( rb_thread_t th,
VALUE ep,
VALUE  ary 
)
static

Definition at line 559 of file vm.c.

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

static VALUE vm_default_params ( void  )
static

Definition at line 1882 of file vm.c.

References GET_VM, rb_hash_new(), rb_obj_freeze(), result, and SET.

Referenced by Init_VM().

static void vm_default_params_setup ( rb_vm_t vm)
static
static void vm_define_method ( rb_thread_t th,
VALUE  obj,
ID  id,
VALUE  iseqval,
rb_num_t  is_singleton,
NODE cref 
)
static
static VALUE* VM_EP_LEP ( VALUE ep)
inlinestatic

Definition at line 25 of file vm.c.

References VM_EP_LEP_P, and VM_EP_PREV_EP.

Referenced by rb_vm_ep_local_ep(), and VM_CF_LEP().

static VALUE vm_exec ( rb_thread_t th)
static

Definition at line 1417 of file vm.c.

References 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, iseq_catch_table_entry::end, entry, rb_control_frame_struct::ep, err, rb_thread_struct::errinfo, EXEC_EVENT_HOOK, EXEC_TAG, FALSE, GET_THROWOBJ_CATCH_POINT, GET_THROWOBJ_VAL, GetISeqPtr, hook_before_rewind(), i, iseq_catch_table_entry::iseq, rb_control_frame_struct::iseq, rb_iseq_struct::iseq_encoded, JUMP_TAG, rb_method_entry_struct::klass, rb_control_frame_struct::klass, rb_iseq_struct::local_size, rb_control_frame_struct::me, NULL, rb_control_frame_struct::pc, Qnil, result, RUBY_DTRACE_METHOD_RETURN_HOOK, RUBY_EVENT_C_RETURN, RUBY_VM_PREVIOUS_CONTROL_FRAME, rb_control_frame_struct::self, SET_THROWOBJ_CATCH_POINT, SET_THROWOBJ_STATE, iseq_catch_table_entry::sp, rb_control_frame_struct::sp, rb_iseq_struct::stack_max, iseq_catch_table_entry::start, rb_thread_struct::state, state, TAG_BREAK, TAG_NEXT, TAG_RAISE, TAG_REDO, TAG_RETRY, TAG_RETURN, TH_POP_TAG, TH_POP_TAG2, TH_PUSH_TAG, TRUE, iseq_catch_table_entry::type, type, UNLIKELY, vm_base_ptr(), VM_ENVVAL_PREV_EP_PTR, vm_exec_core(), VM_FRAME_MAGIC_CFUNC, VM_FRAME_MAGIC_RESCUE, VM_FRAME_TYPE, VM_FRAME_TYPE_FINISH_P, 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
static void vm_init2 ( rb_vm_t vm)
static
static void vm_init_redefined_flag ( void  )
static

Definition at line 1232 of file vm.c.

References AREF, C, DIV, MATCH, MOD, OP, and st_init_numtable().

Referenced by Init_VM().

static VALUE vm_invoke_proc ( rb_thread_t th,
rb_proc_t proc,
VALUE  self,
VALUE  defined_class,
int  argc,
const VALUE argv,
const rb_block_t blockptr 
)
static
static void vm_iter_break ( rb_thread_t th,
VALUE  val 
)
static
static VALUE vm_make_env_each ( rb_thread_t *const  th,
rb_control_frame_t *const  cfp,
VALUE envptr,
VALUE *const  endptr 
)
static
static VALUE vm_make_env_object ( rb_thread_t th,
rb_control_frame_t cfp,
VALUE blockprocptr 
)
static
static VALUE vm_make_proc_from_block ( rb_thread_t th,
rb_block_t block 
)
static

Definition at line 647 of file vm.c.

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

Referenced by vm_make_env_object().

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

Definition at line 1756 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
static rb_control_frame_t* vm_normal_frame ( rb_thread_t th,
rb_control_frame_t cfp 
)
static
static int vm_redefinition_check_flag ( VALUE  klass)
static
static void vm_rewrite_ep_in_errinfo ( rb_thread_t th)
static
static void vm_set_eval_stack ( rb_thread_t th,
VALUE  iseqval,
const NODE cref,
rb_block_t base_block 
)
static
static void vm_set_main_stack ( rb_thread_t th,
VALUE  iseqval 
)
static
static void vm_set_top_stack ( rb_thread_t th,
VALUE  iseqval 
)
static
static VALUE vm_stat ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE vm_svar_get ( VALUE  key)
static

Definition at line 933 of file vm.c.

References rb_thread_struct::cfp, GET_THREAD(), th, 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 940 of file vm.c.

References rb_thread_struct::cfp, GET_THREAD(), th, 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 
)
inlinestatic
static VALUE vm_yield_with_block ( rb_thread_t th,
int  argc,
const VALUE argv,
const rb_block_t blockargptr 
)
inlinestatic
static VALUE vm_yield_with_cref ( rb_thread_t th,
int  argc,
const VALUE argv,
const NODE cref 
)
inlinestatic

Variable Documentation

const rb_data_type_t env_data_type
static
Initial value:
= {
"VM/env",
}
static size_t env_memsize(const void *ptr)
Definition: vm.c:392
static void env_mark(void *const ptr)
Definition: vm.c:350
#define RUBY_TYPED_FREE_IMMEDIATELY
static void env_free(void *const ptr)
Definition: vm.c:380
#define NULL
Definition: _sdbm.c:102

Definition at line 405 of file vm.c.

VALUE rb_cEnv

Definition at line 99 of file vm.c.

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

VALUE rb_cRubyVM

Definition at line 97 of file vm.c.

Referenced by Init_ISeq(), and Init_VM().

VALUE rb_cThread

Definition at line 98 of file vm.c.

size_t rb_gc_stack_maxsize
VALUE* rb_gc_stack_start
VALUE rb_mRubyVMFrozenCore

Definition at line 100 of file vm.c.

Referenced by Init_VM(), mlambda(), mproc(), and rb_threadptr_exec_event_hooks_orig().

rb_thread_t* ruby_current_thread = 0

Definition at line 104 of file vm.c.

Referenced by GET_THREAD().

rb_vm_t* ruby_current_vm = 0

Definition at line 105 of file vm.c.

Referenced by Init_VM().

const rb_data_type_t ruby_threadptr_data_type
Initial value:
= {
"VM/thread",
{
},
}
static void thread_free(void *ptr)
Definition: vm.c:2087
void rb_thread_mark(void *th)
Definition: vm.c:2018
static size_t thread_memsize(const void *ptr)
Definition: vm.c:2128
#define RUBY_TYPED_FREE_IMMEDIATELY
#define NULL
Definition: _sdbm.c:102

Definition at line 2148 of file vm.c.

rb_serial_t ruby_vm_class_serial = 1
static

Definition at line 76 of file vm.c.

Referenced by vm_stat().

void(* ruby_vm_collect_usage_func_insn)(int insn) = NULL

Definition at line 3046 of file vm.c.

void(* ruby_vm_collect_usage_func_operand)(int insn, int n, VALUE op) = NULL

Definition at line 3047 of file vm.c.

void(* ruby_vm_collect_usage_func_register)(int reg, int isset) = NULL

Definition at line 3048 of file vm.c.

VALUE ruby_vm_const_missing_count = 0

Definition at line 102 of file vm.c.

Referenced by rb_vm_inc_const_missing_count().

rb_event_flag_t ruby_vm_event_flags

Definition at line 106 of file vm.c.

Referenced by recalc_add_ruby_vm_event_flags(), and recalc_remove_ruby_vm_event_flags().

rb_serial_t ruby_vm_global_constant_state = 1
static

Definition at line 75 of file vm.c.

Referenced by vm_stat().

rb_serial_t ruby_vm_global_method_state = 1
static

Definition at line 74 of file vm.c.

Referenced by vm_stat().

short ruby_vm_redefined_flag[BOP_LAST_]

Definition at line 103 of file vm.c.

Referenced by rb_vm_check_redefinition_opt_method().

int thread_recycle_stack_count = 0
static

Definition at line 1977 of file vm.c.

Referenced by thread_recycle_stack().

VALUE* thread_recycle_stack_slot[RECYCLE_MAX]
static

Definition at line 1976 of file vm.c.

const rb_data_type_t vm_data_type
static
Initial value:
= {
"VM",
}
static size_t vm_memsize(const void *ptr)
Definition: vm.c:1856
void rb_vm_mark(void *ptr)
Definition: vm.c:1766
#define RUBY_TYPED_FREE_IMMEDIATELY
#define vm_free
Definition: vm.c:1819
#define NULL
Definition: _sdbm.c:102

Definition at line 1874 of file vm.c.

st_table* vm_opt_method_table = 0
static

Definition at line 1167 of file vm.c.