Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
Macros | Functions | Variables
vm.c File Reference
#include "internal.h"
#include "ruby/vm.h"
#include "ruby/st.h"
#include "gc.h"
#include "vm_core.h"
#include "vm_debug.h"
#include "iseq.h"
#include "eval_intern.h"
#include "builtin.h"
#include "probes.h"
#include "probes_helper.h"
#include "mjit.h"
#include "vm_insnhelper.h"
#include "vm_exec.h"
#include "vm_insnhelper.c"
#include "vm_exec.c"
#include "vm_method.c"
#include "vm_eval.c"
#include "vm_call_iseq_optimized.inc"

Go to the source code of this file.

Macros

#define vm_exec   rb_vm_exec
 
#define PROCDEBUG   0
 
#define ruby_vm_redefined_flag   GET_VM()->redefined_flag
 
#define S(s)   sym_##s = ID2SYM(rb_intern_const(#s))
 
#define SET(name, attr)
 
#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 SET(name)   rb_hash_aset(result, ID2SYM(rb_intern(#name)), SIZET2NUM(vm->default_params.name));
 
#define thread_data_type   ruby_threadptr_data_type
 
#define REWIND_CFP(expr)
 

Functions

VALUE rb_str_concat_literals (size_t, const VALUE *)
 
MJIT_FUNC_EXPORTED VALUE vm_exec (rb_execution_context_t *, int)
 
 PUREFUNC (static inline const VALUE *VM_EP_LEP(const VALUE *))
 
const VALUErb_vm_ep_local_ep (const VALUE *ep)
 
 PUREFUNC (static inline const VALUE *VM_CF_LEP(const rb_control_frame_t *const cfp))
 
 PUREFUNC (static inline VALUE VM_CF_BLOCK_HANDLER(const rb_control_frame_t *const cfp))
 
int rb_vm_cframe_keyword_p (const rb_control_frame_t *cfp)
 
int rb_vm_cframe_empty_keyword_p (const rb_control_frame_t *cfp)
 
VALUE rb_vm_frame_block_handler (const rb_control_frame_t *cfp)
 
rb_cref_trb_vm_cref_new_toplevel (void)
 
void rb_vm_block_ep_update (VALUE obj, const struct rb_block *dst, const VALUE *ep)
 
VALUE rb_vm_invoke_bmethod (rb_execution_context_t *ec, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE block_handler, const rb_callable_method_entry_t *me)
 
rb_serial_t rb_next_class_serial (void)
 
void rb_vm_inc_const_missing_count (void)
 
MJIT_FUNC_EXPORTED int rb_dtrace_setup (rb_execution_context_t *ec, VALUE klass, ID id, struct ruby_dtrace_method_hook_args *args)
 
