Ruby
2.5.0dev(2017-10-22revision60238)
|
#include "internal.h"
#include "ruby/vm.h"
#include "ruby/st.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_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 | 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 | USE_THREAD_DATA_RECYCLE 1 |
#define | RECYCLE_MAX 64 |
#define | thread_data_type ruby_threadptr_data_type |
#define | REWIND_CFP(expr) |
Variables | |
VALUE | rb_cRubyVM |
VALUE | rb_cThread |
VALUE | rb_mRubyVMFrozenCore |
VALUE | ruby_vm_const_missing_count = 0 |
rb_thread_t * | ruby_current_thread = 0 |
rb_vm_t * | ruby_current_vm = 0 |
rb_event_flag_t | ruby_vm_event_flags |
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 |
VALUE * | rb_gc_stack_start |
size_t | rb_gc_stack_maxsize |
const struct st_hash_type | rb_fstring_hash_type |
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 |
#define C | ( | k | ) | add_opt_method(rb_c##k, mid, bop) |
#define OP | ( | mid_, | |
bop_ | |||
) | (mid = id##mid_, bop = BOP_##bop_, ruby_vm_redefined_flag[bop] = 0) |
#define RECYCLE_MAX 64 |
Definition at line 2334 of file vm.c.
Referenced by rb_thread_recycle_stack_release().
#define REWIND_CFP | ( | expr | ) |
#define S | ( | s | ) | sym_##s = ID2SYM(rb_intern_const(#s)) |
#define SET | ( | name, | |
attr | |||
) |
#define SET | ( | name | ) | rb_hash_aset(result, ID2SYM(rb_intern(#name)), SIZET2NUM(vm->default_params.name)); |
#define thread_data_type ruby_threadptr_data_type |
Definition at line 2494 of file vm.c.
Referenced by rb_obj_is_thread().
void Init_BareVM | ( | void | ) |
Definition at line 3122 of file vm.c.
References EXIT_FAILURE, MEMZERO, rb_thread_set_current_raw, and ruby_mimmalloc().
Referenced by ruby_setup().
void Init_top_self | ( | void | ) |
Definition at line 3172 of file vm.c.
References GET_VM, 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 2820 of file vm.c.
References CLASS_OF, rb_cObject, rb_define_class(), rb_define_singleton_method(), rb_undef_alloc_func(), and rb_undef_method().
void Init_vm_objects | ( | void | ) |
Definition at line 3145 of file vm.c.
References rb_vm_struct::defined_module_hash, rb_vm_struct::frozen_strings, GET_VM, rb_vm_struct::loading_table, rb_vm_struct::mark_object_ary, rb_ary_tmp_new(), rb_hash_new(), st_init_strtable, and st_init_table_with_size.
Referenced by ruby_setup().
NORETURN | ( | static void | vm_iter_breakrb_thread_t *th, VALUE val | ) |
PUREFUNC | ( | static inline VALUE | VM_CF_BLOCK_HANDLERconst rb_control_frame_t *const cfp | ) |
VALUE rb_backref_get | ( | void | ) |
Definition at line 1229 of file vm.c.
Referenced by rb_f_global_variables().
void rb_backref_set | ( | VALUE | val | ) |
Definition at line 1235 of file vm.c.
Referenced by rb_reg_match2().
const VALUE* rb_binding_add_dynavars | ( | VALUE | bindval, |
rb_binding_t * | bind, | ||
int | dyncount, | ||
const ID * | dynvars | ||
) |
Definition at line 926 of file vm.c.
References rb_binding_t::pathobj.
Definition at line 310 of file variable.c.
References fc_result::path.
Referenced by rb_vm_inc_const_missing_count(), and ruby_th_dtrace_setup().
void rb_execution_context_mark | ( | const rb_execution_context_t * | ec | ) |
Definition at line 2371 of file vm.c.
References rb_execution_context_struct::cfp, rb_control_frame_struct::ep, rb_gc_mark_values(), rb_control_frame_struct::sp, VM_ASSERT, rb_execution_context_struct::vm_stack, and rb_execution_context_struct::vm_stack_size.
Referenced by rb_thread_mark().
void rb_fiber_mark_self | ( | rb_fiber_t * | fib | ) |
Referenced by rb_thread_mark(), and rb_thread_recycle_stack_release().
Definition at line 2070 of file vm.c.
References GET_THREAD, and rb_thread_method_id_and_class().
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 | ||
) |
Definition at line 2027 of file vm.c.
References GET_THREAD, and rb_captured_block::val.
Definition at line 2037 of file vm.c.
References GET_THREAD, and rb_captured_block::val.
Definition at line 794 of file vm.c.
Referenced by rb_iseqw_local_variables().
VALUE rb_lastline_get | ( | void | ) |
Definition at line 1241 of file vm.c.
Referenced by rb_io_print(), and rb_reg_match2().
rb_serial_t rb_next_class_serial | ( | void | ) |
Definition at line 309 of file vm.c.
References NEXT_CLASS_SERIAL.
Definition at line 2506 of file vm.c.
References Qfalse, Qtrue, rb_typeddata_is_kind_of(), and thread_data_type.
VALUE rb_proc_create | ( | VALUE | klass, |
const struct rb_block * | block, | ||
int8_t | safe_level, | ||
int8_t | is_from_method, | ||
int8_t | is_lambda | ||
) |
Definition at line 851 of file vm.c.
References GET_THREAD, rb_proc_alloc(), RTYPEDDATA_DATA, and VM_ASSERT.
Referenced by rb_obj_is_proc().
VALUE rb_proc_create_from_captured | ( | VALUE | klass, |
const struct rb_captured_block * | captured, | ||
enum rb_block_type | block_type, | ||
int8_t | safe_level, | ||
int8_t | is_from_method, | ||
int8_t | is_lambda | ||
) |
Definition at line 807 of file vm.c.
References rb_block::as, rb_proc_t::block, rb_block::captured, rb_captured_block::code, rb_captured_block::ep, GET_THREAD, RB_OBJ_WRITE, rb_proc_alloc(), rb_vm_block_ep_update(), RTYPEDDATA_DATA, rb_captured_block::self, rb_captured_block::val, and VM_ASSERT.
const char* rb_source_loc | ( | int * | pline | ) |
Definition at line 1313 of file vm.c.
References rb_source_location(), and RSTRING_PTR.
Referenced by rb_bug(), and rb_bug_context().
VALUE rb_source_location | ( | int * | pline | ) |
Definition at line 1297 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, rb_control_frame_struct::iseq, rb_iseq_path(), rb_vm_get_ruby_level_next_cfp(), and rb_vm_get_sourceline().
Referenced by rb_source_loc().
const char* rb_sourcefile | ( | void | ) |
Definition at line 1269 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, rb_control_frame_struct::iseq, rb_iseq_path(), rb_vm_get_ruby_level_next_cfp(), and RSTRING_PTR.
VALUE rb_sourcefilename | ( | void | ) |
Definition at line 1255 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, rb_control_frame_struct::iseq, Qnil, rb_iseq_path(), and rb_vm_get_ruby_level_next_cfp().
int rb_sourceline | ( | void | ) |
Definition at line 1283 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, rb_vm_get_ruby_level_next_cfp(), and rb_vm_get_sourceline().
Definition at line 2909 of file string.c.
References ENC_CODERANGE, ENCINDEX_US_ASCII, ENCODING_GET, ENCODING_GET_INLINED, LIKELY, MIN_PRE_ALLOC_SIZE, NULL, OBJ_INFECT_RAW, rb_enc_copy(), rb_enc_set_index(), rb_str_buf_new(), rb_str_new(), rb_str_resurrect(), RSTRING_LEN, RSTRING_PTR, and UNLIKELY.
VALUE rb_thread_current_status | ( | const rb_thread_t * | th | ) |
Definition at line 2076 of file vm.c.
References rb_iseq_struct::body, rb_execution_context_struct::cfp, rb_callable_method_entry_struct::def, rb_thread_struct::ec, rb_control_frame_struct::iseq, rb_iseq_location_struct::label, rb_iseq_constant_body::location, rb_callable_method_entry_struct::owner, rb_control_frame_struct::pc, PRIsVALUE, Qnil, rb_class_path(), rb_id2str, rb_iseq_path(), rb_sprintf(), rb_vm_frame_method_entry(), and rb_vm_get_sourceline().
void rb_thread_mark | ( | void * | ptr | ) |
Definition at line 2413 of file vm.c.
References rb_thread_struct::ec, rb_thread_struct::event_hooks, rb_thread_struct::first_args, rb_thread_struct::first_proc, rb_thread_struct::last_status, rb_thread_struct::locking_mutex, rb_thread_struct::name, rb_thread_struct::pending_interrupt_mask_stack, rb_thread_struct::pending_interrupt_queue, rb_execution_context_mark(), rb_fiber_mark_self(), rb_vm_trace_mark_event_hooks(), rb_thread_struct::root_fiber, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_UNLESS_NULL, rb_thread_struct::stat_insn_usage, rb_thread_struct::thgroup, rb_thread_struct::top_self, rb_thread_struct::top_wrapper, and rb_thread_struct::value.
int rb_thread_method_id_and_class | ( | rb_thread_t * | th, |
ID * | idp, | ||
ID * | called_idp, | ||
VALUE * | klassp | ||
) |
Definition at line 2064 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, and rb_vm_control_frame_id_and_class().
Referenced by rb_frame_method_id_and_class(), and ruby_th_dtrace_setup().
void rb_thread_recycle_stack_release | ( | VALUE * | stack | ) |
Definition at line 2355 of file vm.c.
References NULL, rb_fiber_mark_self(), RECYCLE_MAX, ruby_xfree(), and VM_ASSERT.
Definition at line 2172 of file vm.c.
References rb_vm_struct::defined_module_hash, GET_VM, ID2SYM, rb_hash_aset(), and TRUE.
Referenced by rb_define_class(), and rb_define_module().
Definition at line 271 of file vm.c.
References rb_block::as, rb_block::captured, rb_captured_block::ep, Qundef, and RB_OBJ_WRITTEN.
Referenced by rb_proc_create_from_captured().
VALUE rb_vm_call_cfunc | ( | VALUE | recv, |
VALUE(*)(VALUE) | func, | ||
VALUE | arg, | ||
VALUE | block_handler, | ||
VALUE | filename | ||
) |
Definition at line 2100 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, Qnil, rb_iseq_new(), and rb_captured_block::val.
VALUE rb_vm_cbase | ( | void | ) |
Definition at line 1368 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, rb_eRuntimeError, rb_raise(), and rb_vm_get_ruby_level_next_cfp().
int rb_vm_control_frame_id_and_class | ( | const rb_control_frame_t * | cfp, |
ID * | idp, | ||
ID * | called_idp, | ||
VALUE * | klassp | ||
) |
Definition at line 2048 of file vm.c.
References rb_callable_method_entry_struct::called_id, rb_callable_method_entry_struct::def, FALSE, rb_callable_method_entry_struct::owner, rb_vm_frame_method_entry(), and TRUE.
Referenced by rb_thread_method_id_and_class().
rb_cref_t* rb_vm_cref | ( | void | ) |
Definition at line 1321 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, NULL, and rb_vm_get_ruby_level_next_cfp().
Definition at line 1343 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, NULL, rb_vm_get_ruby_level_next_cfp(), and rb_control_frame_struct::self.
rb_cref_t* rb_vm_cref_replace_with_duplicated_cref | ( | void | ) |
Definition at line 1334 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, GET_THREAD, and rb_vm_get_ruby_level_next_cfp().
Definition at line 741 of file vm.c.
References rb_env_t::ep.
Referenced by rb_vmdebug_env_dump_raw().
VALUE rb_vm_frame_block_handler | ( | const rb_control_frame_t * | cfp | ) |
Definition at line 82 of file vm.c.
Referenced by rb_block_given_p(), and rb_block_min_max_arity().
st_table* rb_vm_fstring_table | ( | void | ) |
Definition at line 3211 of file vm.c.
References GET_VM.
Referenced by Init_String(), and rb_str_free().
rb_control_frame_t* rb_vm_get_binding_creatable_next_cfp | ( | const rb_thread_t * | th, |
const rb_control_frame_t * | cfp | ||
) |
Definition at line 486 of file vm.c.
References rb_control_frame_struct::iseq, RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P, and RUBY_VM_PREVIOUS_CONTROL_FRAME.
Referenced by rb_tracearg_binding(), rb_vm_make_binding(), and rb_vm_stack_to_heap().
rb_control_frame_t* rb_vm_get_ruby_level_next_cfp | ( | const rb_thread_t * | th, |
const rb_control_frame_t * | cfp | ||
) |
Definition at line 498 of file vm.c.
References RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P.
Referenced by rb_source_location(), rb_sourcefile(), rb_sourcefilename(), rb_sourceline(), rb_vm_cbase(), rb_vm_cref(), rb_vm_cref_in_context(), rb_vm_cref_replace_with_duplicated_cref(), and rb_vm_make_binding().
void rb_vm_inc_const_missing_count | ( | void | ) |
Definition at line 330 of file vm.c.
References rb_class_path_no_cache().
Referenced by rb_const_missing().
VALUE rb_vm_invoke_proc | ( | rb_thread_t * | th, |
rb_proc_t * | proc, | ||
int | argc, | ||
const VALUE * | argv, | ||
VALUE | passed_block_handler | ||
) |
Definition at line 1172 of file vm.c.
Referenced by rb_fiber_start(), rb_proc_call(), and rb_proc_call_with_block().
Definition at line 1414 of file vm.c.
Referenced by rb_need_block().
VALUE rb_vm_make_binding | ( | rb_thread_t * | th, |
const rb_control_frame_t * | src_cfp | ||
) |
Definition at line 895 of file vm.c.
References rb_eRuntimeError, rb_raise(), rb_vm_get_binding_creatable_next_cfp(), and rb_vm_get_ruby_level_next_cfp().
Referenced by rb_binding_new(), and rb_tracearg_binding().
Definition at line 1421 of file vm.c.
References GET_THREAD, Qnil, Qundef, TAG_BREAK, TAG_NEXT, TAG_REDO, TAG_RETRY, and TAG_RETURN.
Referenced by rb_fiber_start().
VALUE rb_vm_make_proc | ( | rb_thread_t * | th, |
const struct rb_captured_block * | captured, | ||
VALUE | klass | ||
) |
Definition at line 868 of file vm.c.
References FALSE, and rb_vm_make_proc_lambda().
VALUE rb_vm_make_proc_lambda | ( | rb_thread_t * | th, |
const struct rb_captured_block * | captured, | ||
VALUE | klass, | ||
int8_t | is_lambda | ||
) |
Definition at line 874 of file vm.c.
Referenced by rb_vm_make_proc().
void rb_vm_mark | ( | void * | ptr | ) |
Definition at line 2124 of file vm.c.
References rb_vm_struct::cmd, rb_vm_struct::coverages, rb_vm_struct::defined_module_hash, rb_vm_struct::event_hooks, rb_vm_struct::expanded_load_path, rb_vm_struct::living_threads, rb_vm_struct::load_path, rb_vm_struct::load_path_check_cache, rb_vm_struct::load_path_snapshot, rb_vm_struct::loaded_features, rb_vm_struct::loaded_features_snapshot, rb_vm_struct::loading_table, rb_vm_struct::mark_object_ary, rb_gc_mark(), rb_gc_mark_values(), rb_mark_tbl(), rb_vm_trace_mark_event_hooks(), RUBY_GC_INFO, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_UNLESS_NULL, RUBY_NSIG, rb_thread_struct::self, rb_vm_struct::thgroup_default, rb_vm_struct::top_self, and rb_vm_struct::trap_list.
void rb_vm_pop_cfunc_frame | ( | void | ) |
Definition at line 532 of file vm.c.
References rb_callable_method_entry_struct::called_id, rb_execution_context_struct::cfp, rb_callable_method_entry_struct::def, rb_thread_struct::ec, EXEC_EVENT_HOOK, GET_THREAD, rb_callable_method_entry_struct::owner, Qnil, rb_vm_frame_method_entry(), RUBY_DTRACE_CMETHOD_RETURN_HOOK, RUBY_EVENT_C_RETURN, and rb_control_frame_struct::self.
Referenced by rb_mod_const_missing().
void rb_vm_register_special_exception_str | ( | enum ruby_special_exceptions | sp, |
VALUE | cls, | ||
VALUE | mesg | ||
) |
Definition at line 2161 of file vm.c.
References GET_VM, OBJ_FREEZE, OBJ_TAINT, rb_exc_new3, rb_gc_register_mark_object(), rb_obj_freeze(), and rb_vm_struct::special_exceptions.
void rb_vm_rewind_cfp | ( | rb_thread_t * | th, |
rb_control_frame_t * | cfp | ||
) |
Definition at line 544 of file vm.c.
References rb_execution_context_struct::cfp, and rb_thread_struct::ec.
void rb_vm_set_progname | ( | VALUE | filename | ) |
Definition at line 3110 of file vm.c.
References rb_thread_struct::ec, GET_VM, rb_control_frame_struct::iseq, rb_iseq_pathobj_set(), rb_iseq_realpath(), rb_str_dup(), rb_execution_context_struct::vm_stack, and rb_execution_context_struct::vm_stack_size.
Referenced by ruby_set_script_name().
void rb_vm_stack_to_heap | ( | rb_thread_t * | th | ) |
Definition at line 731 of file vm.c.
References rb_execution_context_struct::cfp, rb_thread_struct::ec, and rb_vm_get_binding_creatable_next_cfp().
VALUE rb_vm_top_self | ( | void | ) |
Definition at line 3166 of file vm.c.
References GET_VM.
Referenced by Init_top_self(), and rb_eval_string_wrap().
void rb_vm_trace_mark_event_hooks | ( | rb_hook_list_t * | hooks | ) |
Definition at line 49 of file vm_trace.c.
References rb_event_hook_struct::data, rb_hook_list_struct::hooks, rb_event_hook_struct::next, and rb_gc_mark().
Referenced by rb_thread_mark(), and rb_vm_mark().
int ruby_th_dtrace_setup | ( | rb_thread_t * | th, |
VALUE | klass, | ||
ID | id, | ||
struct ruby_dtrace_method_hook_args * | args | ||
) |
Definition at line 338 of file vm.c.
References BUILTIN_TYPE, FALSE, FL_SINGLETON, FL_TEST, GET_THREAD, name, NIL_P, rb_attr_get(), rb_class_path_no_cache(), rb_thread_method_id_and_class(), RB_TYPE_P, RBASIC, T_CLASS, T_ICLASS, and T_MODULE.
void ruby_vm_at_exit | ( | void(*)(rb_vm_t *) | func | ) |
Definition at line 563 of file vm.c.
References ALLOC, rb_vm_struct::at_exit, rb_at_exit_list::func, GET_VM, and rb_at_exit_list::next.
int ruby_vm_destruct | ( | rb_vm_t * | vm | ) |
Definition at line 2189 of file vm.c.
References rb_vm_struct::main_thread, rb_vm_struct::objspace, rb_fiber_reset_root_local_storage(), RUBY_FREE_ENTER, and rb_thread_struct::self.
VALUE rb_cRubyVM |
Definition at line 314 of file vm.c.
Referenced by Init_ISeq().
const struct st_hash_type rb_fstring_hash_type |
size_t rb_gc_stack_maxsize |
VALUE* rb_gc_stack_start |
rb_thread_t* ruby_current_thread = 0 |
const rb_data_type_t ruby_threadptr_data_type |
rb_serial_t ruby_vm_class_serial = 1 |
void(* ruby_vm_collect_usage_func_register) (int reg, int isset) = NULL |
rb_event_flag_t ruby_vm_event_flags |
rb_serial_t ruby_vm_global_constant_state = 1 |
rb_serial_t ruby_vm_global_method_state = 1 |