Ruby
2.7.1p83(2020-03-31revisiona0c7c23c9cec0d0ffcba012279cd652d28ad5bf3)
|
#include "internal.h"
#include "ruby/util.h"
#include "eval_intern.h"
#include "gc.h"
#include "vm_core.h"
#include "iseq.h"
#include "id_table.h"
#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
#include "mjit.h"
#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 |
struct | succ_index_table |
struct | succ_index_table::succ_dict_block |
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 /* suppress warnings by gcc 4.8 */ |
#define | CALL_FLAG(n) if (ci->flag & 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) |
#define | IMMEDIATE_TABLE_SIZE 54 /* a multiple of 9, and < 128 */ |
#define | imm_block_rank_set(v, i, r) (v) |= (uint64_t)(r) << (7 * (i)) |
#define | imm_block_rank_get(v, i) (((int)((v) >> ((i) * 7))) & 0x7f) |
#define | small_block_rank_set(v, i, r) (v) |= (uint64_t)(r) << (9 * ((i) - 1)) |
#define | small_block_rank_get(v, i) ((i) == 0 ? 0 : (((int)((v) >> (((i) - 1) * 9))) & 0x1ff)) |
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 (ci->flag & 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 IMMEDIATE_TABLE_SIZE 54 /* a multiple of 9, and < 128 */ |
#define INITIALIZED volatile /* suppress warnings by gcc 4.8 */ |
#define INSN_CODE | ( | insn | ) | (insn) |
#define PARAM | ( | i, | |
type | |||
) |
#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 |
Definition at line 3541 of file iseq.c.
References rb_cISeq, rb_cObject, rb_cRubyVM, rb_define_class_under(), rb_define_method(), and rb_undef_alloc_func().
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 1828 of file iseq.c.
References BIN, DEFINED_CONST_FROM, DEFINED_FUNC, DEFINED_REF, len, PRIdVALUE, PRIuVALUE, Qundef, rb_fstring_lit, rb_iseq_defined_string(), rb_sprintf(), rb_str_new_cstr, rb_type_str(), and types.
Referenced by rb_iseq_disasm_insn().
Definition at line 1039 of file iseq.c.
References iseq, and 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 3202 of file iseq.c.
References trace_set_local_events_struct::n, trace_set_local_events_struct::target_line, trace_set_local_events_struct::tpval, and trace_set_local_events_struct::turnon_events.
Definition at line 1051 of file iseq.c.
References rb_iseq_location_struct::base_label, rb_iseq_struct::body, iseq, and rb_iseq_constant_body::location.
void rb_iseq_clear_event_flags | ( | const rb_iseq_t * | iseq, |
size_t | pos, | ||
rb_event_flag_t | reset | ||
) |
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 1076 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, iseq, 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 433 of file iseq.c.
References rb_iseq_constant_body::iseq_unique_id, and ZALLOC.
Definition at line 1086 of file iseq.c.
References iseq, and ISEQ_COVERAGE.
VALUE rb_iseq_defined_string | ( | enum defined_type | type | ) |
Definition at line 3033 of file iseq.c.
References GET_VM, numberof, OBJ_FREEZE, rb_gc_register_mark_object(), rb_str_new_cstr, ruby_xcalloc(), and str.
Referenced by rb_insn_operand_intern().
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 2021 of file iseq.c.
References iseq, 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, 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, strcspn(), and types.
Referenced by rb_vmdebug_debug_print_pre().
MJIT_FUNC_EXPORTED rb_event_flag_t rb_iseq_event_flags | ( | const rb_iseq_t * | iseq, |
size_t | pos | ||
) |
Definition at line 1774 of file iseq.c.
Referenced by rb_iseq_disasm_insn(), and rb_iseq_trace_set().
Definition at line 1057 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_location_struct::first_lineno, iseq, and rb_iseq_constant_body::location.
Definition at line 89 of file iseq.c.
References 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_kwarg_call_data::ci_kw, rb_iseq_constant_body::ci_kw_size, rb_iseq_constant_body::ci_size, i, rb_iseq_constant_body::insns_info, rb_iseq_constant_body::is_entries, iseq, rb_iseq_constant_body::iseq_encoded, rb_iseq_constant_body::keyword, rb_call_info_with_kwarg::kw_arg, LIKELY, rb_iseq_constant_body::local_table, mjit_free_iseq(), NULL, rb_iseq_constant_body::opt_table, rb_iseq_constant_body::param, rb_iseq_constant_body::iseq_insn_info::positions, rb_iseq_shared_exc_local_tbl, RUBY_FREE_ENTER, ruby_xfree(), and rb_iseq_constant_body::iseq_insn_info::succ_index_table.
Definition at line 623 of file iseq.c.
References rb_iseq_struct::aux, rb_iseq_struct::exec, iseq, ISEQ_TRACE_EVENTS, rb_iseq_trace_set(), and ruby_vm_event_enabled_global_flags.
unsigned int* rb_iseq_insns_info_decode_positions | ( | const struct rb_iseq_constant_body * | body | ) |
Definition at line 613 of file iseq.c.
References rb_iseq_constant_body::insns_info, rb_iseq_constant_body::iseq_size, size, rb_iseq_constant_body::iseq_insn_info::size, and rb_iseq_constant_body::iseq_insn_info::succ_index_table.
Definition at line 595 of file iseq.c.
References rb_iseq_struct::body, if(), rb_iseq_constant_body::insns_info, iseq, rb_iseq_constant_body::iseq_size, rb_iseq_constant_body::iseq_insn_info::positions, ruby_xfree(), size, rb_iseq_constant_body::iseq_insn_info::size, and rb_iseq_constant_body::iseq_insn_info::succ_index_table.
Definition at line 1045 of file iseq.c.
References rb_iseq_struct::body, iseq, rb_iseq_location_struct::label, and rb_iseq_constant_body::location.
Definition at line 1761 of file iseq.c.
Referenced by rb_iseq_disasm_insn().
Definition at line 847 of file iseq.c.
References rb_check_funcall(), rb_cISeq, rb_intern, RBASIC_CLASS, and SPECIAL_CONST_P.
Definition at line 287 of file iseq.c.
References rb_iseq_struct::body, FL_TEST, iseq, ISEQ_MARKABLE_ISEQ, RUBY_MARK_ENTER, RUBY_MARK_UNLESS_NULL, and rb_iseq_struct::wrapper.
Definition at line 373 of file iseq.c.
References rb_iseq_struct::body, rb_iseq_constant_body::call_data, rb_iseq_constant_body::catch_table, rb_iseq_constant_body::ci_size, rb_iseq_constant_body::insns_info, int, iseq, ISEQ_EXECUTABLE_P, rb_iseq_constant_body::iseq_size, rb_iseq_constant_body::local_table_size, size, rb_iseq_constant_body::iseq_insn_info::size, and unsigned.
Definition at line 1063 of file iseq.c.
References rb_iseq_location_struct::base_label, rb_iseq_struct::body, iseq, 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.
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 761 of file iseq.c.
References INT2FIX, name, path, rb_iseq_new_with_opt(), and realpath().
Referenced by rb_vm_call_cfunc().
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 785 of file iseq.c.
References INT2FIX, rb_iseq_constant_body::ISEQ_TYPE_MAIN, path, rb_fstring_lit, rb_iseq_new_with_opt(), and realpath().
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 769 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, path, rb_default_coverage(), rb_get_coverage_mode(), rb_get_coverages(), rb_hash_aset(), rb_iseq_new_with_opt(), realpath(), and RTEST.
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 828 of file iseq.c.
References iseq, and iseq_alloc().
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, | ||
enum iseq_type | type, | ||
const rb_compile_option_t * | option | ||
) |
Definition at line 807 of file iseq.c.
References iseq, iseq_alloc(), and rb_ast_body_struct::root.
Referenced by rb_iseq_new(), rb_iseq_new_main(), and rb_iseq_new_top().
Definition at line 2939 of file iseq.c.
References rb_iseq_constant_body::block_start, rb_iseq_struct::body, CONST_ID, rb_iseq_constant_body::flags, i, ID2SYM, iseq, key, rb_iseq_constant_body::keyword, rb_iseq_constant_body::lead_num, rb_iseq_constant_body::opt_num, rb_iseq_constant_body::param, 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.
Definition at line 1027 of file iseq.c.
Referenced by rb_resolve_me_location(), and rb_sourcefile().
Definition at line 450 of file iseq.c.
References NIL_P, path, Qnil, rb_ary_new_from_args, rb_fstring(), rb_obj_freeze(), rb_str_cmp(), RB_TYPE_P, realpath(), T_STRING, and VM_ASSERT.
Referenced by rb_iseq_pathobj_set().
Definition at line 469 of file iseq.c.
References rb_iseq_struct::body, iseq, rb_iseq_constant_body::location, path, rb_iseq_location_struct::pathobj, rb_iseq_pathobj_new(), RB_OBJ_WRITE, and realpath().
Referenced by rb_vm_set_progname().
Definition at line 1033 of file iseq.c.
Referenced by rb_iseq_absolute_path(), and rb_vm_set_progname().
Definition at line 1110 of file iseq.c.
References rb_objspace_each_objects().
Referenced by rb_reset_coverages().
Definition at line 3258 of file iseq.c.
References trace_clear_local_events_struct::n, and trace_clear_local_events_struct::tpval.
Definition at line 3140 of file iseq.c.
References rb_iseq_struct::body, iseq, and rb_iseq_constant_body::iseq_encoded.
void rb_iseq_trace_set | ( | const rb_iseq_t * | iseq, |
rb_event_flag_t | turnon_events | ||
) |
Definition at line 3269 of file iseq.c.
References rb_iseq_struct::aux, rb_iseq_struct::body, rb_iseq_struct::exec, iseq, rb_iseq_constant_body::iseq_encoded, ISEQ_EXECUTABLE_P, rb_iseq_constant_body::iseq_size, pc, 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 3315 of file iseq.c.
References rb_objspace_each_objects().
Definition at line 221 of file iseq.c.
References rb_iseq_location_struct::base_label, rb_iseq_struct::body, rb_iseq_constant_body::coverage, FL_TEST, iseq, ISEQ_MARKABLE_ISEQ, rb_iseq_location_struct::label, rb_iseq_constant_body::local_iseq, rb_iseq_constant_body::location, rb_iseq_constant_body::parent_iseq, rb_iseq_location_struct::pathobj, rb_iseq_constant_body::pc2branchindex, rb_gc_location(), and rb_iseq_constant_body::variable.
Definition at line 3085 of file iseq.c.
References rb_vm_get_insns_address_table().
Referenced by ruby_setup().
Definition at line 3111 of file iseq.c.
References key, st_data_t, and st_lookup().
VALUE rb_cISeq |
Definition at line 32 of file iseq.c.
Referenced by Init_ISeq(), and rb_iseq_load_iseq().