rb_control_frame_trb_vm_get_binding_creatable_next_cfp (const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
 
MJIT_FUNC_EXPORTED rb_control_frame_trb_vm_get_ruby_level_next_cfp (const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
 
MJIT_STATIC void rb_vm_pop_cfunc_frame (void)
 
void rb_vm_rewind_cfp (rb_execution_context_t *ec, 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...
 
void rb_vm_stack_to_heap (rb_execution_context_t *ec)
 
const rb_env_trb_vm_env_prev_env (const rb_env_t *env)
 
VALUE rb_vm_env_local_variables (const rb_env_t *env)
 
VALUE rb_iseq_local_variables (const rb_iseq_t *iseq)
 
void rb_vm_block_copy (VALUE obj, const struct rb_block *dst, const struct rb_block *src)
 
VALUE rb_proc_dup (VALUE self)
 
MJIT_FUNC_EXPORTED VALUE rb_vm_make_proc_lambda (const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda)
 
VALUE rb_vm_make_binding (const rb_execution_context_t *ec, const rb_control_frame_t *src_cfp)
 
const VALUErb_binding_add_dynavars (VALUE bindval, rb_binding_t *bind, int dyncount, const ID *dynvars)
 
 ALWAYS_INLINE (static VALUE invoke_iseq_block_from_c(rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE passed_block_handler, const rb_cref_t *cref, int is_lambda, const rb_callable_method_entry_t *me))
 
 ALWAYS_INLINE (static VALUE invoke_block_from_c_proc(rb_execution_context_t *ec, const rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE passed_block_handler, int is_lambda, const rb_callable_method_entry_t *me))
 
MJIT_FUNC_EXPORTED VALUE rb_vm_invoke_proc (rb_execution_context_t *ec, rb_proc_t *proc, int argc, const VALUE *argv, int kw_splat, VALUE passed_block_handler)
 
VALUE rb_backref_get (void)
 
void rb_backref_set (VALUE val)
 
VALUE rb_lastline_get (void)
 
void rb_lastline_set (VALUE val)
 
const charrb_sourcefile (void)
 
int rb_sourceline (void)
 
VALUE rb_source_location (int *pline)
 
MJIT_FUNC_EXPORTED const charrb_source_location_cstr (int *pline)
 
rb_cref_trb_vm_cref (void)
 
rb_cref_trb_vm_cref_replace_with_duplicated_cref (void)
 
const rb_cref_trb_vm_cref_in_context (VALUE self, VALUE cbase)
 
VALUE rb_vm_cbase (void)
 
MJIT_FUNC_EXPORTED 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_execution_context_t *ec, VALUE val))
 
void rb_iter_break (void)
 
void rb_iter_break_value (VALUE val)
 
int rb_vm_check_optimizable_mid (VALUE mid)
 
void rb_vm_check_redefinition_by_prepend (VALUE klass)
 
VALUE rb_iseq_eval (const rb_iseq_t *iseq)
 
VALUE rb_iseq_eval_main (const rb_iseq_t *iseq)
 
int rb_vm_control_frame_id_and_class (const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp)
 
int rb_ec_frame_method_id_and_class (const rb_execution_context_t *ec, ID *idp, ID *called_idp, VALUE *klassp)
 
int rb_frame_method_id_and_class (ID *idp, VALUE *klassp)
 
VALUE rb_vm_call_cfunc (VALUE recv, VALUE(*func)(VALUE), VALUE arg, VALUE block_handler, VALUE filename)
 
void rb_vm_update_references (void *ptr)
 
void rb_vm_mark (void *ptr)
 
void rb_vm_register_special_exception_str (enum ruby_special_exceptions sp, VALUE cls, VALUE mesg)
 
int rb_vm_add_root_module (ID id, VALUE module)
 
int ruby_vm_destruct (rb_vm_t *vm)
 
void rb_execution_context_update (const rb_execution_context_t *ec)
 
void rb_execution_context_mark (const rb_execution_context_t *ec)
 
void rb_fiber_mark_self (rb_fiber_t *fib)
 
void rb_fiber_update_self (rb_fiber_t *fib)
 
void rb_threadptr_root_fiber_setup (rb_thread_t *th)
 
void rb_threadptr_root_fiber_release (rb_thread_t *th)
 
VALUE rb_obj_is_thread (VALUE obj)
 
void rb_ec_set_vm_stack (rb_execution_context_t *ec, VALUE *stack, size_t size)
 
void rb_ec_initialize_vm_stack (rb_execution_context_t *ec, VALUE *stack, size_t size)
 
void rb_ec_clear_vm_stack (rb_execution_context_t *ec)
 
VALUE rb_thread_alloc (VALUE klass)
 
void Init_VM (void)
 
void rb_vm_set_progname (VALUE filename)
 
void Init_BareVM (void)
 
void Init_vm_objects (void)
 
VALUE rb_vm_top_self (void)
 
void Init_top_self (void)
 
VALUErb_ruby_verbose_ptr (void)
 
VALUErb_ruby_debug_ptr (void)
 
VALUE rb_insn_operand_intern (const rb_iseq_t *iseq, VALUE insn, int op_no, VALUE op, int len, size_t pos, VALUE *pnop, VALUE child)
 
st_tablerb_vm_fstring_table (void)
 
 MAYBE_UNUSED (static void(*ruby_vm_collect_usage_func_insn)(int insn))
 
 MAYBE_UNUSED (static void(*ruby_vm_collect_usage_func_operand)(int insn, int n, VALUE op))
 
 MAYBE_UNUSED (static void(*ruby_vm_collect_usage_func_register)(int reg, int isset))
 

Variables

VALUE rb_cRubyVM
 
VALUE rb_cThread
 
VALUE rb_mRubyVMFrozenCore
 
VALUE rb_block_param_proxy
 
VALUE ruby_vm_const_missing_count = 0
 
rb_vm_truby_current_vm_ptr = NULL
 
rb_execution_context_truby_current_execution_context_ptr = NULL
 
rb_event_flag_t ruby_vm_event_flags
 
rb_event_flag_t ruby_vm_event_enabled_global_flags
 
unsigned int ruby_vm_event_local_num
 
rb_serial_t ruby_vm_global_method_state = 1
 
rb_serial_t ruby_vm_global_constant_state = 1
 
rb_serial_t ruby_vm_class_serial = 1
 
const rb_data_type_t ruby_threadptr_data_type
 
VALUErb_gc_stack_start
 
size_t rb_gc_stack_maxsize
 
const struct st_hash_type rb_fstring_hash_type
 

Macro Definition Documentation

◆ C

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

◆ OP

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

◆ PROCDEBUG

#define PROCDEBUG   0

Definition at line 355 of file vm.c.

◆ REWIND_CFP

#define REWIND_CFP (   expr)
Value:
do { \
rb_execution_context_t *ec__ = GET_EC(); \
VALUE *const curr_sp = (ec__->cfp++)->sp; \
VALUE *const saved_sp = ec__->cfp->sp; \
ec__->cfp->sp = curr_sp; \
expr; \
(ec__->cfp--)->sp = saved_sp; \
} while (0)
#define GET_EC()

Definition at line 2765 of file vm.c.

◆ ruby_vm_redefined_flag

#define ruby_vm_redefined_flag   GET_VM()->redefined_flag

Definition at line 370 of file vm.c.

◆ S

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

◆ SET [1/2]

#define SET (   name)    rb_hash_aset(result, ID2SYM(rb_intern(#name)), SIZET2NUM(vm->default_params.name));

◆ SET [2/2]

#define SET (   name,
  attr 
)
Value:
if (key == sym_##name) \
return SERIALT2NUM(attr); \
else if (hash != Qnil) \
rb_hash_aset(hash, sym_##name, SERIALT2NUM(attr));
const char * name
Definition: nkf.c:208
#define SERIALT2NUM
#define Qnil

◆ thread_data_type

#define thread_data_type   ruby_threadptr_data_type

Definition at line 2644 of file vm.c.

◆ vm_exec

#define vm_exec   rb_vm_exec

Definition at line 15 of file vm.c.

Function Documentation

◆ ALWAYS_INLINE() [1/2]

ALWAYS_INLINE ( static VALUE   invoke_block_from_c_procrb_execution_context_t *ec, const rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE passed_block_handler, int is_lambda, const rb_callable_method_entry_t *me)

◆ ALWAYS_INLINE() [2/2]

ALWAYS_INLINE ( static VALUE   invoke_iseq_block_from_crb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE self, int argc, const VALUE *argv, int kw_splat, VALUE passed_block_handler, const rb_cref_t *cref, int is_lambda, const rb_callable_method_entry_t *me)

◆ Init_BareVM()

void Init_BareVM ( void  )

Definition at line 3303 of file vm.c.

References exit(), EXIT_FAILURE, fprintf(), MEMZERO, ruby_mimmalloc(), and stderr.

Referenced by ruby_setup().

◆ Init_top_self()

void Init_top_self ( void  )

◆ Init_VM()

void Init_VM ( void  )

◆ Init_vm_objects()

void Init_vm_objects ( void  )

◆ MAYBE_UNUSED() [1/3]

MAYBE_UNUSED ( static void(*)(int insn)  ruby_vm_collect_usage_func_insn)

◆ MAYBE_UNUSED() [2/3]

MAYBE_UNUSED ( static void(*)(int insn, int n, VALUE op)  ruby_vm_collect_usage_func_operand)

◆ MAYBE_UNUSED() [3/3]

MAYBE_UNUSED ( static void(*)(int reg, int isset ruby_vm_collect_usage_func_register)

◆ NORETURN()

NORETURN ( static void   vm_iter_breakrb_execution_context_t *ec, VALUE val)

◆ PUREFUNC() [1/3]

PUREFUNC ( static inline const VALUE VM_CF_LEPconst rb_control_frame_t *const cfp)

◆ PUREFUNC() [2/3]

PUREFUNC ( static inline const VALUE VM_EP_LEPconst VALUE *)

◆ PUREFUNC() [3/3]

PUREFUNC ( static inline VALUE   VM_CF_BLOCK_HANDLERconst rb_control_frame_t *const cfp)

◆ rb_backref_get()

VALUE rb_backref_get ( void  )

Definition at line 1304 of file vm.c.

Referenced by rb_f_global_variables().

◆ rb_backref_set()

void rb_backref_set ( VALUE  val)

Definition at line 1310 of file vm.c.

Referenced by rb_reg_match2().

◆ rb_binding_add_dynavars()

const VALUE * rb_binding_add_dynavars ( VALUE  bindval,
rb_binding_t bind,
int  dyncount,
const ID dynvars 
)

Definition at line 984 of file vm.c.

References path, and rb_binding_t::pathobj.

◆ rb_dtrace_setup()

MJIT_FUNC_EXPORTED int rb_dtrace_setup ( rb_execution_context_t ec,
VALUE  klass,
ID  id,
struct ruby_dtrace_method_hook_args args 
)

◆ rb_ec_clear_vm_stack()

void rb_ec_clear_vm_stack ( rb_execution_context_t ec)

Definition at line 2701 of file vm.c.

References rb_execution_context_struct::cfp, NULL, and rb_ec_set_vm_stack().

Referenced by rb_threadptr_root_fiber_terminate().

◆ rb_ec_frame_method_id_and_class()

int rb_ec_frame_method_id_and_class ( const rb_execution_context_t ec,
ID idp,
ID called_idp,
VALUE klassp 
)

◆ rb_ec_initialize_vm_stack()

void rb_ec_initialize_vm_stack ( rb_execution_context_t ec,
VALUE stack,
size_t  size 
)

◆ rb_ec_set_vm_stack()

void rb_ec_set_vm_stack ( rb_execution_context_t ec,
VALUE stack,
size_t  size 
)
inline

◆ rb_execution_context_mark()

void rb_execution_context_mark ( const rb_execution_context_t ec)

◆ rb_execution_context_update()

void rb_execution_context_update ( const rb_execution_context_t ec)

◆ rb_fiber_mark_self()

void rb_fiber_mark_self ( rb_fiber_t fib)

◆ rb_fiber_update_self()

void rb_fiber_update_self ( rb_fiber_t fib)

◆ rb_frame_method_id_and_class()

int rb_frame_method_id_and_class ( ID idp,
VALUE klassp 
)

Definition at line 2206 of file vm.c.

References GET_EC, and rb_ec_frame_method_id_and_class().

◆ rb_insn_operand_intern()

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

◆ rb_iseq_eval()

VALUE rb_iseq_eval ( const rb_iseq_t iseq)

Definition at line 2163 of file vm.c.

References GET_EC.

◆ rb_iseq_eval_main()

VALUE rb_iseq_eval_main ( const rb_iseq_t iseq)

Definition at line 2173 of file vm.c.

References GET_EC.

◆ rb_iseq_local_variables()

VALUE rb_iseq_local_variables ( const rb_iseq_t iseq)

Definition at line 849 of file vm.c.

References vars.

Referenced by rb_iseqw_local_variables().

◆ rb_iter_break()

void rb_iter_break ( void  )

Definition at line 1546 of file vm.c.

◆ rb_iter_break_value()

void rb_iter_break_value ( VALUE  val)

Definition at line 1552 of file vm.c.

◆ rb_lastline_get()

VALUE rb_lastline_get ( void  )

Definition at line 1316 of file vm.c.

Referenced by rb_io_print(), and rb_reg_match2().

◆ rb_lastline_set()

void rb_lastline_set ( VALUE  val)

Definition at line 1322 of file vm.c.

◆ rb_next_class_serial()

rb_serial_t rb_next_class_serial ( void  )

Definition at line 358 of file vm.c.

References mjit_add_class_serial(), and NEXT_CLASS_SERIAL.

◆ rb_obj_is_thread()

VALUE rb_obj_is_thread ( VALUE  obj)

Definition at line 2657 of file vm.c.

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

◆ rb_proc_dup()

VALUE rb_proc_dup ( VALUE  self)

Definition at line 920 of file vm.c.

References GetProcPtr, and src.

◆ rb_source_location()

VALUE rb_source_location ( int pline)

Definition at line 1360 of file vm.c.

References rb_execution_context_struct::cfp, cfp, GET_EC, and rb_vm_get_ruby_level_next_cfp().

Referenced by rb_source_location_cstr().

◆ rb_source_location_cstr()

MJIT_FUNC_EXPORTED const char * rb_source_location_cstr ( int pline)

Definition at line 1376 of file vm.c.

References NIL_P, NULL, path, rb_source_location(), and RSTRING_PTR.

Referenced by rb_bug(), rb_bug_for_fatal_signal(), and rb_set_safe_level().

◆ rb_sourcefile()

const char * rb_sourcefile ( void  )

◆ rb_sourceline()

int rb_sourceline ( void  )

◆ rb_str_concat_literals()

VALUE rb_str_concat_literals ( size_t  num,
const VALUE strary 
)

Definition at line 2974 of file string.c.

◆ rb_thread_alloc()

VALUE rb_thread_alloc ( VALUE  klass)

Definition at line 2758 of file vm.c.

◆ rb_threadptr_root_fiber_release()

void rb_threadptr_root_fiber_release ( rb_thread_t th)

◆ rb_threadptr_root_fiber_setup()

void rb_threadptr_root_fiber_setup ( rb_thread_t th)

◆ rb_vm_add_root_module()

int rb_vm_add_root_module ( ID  id,
VALUE  module 
)

◆ rb_vm_block_copy()

void rb_vm_block_copy ( VALUE  obj,
const struct rb_block dst,
const struct rb_block src 
)

Definition at line 885 of file vm.c.

◆ rb_vm_block_ep_update()

void rb_vm_block_ep_update ( VALUE  obj,
const struct rb_block dst,
const VALUE ep 
)

Definition at line 315 of file vm.c.

References rb_block::as, rb_block::captured, rb_captured_block::ep, obj, Qundef, and RB_OBJ_WRITTEN.

◆ rb_vm_call_cfunc()

VALUE rb_vm_call_cfunc ( VALUE  recv,
VALUE(*)(VALUE func,
VALUE  arg,
VALUE  block_handler,
VALUE  filename 
)

Definition at line 2212 of file vm.c.

References rb_execution_context_struct::cfp, GET_EC, iseq, Qnil, rb_iseq_new(), and reg_cfp.

◆ rb_vm_cbase()

VALUE rb_vm_cbase ( void  )

◆ rb_vm_cframe_empty_keyword_p()

int rb_vm_cframe_empty_keyword_p ( const rb_control_frame_t cfp)

Definition at line 109 of file vm.c.

Referenced by rb_empty_keyword_given_p().

◆ rb_vm_cframe_keyword_p()

int rb_vm_cframe_keyword_p ( const rb_control_frame_t cfp)

Definition at line 102 of file vm.c.

Referenced by rb_keyword_given_p().

◆ rb_vm_check_optimizable_mid()

int rb_vm_check_optimizable_mid ( VALUE  mid)

Definition at line 1581 of file vm.c.

◆ rb_vm_check_redefinition_by_prepend()

void rb_vm_check_redefinition_by_prepend ( VALUE  klass)

Definition at line 1631 of file vm.c.

◆ rb_vm_control_frame_id_and_class()

int rb_vm_control_frame_id_and_class ( const rb_control_frame_t cfp,
ID idp,
ID called_idp,
VALUE klassp 
)

Definition at line 2184 of file vm.c.

References me.

Referenced by rb_ec_frame_method_id_and_class().

◆ rb_vm_cref()

rb_cref_t * rb_vm_cref ( void  )

Definition at line 1384 of file vm.c.

References GET_EC.

◆ rb_vm_cref_in_context()

const rb_cref_t * rb_vm_cref_in_context ( VALUE  self,
VALUE  cbase 
)

◆ rb_vm_cref_new_toplevel()

rb_cref_t * rb_vm_cref_new_toplevel ( void  )

Definition at line 298 of file vm.c.

◆ rb_vm_cref_replace_with_duplicated_cref()

rb_cref_t * rb_vm_cref_replace_with_duplicated_cref ( void  )

Definition at line 1391 of file vm.c.

References rb_execution_context_struct::cfp, cfp, GET_EC, and rb_vm_get_ruby_level_next_cfp().

◆ rb_vm_env_local_variables()

VALUE rb_vm_env_local_variables ( const rb_env_t env)

Definition at line 840 of file vm.c.

References vars.

◆ rb_vm_env_prev_env()

const rb_env_t * rb_vm_env_prev_env ( const rb_env_t env)

Definition at line 796 of file vm.c.

References env.

Referenced by rb_vmdebug_env_dump_raw().

◆ rb_vm_ep_local_ep()

const VALUE * rb_vm_ep_local_ep ( const VALUE ep)

Definition at line 75 of file vm.c.

◆ rb_vm_frame_block_handler()

VALUE rb_vm_frame_block_handler ( const rb_control_frame_t cfp)

Definition at line 115 of file vm.c.

◆ rb_vm_fstring_table()

st_table * rb_vm_fstring_table ( void  )

Definition at line 3394 of file vm.c.

References GET_VM.

Referenced by Init_String(), and rb_str_free().

◆ rb_vm_get_binding_creatable_next_cfp()

rb_control_frame_t * rb_vm_get_binding_creatable_next_cfp ( const rb_execution_context_t ec,
const rb_control_frame_t cfp 
)

Definition at line 541 of file vm.c.

Referenced by rb_tracearg_binding(), rb_vm_make_binding(), and rb_vm_stack_to_heap().

◆ rb_vm_get_ruby_level_next_cfp()

MJIT_FUNC_EXPORTED rb_control_frame_t * rb_vm_get_ruby_level_next_cfp ( const rb_execution_context_t ec,
const rb_control_frame_t cfp 
)

◆ rb_vm_inc_const_missing_count()

void rb_vm_inc_const_missing_count ( void  )

Definition at line 386 of file vm.c.

References ruby_vm_const_missing_count.

Referenced by rb_const_missing().

◆ rb_vm_invoke_bmethod()

VALUE rb_vm_invoke_bmethod ( rb_execution_context_t ec,
rb_proc_t proc,
VALUE  self,
int  argc,
const VALUE argv,
int  kw_splat,
VALUE  block_handler,
const rb_callable_method_entry_t me 
)

Definition at line 1242 of file vm.c.

◆ rb_vm_invoke_proc()

MJIT_FUNC_EXPORTED VALUE rb_vm_invoke_proc ( rb_execution_context_t ec,
rb_proc_t proc,
int  argc,
const VALUE argv,
int  kw_splat,
VALUE  passed_block_handler 
)

◆ rb_vm_jump_tag_but_local_jump()

void rb_vm_jump_tag_but_local_jump ( int  state)

Definition at line 1510 of file vm.c.

References EC_JUMP_TAG, exc, GET_EC, NIL_P, Qundef, rb_exc_raise(), and rb_vm_make_jump_tag_but_local_jump().

◆ rb_vm_localjump_error()

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

Definition at line 1471 of file vm.c.

References exc.

Referenced by rb_need_block().

◆ rb_vm_make_binding()

VALUE rb_vm_make_binding ( const rb_execution_context_t ec,
const rb_control_frame_t src_cfp 
)

◆ rb_vm_make_jump_tag_but_local_jump()

VALUE rb_vm_make_jump_tag_but_local_jump ( int  state,
VALUE  val 
)

Definition at line 1478 of file vm.c.

References GET_EC, Qnil, Qundef, TAG_BREAK, TAG_NEXT, TAG_REDO, TAG_RETRY, and TAG_RETURN.

Referenced by rb_fiber_start(), and rb_vm_jump_tag_but_local_jump().

◆ rb_vm_make_proc_lambda()

MJIT_FUNC_EXPORTED VALUE rb_vm_make_proc_lambda ( const rb_execution_context_t ec,
const struct rb_captured_block captured,
VALUE  klass,
int8_t  is_lambda 
)

Definition at line 933 of file vm.c.

◆ rb_vm_mark()

void rb_vm_mark ( void ptr)

◆ rb_vm_pop_cfunc_frame()

MJIT_STATIC void rb_vm_pop_cfunc_frame ( void  )

Definition at line 590 of file vm.c.

References rb_execution_context_struct::cfp, cfp, GET_EC, and me.

◆ rb_vm_register_special_exception_str()

void rb_vm_register_special_exception_str ( enum ruby_special_exceptions  sp,
VALUE  cls,
VALUE  mesg 
)

◆ rb_vm_rewind_cfp()

void rb_vm_rewind_cfp ( rb_execution_context_t ec,
rb_control_frame_t cfp 
)

Definition at line 604 of file vm.c.

References rb_execution_context_struct::cfp, cfp, and printf().

◆ rb_vm_set_progname()

void rb_vm_set_progname ( VALUE  filename)

◆ rb_vm_stack_to_heap()

void rb_vm_stack_to_heap ( rb_execution_context_t ec)

◆ rb_vm_top_self()

VALUE rb_vm_top_self ( void  )

Definition at line 3349 of file vm.c.

References GET_VM.

Referenced by Init_top_self(), and rb_eval_string_wrap().

◆ rb_vm_update_references()

void rb_vm_update_references ( void ptr)

Definition at line 2234 of file vm.c.

References rb_vm_struct::frozen_strings, ptr, and rb_gc_update_tbl_refs().

◆ ruby_vm_at_exit()

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]functhe function to register.

Definition at line 623 of file vm.c.

References ALLOC, rb_vm_struct::at_exit, rb_at_exit_list::func, GET_VM, and rb_at_exit_list::next.

◆ ruby_vm_destruct()

int ruby_vm_destruct ( rb_vm_t vm)

◆ vm_exec()

VALUE vm_exec ( rb_execution_context_t ec,
int  mjit_enable_p 
)

Definition at line 1909 of file vm.c.

Variable Documentation

◆ rb_block_param_proxy

VALUE rb_block_param_proxy

Definition at line 368 of file vm.c.

◆ rb_cRubyVM

VALUE rb_cRubyVM

Definition at line 365 of file vm.c.

Referenced by Init_VM().

◆ rb_fstring_hash_type

const struct st_hash_type rb_fstring_hash_type
extern

Definition at line 260 of file string.c.

Referenced by Init_vm_objects().

◆ rb_gc_stack_maxsize

size_t rb_gc_stack_maxsize
extern

◆ rb_gc_stack_start

VALUE* rb_gc_stack_start
extern

◆ rb_mRubyVMFrozenCore

VALUE rb_mRubyVMFrozenCore

Definition at line 367 of file vm.c.

◆ ruby_current_execution_context_ptr

rb_execution_context_t* ruby_current_execution_context_ptr = NULL

Definition at line 373 of file vm.c.

◆ ruby_current_vm_ptr

rb_vm_t* ruby_current_vm_ptr = NULL

Definition at line 372 of file vm.c.

◆ ruby_threadptr_data_type

const rb_data_type_t ruby_threadptr_data_type
Initial value:
= {
"VM/thread",
{
thread_mark,
thread_free,
thread_memsize,
thread_compact,
},
}
#define RUBY_TYPED_FREE_IMMEDIATELY

Definition at line 2645 of file vm.c.

◆ ruby_vm_class_serial

rb_serial_t ruby_vm_class_serial = 1

Definition at line 381 of file vm.c.

◆ ruby_vm_const_missing_count

VALUE ruby_vm_const_missing_count = 0

Definition at line 371 of file vm.c.

Referenced by rb_vm_inc_const_missing_count().

◆ ruby_vm_event_enabled_global_flags

rb_event_flag_t ruby_vm_event_enabled_global_flags

Definition at line 376 of file vm.c.

◆ ruby_vm_event_flags

rb_event_flag_t ruby_vm_event_flags

Definition at line 375 of file vm.c.

◆ ruby_vm_event_local_num

unsigned int ruby_vm_event_local_num

Definition at line 377 of file vm.c.

◆ ruby_vm_global_constant_state

rb_serial_t ruby_vm_global_constant_state = 1

Definition at line 380 of file vm.c.

◆ ruby_vm_global_method_state

rb_serial_t ruby_vm_global_method_state = 1

Definition at line 379 of file vm.c.