Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
#include "ruby/internal/config.h"
#include "eval_intern.h"
#include "gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/bits.h"
#include "internal/class.h"
#include "internal/compile.h"
#include "internal/error.h"
#include "internal/file.h"
#include "internal/hash.h"
#include "internal/parse.h"
#include "internal/sanitizers.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "iseq.h"
#include "mjit.h"
#include "ruby/util.h"
#include "vm_core.h"
#include "vm_callinfo.h"
#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
#include "node_name.inc"
Go to the source code of this file.
Data Structures | |
struct | insn_data_struct |
struct | trace_set_local_events_struct |
struct | trace_clear_local_events_struct |
Macros | |
#define | RUBY_VM_INSNS_INFO 1 |
#define | hidden_obj_p(obj) (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass) |
#define | SET_COMPILE_OPTION(o, h, mem) |
#define | SET_COMPILE_OPTION_NUM(o, h, mem) |
#define | SET_COMPILE_OPTION(o, h, mem) rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse) |
#define | SET_COMPILE_OPTION_NUM(o, h, mem) rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem)) |
#define | CHECK_ARRAY(v) rb_to_array_type(v) |
#define | CHECK_HASH(v) rb_to_hash_type(v) |
#define | CHECK_STRING(v) rb_str_to_str(v) |
#define | CHECK_SYMBOL(v) rb_to_symbol_type(v) |
#define | INITIALIZED /* volatile */ |
#define | CALL_FLAG(n) if (vm_ci_flag(ci) & VM_CALL_##n) rb_ary_push(flags, rb_str_new2(#n)) |
#define | C(ev, cstr, l) if (events & ev) rb_ary_push(ary, rb_ary_new_from_args(2, l, ID2SYM(rb_intern(cstr)))); |
#define | DECL_SYMBOL(name) static ID sym_##name |
#define | INIT_SYMBOL(name) sym_##name = rb_intern(#name) |
#define | CHECK_EVENT(ev) if (events & ev) rb_ary_push(body, ID2SYM(rb_intern(#ev))); |
#define | PARAM_TYPE(type) rb_ary_push(a = rb_ary_new2(2), ID2SYM(type)) |
#define | PARAM_ID(i) body->local_table[(i)] |
#define | PARAM(i, type) |
#define | INSN_CODE(insn) (insn) |
Typedefs | |
typedef VALUE | iseq_value_itr_t(void *ctx, VALUE obj) |
typedef VALUE | rb_vm_insns_translator_t(const void *addr) |
typedef struct insn_data_struct | insn_data_t |
Variables | |
VALUE | rb_cISeq |
#define C | ( | ev, | |
cstr, | |||
l | |||
) | if (events & ev) rb_ary_push(ary, rb_ary_new_from_args(2, l, ID2SYM(rb_intern(cstr)))); |
#define CALL_FLAG | ( | n | ) | if (vm_ci_flag(ci) & VM_CALL_##n) rb_ary_push(flags, rb_str_new2(#n)) |
#define CHECK_ARRAY | ( | v | ) | rb_to_array_type(v) |
#define CHECK_EVENT | ( | ev | ) | if (events & ev) rb_ary_push(body, ID2SYM(rb_intern(#ev))); |
#define CHECK_HASH | ( | v | ) | rb_to_hash_type(v) |
#define CHECK_STRING | ( | v | ) | rb_str_to_str(v) |
#define CHECK_SYMBOL | ( | v | ) | rb_to_symbol_type(v) |
#define hidden_obj_p | ( | obj | ) | (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass) |
#define INITIALIZED /* volatile */ |
#define INSN_CODE | ( | insn | ) | (insn) |
#define PARAM | ( | i, | |
type | |||
) |
#define PARAM_ID | ( | i | ) | body->local_table[(i)] |
#define PARAM_TYPE | ( | type | ) | rb_ary_push(a = rb_ary_new2(2), ID2SYM(type)) |
#define SET_COMPILE_OPTION | ( | o, | |
h, | |||
mem | |||
) |
#define SET_COMPILE_OPTION | ( | o, | |
h, | |||
mem | |||
) | rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse) |
#define SET_COMPILE_OPTION_NUM | ( | o, | |
h, | |||
mem | |||
) |
#define SET_COMPILE_OPTION_NUM | ( | o, | |
h, | |||
mem | |||
) | rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem)) |
typedef struct insn_data_struct insn_data_t |
void Init_ISeq | ( | void | ) |
Definition at line 3605 of file iseq.c.
References CLASS_OF, rb_cISeq, rb_cObject, rb_cRubyVM, rb_define_class_under(), rb_define_method, rb_define_private_method, rb_define_singleton_method, rb_undef_alloc_func(), and rb_undef_method().
Definition at line 83 of file node.c.
References FL_SINGLETON, FL_TEST, PRIsVALUE, rb_class_path(), rb_inspect(), rb_sprintf(), str, T_CLASS, T_ICLASS, and T_MODULE.
Referenced by 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, | ||
const VALUE * | pnop, | ||
VALUE | child | ||
) |
Definition at line 1889 of file iseq.c.
References rb_builtin_function::argc, rb_iseq_struct::body, CALL_FLAG, rb_call_data::ci, CLASS_OF, DEFINED_CONST_FROM, DEFINED_FUNC, DEFINED_REF, FIXNUM_P, ID2SYM, INT2FIX, rb_iseq_constant_body::is_entries, rb_callinfo_kwarg::keyword_len, rb_callinfo_kwarg::keywords, rb_iseq_location_struct::label, len, rb_iseq_constant_body::location, rb_callinfo::mid, rb_builtin_function::name, NUM2INT, PRIdPTRDIFF, PRIdVALUE, PRIsVALUE, PRIuVALUE, Qundef, rb_ary_join(), rb_ary_new(), rb_ary_new_from_values(), rb_ary_push(), rb_bug(), rb_cISeq, rb_dump_literal(), rb_fstring_lit, rb_id2str, rb_insn_unified_local_var_level(), rb_inspect(), rb_iseq_defined_string(), rb_sprintf(), rb_str_new2, rb_str_new_cstr, rb_type_str(), types, VM_CALL_KWARG, and VM_ENV_DATA_SIZE.
Referenced by rb_iseq_disasm_insn().
Referenced by rb_insn_operand_intern().
Definition at line 1099 of file iseq.c.
References rb_iseq_realpath().
int rb_iseq_add_local_tracepoint_recursively | ( | const rb_iseq_t * | iseq, |
rb_event_flag_t | turnon_events, | ||
VALUE | tpval, | ||
unsigned int | target_line | ||
) |
Definition at line 3266 of file iseq.c.
References trace_set_local_events_struct::n, Qnil, rb_funcall(), rb_intern(), rb_iseq_disasm(), trace_set_local_events_struct::target_line, trace_set_local_events_struct::tpval, and trace_set_local_events_struct::turnon_events.
Definition at line 1111 of file iseq.c.
References rb_iseq_location_struct::base_label, rb_iseq_struct::body, and rb_iseq_constant_body::location.
Referenced by rb_profile_frame_base_label().
void rb_iseq_clear_event_flags | ( | const rb_iseq_t * | iseq, |
size_t | pos, | ||
rb_event_flag_t | reset | ||
) |
Definition at line 1846 of file iseq.c.
References rb_iseq_struct::aux, iseq_insn_info_entry::events, rb_iseq_struct::exec, rb_iseq_struct::global_trace_events, and rb_iseq_trace_flag_cleared().
void rb_iseq_code_location | ( | const rb_iseq_t * | iseq, |
int * | beg_pos_lineno, | ||
int * | beg_pos_column, | ||
int * | end_pos_lineno, | ||
int * | end_pos_column | ||
) |
Definition at line 1136 of file iseq.c.
References rb_code_location_struct::beg_pos, rb_iseq_struct::body, rb_iseq_location_struct::code_location, rb_code_position_struct::column, rb_code_location_struct::end_pos, rb_code_position_struct::lineno, and rb_iseq_constant_body::location.
struct rb_iseq_constant_body * rb_iseq_constant_body_alloc | ( | void | ) |
Definition at line 1146 of file iseq.c.
References ISEQ_COVERAGE.
VALUE rb_iseq_defined_string | ( | enum defined_type | type | ) |
Definition at line 3087 of file iseq.c.
References numberof, OBJ_FREEZE, rb_gc_register_mark_object(), rb_str_new_cstr, ruby_xcalloc(), and str.
Referenced by rb_insn_operand_intern().
Definition at line 2335 of file iseq.c.
References rb_str_new, rb_str_resize(), RSTRING_LEN, and str.
Referenced by rb_iseq_add_local_tracepoint_recursively().
int rb_iseq_disasm_insn | ( | VALUE | ret, |
const VALUE * | code, | ||
size_t | pos, | ||
const rb_iseq_t * | iseq, | ||
VALUE | child | ||
) |
Disassemble a instruction Iseq -> Iseq inspect object.
Definition at line 2078 of file iseq.c.
References len, PRIuSIZE, rb_insn_operand_intern(), rb_iseq_event_flags(), rb_iseq_line_no(), rb_str_cat2, rb_str_catf(), rb_str_concat(), rb_str_new, RSTRING_LEN, RSTRING_PTR, RUBY_EVENT_B_CALL, RUBY_EVENT_B_RETURN, RUBY_EVENT_C_CALL, RUBY_EVENT_C_RETURN, RUBY_EVENT_CALL, RUBY_EVENT_CLASS, RUBY_EVENT_COVERAGE_BRANCH, RUBY_EVENT_COVERAGE_LINE, RUBY_EVENT_END, RUBY_EVENT_LINE, RUBY_EVENT_RETURN, str, and types.
Referenced by rb_vmdebug_debug_print_pre().
rb_event_flag_t rb_iseq_event_flags | ( | const rb_iseq_t * | iseq, |
size_t | pos | ||
) |
Definition at line 1834 of file iseq.c.
References iseq_insn_info_entry::events.
Referenced by rb_iseq_disasm_insn(), and rb_iseq_trace_set().
Definition at line 1117 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_location_struct::first_lineno, and rb_iseq_constant_body::location.
Referenced by rb_profile_frame_first_lineno(), and rb_vm_get_sourceline().
Definition at line 105 of file iseq.c.
References rb_iseq_struct::aux, rb_iseq_constant_body::iseq_insn_info::body, rb_iseq_struct::body, rb_iseq_constant_body::call_data, rb_iseq_constant_body::catch_table, rb_iseq_struct::exec, rb_iseq_constant_body::insns_info, rb_iseq_constant_body::is_entries, rb_iseq_constant_body::iseq_encoded, ISEQ_EXECUTABLE_P, rb_iseq_constant_body::keyword, LIKELY, rb_iseq_struct::local_hooks, rb_iseq_constant_body::local_table, NULL, rb_iseq_constant_body::opt_table, rb_iseq_constant_body::outer_variables, rb_iseq_constant_body::param, rb_iseq_constant_body::iseq_insn_info::positions, rb_hook_list_free(), rb_id_table_free(), rb_iseq_shared_exc_local_tbl, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, and ruby_xfree().
void rb_iseq_init_trace | ( | rb_iseq_t * | iseq | ) |
Definition at line 675 of file iseq.c.
References rb_iseq_struct::aux, rb_iseq_struct::exec, rb_iseq_struct::global_trace_events, ISEQ_TRACE_EVENTS, rb_iseq_trace_set(), and ruby_vm_event_enabled_global_flags.
Referenced by rb_ibf_load_iseq_complete().
Definition at line 646 of file iseq.c.
References rb_iseq_struct::body, if(), rb_iseq_constant_body::insns_info, rb_iseq_constant_body::iseq_size, NULL, rb_iseq_constant_body::iseq_insn_info::positions, ruby_xfree(), and rb_iseq_constant_body::iseq_insn_info::size.
Definition at line 1105 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_location_struct::label, and rb_iseq_constant_body::location.
Referenced by rb_profile_frame_label().
Definition at line 1821 of file iseq.c.
References iseq_insn_info_entry::line_no.
Referenced by rb_iseq_disasm_insn().
Definition at line 907 of file iseq.c.
References NULL, rb_check_funcall(), rb_cISeq, rb_intern(), RBASIC_CLASS, and SPECIAL_CONST_P.
Definition at line 332 of file iseq.c.
References rb_iseq_struct::aux, rb_iseq_location_struct::base_label, rb_iseq_struct::body, rb_iseq_constant_body::call_data, rb_iseq_constant_body::catch_table, iseq_compile_data::catch_table_ary, rb_call_data::cc, rb_call_data::ci, rb_iseq_constant_body::ci_size, rb_iseq_constant_body::coverage, iseq_compile_data::err_info, rb_iseq_struct::exec, FL_TEST, FL_TEST_RAW, rb_iseq_constant_body::flags, rb_iseq_constant_body::has_kw, iseq_compile_data::insn, iseq_catch_table_entry::iseq, ISEQ_EXECUTABLE_P, ISEQ_MARKABLE_ISEQ, ISEQ_NOT_LOADED_YET, ISEQ_USE_COMPILE_DATA, rb_iseq_constant_body::keyword, rb_iseq_location_struct::label, rb_iseq_struct::loader, rb_iseq_struct::local_hooks, rb_iseq_constant_body::location, NULL, rb_iseq_struct::obj, rb_iseq_constant_body::param, rb_iseq_constant_body::parent_iseq, rb_iseq_location_struct::pathobj, rb_iseq_constant_body::pc2branchindex, rb_gc_mark(), rb_gc_mark_movable(), rb_hook_list_mark(), rb_iseq_mark_insn_storage(), rb_vm_empty_cc(), RTEST, RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUBY_MARK_MOVABLE_UNLESS_NULL, RUBY_MARK_UNLESS_NULL, SPECIAL_CONST_P, iseq_compile_data::storage_head, UNALIGNED_MEMBER_PTR, rb_iseq_constant_body::variable, VM_ASSERT, and rb_iseq_struct::wrapper.
Definition at line 442 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_constant_body::catch_table, rb_iseq_constant_body::ci_size, rb_iseq_constant_body::insns_info, int(), rb_iseq_constant_body::is_size, ISEQ_EXECUTABLE_P, rb_iseq_constant_body::iseq_size, rb_iseq_constant_body::keyword, rb_iseq_constant_body::local_table_size, iseq_compile_data_storage::next, iseq_compile_data::node, offsetof, rb_iseq_constant_body::opt_num, rb_iseq_constant_body::param, iseq_compile_data_storage::size, rb_iseq_constant_body::iseq_insn_info::size, and iseq_compile_data::storage_head.
Definition at line 1123 of file iseq.c.
References rb_iseq_location_struct::base_label, rb_iseq_struct::body, rb_iseq_constant_body::ISEQ_TYPE_METHOD, rb_iseq_constant_body::local_iseq, rb_iseq_constant_body::location, Qnil, and rb_iseq_constant_body::type.
Referenced by rb_profile_frame_method_name().
rb_iseq_t * rb_iseq_new | ( | const rb_ast_body_t * | ast, |
VALUE | name, | ||
VALUE | path, | ||
VALUE | realpath, | ||
const rb_iseq_t * | parent, | ||
enum iseq_type | type | ||
) |
Definition at line 809 of file iseq.c.
References INT2FIX, name, and rb_iseq_new_with_opt().
Referenced by Init_VM(), rb_binding_add_dynavars(), and rb_vm_call_cfunc().
rb_iseq_t * rb_iseq_new_eval | ( | const rb_ast_body_t * | ast, |
VALUE | name, | ||
VALUE | path, | ||
VALUE | realpath, | ||
VALUE | first_lineno, | ||
const rb_iseq_t * | parent, | ||
int | isolated_depth | ||
) |
Definition at line 841 of file iseq.c.
References rb_iseq_constant_body::ISEQ_TYPE_EVAL, name, and rb_iseq_new_with_opt().
rb_iseq_t * rb_iseq_new_main | ( | const rb_ast_body_t * | ast, |
VALUE | path, | ||
VALUE | realpath, | ||
const rb_iseq_t * | parent | ||
) |
Definition at line 833 of file iseq.c.
References INT2FIX, rb_iseq_constant_body::ISEQ_TYPE_MAIN, rb_fstring_lit, and rb_iseq_new_with_opt().
rb_iseq_t * rb_iseq_new_top | ( | const rb_ast_body_t * | ast, |
VALUE | name, | ||
VALUE | path, | ||
VALUE | realpath, | ||
const rb_iseq_t * | parent | ||
) |
Definition at line 817 of file iseq.c.
References rb_iseq_constant_body::coverage, COVERAGE_TARGET_ONESHOT_LINES, INT2FIX, rb_iseq_constant_body::ISEQ_TYPE_TOP, len, rb_ast_body_struct::line_count, name, rb_default_coverage(), rb_get_coverage_mode(), rb_get_coverages(), rb_hash_aset(), rb_iseq_new_with_opt(), and RTEST.
Referenced by rb_binding_add_dynavars().
rb_iseq_t * rb_iseq_new_with_callback | ( | const struct rb_iseq_new_with_callback_callback_func * | ifunc, |
VALUE | name, | ||
VALUE | path, | ||
VALUE | realpath, | ||
VALUE | first_lineno, | ||
const rb_iseq_t * | parent, | ||
enum iseq_type | type, | ||
const rb_compile_option_t * | option | ||
) |
Definition at line 888 of file iseq.c.
References iseq_alloc(), name, NULL, and rb_iseq_compile_callback().
rb_iseq_t * rb_iseq_new_with_opt | ( | const rb_ast_body_t * | ast, |
VALUE | name, | ||
VALUE | path, | ||
VALUE | realpath, | ||
VALUE | first_lineno, | ||
const rb_iseq_t * | parent, | ||
int | isolated_depth, | ||
enum iseq_type | type, | ||
const rb_compile_option_t * | option | ||
) |
Definition at line 862 of file iseq.c.
References rb_ast_body_struct::compile_option, iseq_alloc(), name, RNode::nd_loc, nd_node_id, NULL, rb_iseq_compile_node(), and rb_ast_body_struct::root.
Referenced by rb_iseq_new(), rb_iseq_new_eval(), rb_iseq_new_main(), and rb_iseq_new_top().
Definition at line 2993 of file iseq.c.
References rb_iseq_constant_body::accepts_no_kwarg, rb_iseq_constant_body::block_start, rb_iseq_struct::body, CONST_ID, rb_iseq_constant_body::flags, rb_iseq_constant_body::has_block, rb_iseq_constant_body::has_kw, rb_iseq_constant_body::has_kwrest, rb_iseq_constant_body::has_rest, ID2SYM, key, rb_iseq_constant_body::keyword, rb_iseq_constant_body::lead_num, rb_iseq_constant_body::opt_num, PARAM, rb_iseq_constant_body::param, PARAM_ID, PARAM_TYPE, rb_iseq_constant_body::post_num, rb_iseq_constant_body::post_start, Qnil, rb_ary_new2, rb_ary_push(), rb_id2str, rb_iseq_constant_body::rest_start, and rb_iseq_constant_body::size.
Referenced by rb_tracearg_parameters().
Definition at line 1087 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_constant_body::location, and rb_iseq_location_struct::pathobj.
Referenced by rb_block_to_s(), rb_method_definition_set(), rb_profile_frame_path(), rb_resolve_me_location(), rb_source_location(), and rb_sourcefile().
Definition at line 502 of file iseq.c.
References NIL_P, Qnil, rb_ary_new_from_args, rb_fstring(), rb_obj_freeze(), rb_str_cmp(), T_STRING, and VM_ASSERT.
Referenced by rb_iseq_pathobj_set().
Definition at line 521 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_constant_body::location, rb_iseq_location_struct::pathobj, rb_iseq_pathobj_new(), and RB_OBJ_WRITE.
Referenced by rb_vm_set_progname().
Definition at line 1093 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_constant_body::location, and rb_iseq_location_struct::pathobj.
Referenced by rb_current_realfilepath(), rb_iseq_absolute_path(), rb_profile_frame_absolute_path(), and rb_vm_set_progname().
void rb_iseq_remove_coverage_all | ( | void | ) |
Definition at line 1170 of file iseq.c.
References NULL, and rb_objspace_each_objects().
Referenced by rb_reset_coverages().
Definition at line 3322 of file iseq.c.
References trace_clear_local_events_struct::n, and trace_clear_local_events_struct::tpval.
Definition at line 3204 of file iseq.c.
References rb_iseq_struct::body, and rb_iseq_constant_body::iseq_encoded.
Referenced by rb_iseq_clear_event_flags().
void rb_iseq_trace_set | ( | const rb_iseq_t * | iseq, |
rb_event_flag_t | turnon_events | ||
) |
Definition at line 3333 of file iseq.c.
References rb_iseq_struct::aux, rb_iseq_struct::body, rb_hook_list_struct::events, rb_iseq_struct::exec, rb_iseq_struct::global_trace_events, rb_iseq_constant_body::iseq_encoded, ISEQ_EXECUTABLE_P, rb_iseq_constant_body::iseq_size, rb_iseq_struct::local_hooks, and rb_iseq_event_flags().
Referenced by rb_iseq_init_trace().
void rb_iseq_trace_set_all | ( | rb_event_flag_t | turnon_events | ) |
Definition at line 3379 of file iseq.c.
References rb_objspace_each_objects().
void rb_iseq_update_references | ( | rb_iseq_t * | iseq | ) |
Definition at line 257 of file iseq.c.
References rb_iseq_location_struct::base_label, rb_iseq_struct::body, rb_iseq_constant_body::call_data, rb_iseq_constant_body::catch_table, rb_call_data::cc, rb_call_data::ci, rb_iseq_constant_body::ci_size, rb_iseq_constant_body::coverage, FL_TEST, rb_iseq_constant_body::flags, rb_iseq_constant_body::has_kw, iseq_catch_table_entry::iseq, ISEQ_MARKABLE_ISEQ, rb_iseq_constant_body::iseq_size, rb_iseq_constant_body::keyword, rb_iseq_location_struct::label, rb_iseq_constant_body::local_iseq, rb_iseq_constant_body::location, NULL, rb_iseq_constant_body::param, rb_iseq_constant_body::parent_iseq, rb_iseq_location_struct::pathobj, rb_iseq_constant_body::pc2branchindex, Qundef, rb_gc_location(), SPECIAL_CONST_P, UNALIGNED_MEMBER_PTR, and rb_iseq_constant_body::variable.
void rb_vm_encoded_insn_data_table_init | ( | void | ) |
Definition at line 3139 of file iseq.c.
References insn_data_struct::insn, INSN_CODE, insn_data_struct::insn_len, int(), insn_data_struct::notrace_encoded_insn, rb_vm_get_insns_address_table(), st_add_direct, st_init_numtable_with_size, and insn_data_struct::trace_encoded_insn.
Referenced by ruby_setup().
Definition at line 3172 of file iseq.c.
References insn_data_struct::insn, key, rb_bug(), and st_lookup.
Referenced by rb_iseq_original_iseq().
Definition at line 2593 of file iseq.c.
References rb_bug().
Referenced by rb_ast_node_type_change(), and ruby_debug_print_node().
VALUE rb_cISeq |
Definition at line 46 of file iseq.c.
Referenced by Init_ISeq(), rb_insn_operand_intern(), and rb_iseq_load_iseq().