Ruby: vm_insnhelper.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Typedefs | Enumerations | Functions
vm_insnhelper.c File Reference
`#include "ruby/internal/config.h"`
`#include <math.h>`
`#include "constant.h"`
`#include "debug_counter.h"`
`#include "internal.h"`
`#include "internal/class.h"`
`#include "internal/compar.h"`
`#include "internal/hash.h"`
`#include "internal/numeric.h"`
`#include "internal/proc.h"`
`#include "internal/random.h"`
`#include "internal/variable.h"`
`#include "variable.h"`
`#include "insns.inc"`
`#include "insns_info.inc"`
`#include "vm_args.c"`

Go to the source code of this file.

## Macros
#define | vm_check_canary(ec, sp)
#define | vm_check_frame(a, b, c, d)
#define | vm_push_frame_debug_counter_inc(ec, cfp, t) /* void */
#define | EQ_UNREDEFINED_P(t) BASIC_OP_UNREDEFINED_P(BOP_EQ, t##_REDEFINED_OP_FLAG)
#define | CHECK_CMP_NAN(a, b) /* do nothing */
#define | USE_OPT_HIST 0
#define | CHECK_CFP_CONSISTENCY(func)
#define | id_cmp idCmp
#define | IMEMO_CONST_CACHE_SHAREABLE IMEMO_FL_USER0
#define | VM_TRACE_HOOK(target_event, val)

## Typedefs
typedef VALUE(* | builtin_invoker) (rb_execution_context_t *ec, VALUE self, const VALUE *argv, rb_insn_func_t funcptr)

## Enumerations
enum | method_explorer_type { mexp_search_method , mexp_search_invokeblock , mexp_search_super }

## Functions
rb_method_definition_t * | rb_method_definition_create (rb_method_type_t type, ID mid)
void | rb_method_definition_set (const rb_method_entry_t *me, rb_method_definition_t *def, void *opts)
int | rb_method_definition_eq (const rb_method_definition_t *d1, const rb_method_definition_t *d2)
VALUE | rb_make_no_method_exception (VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv, int priv)
VALUE | ruby_vm_special_exception_copy (VALUE exc)
void | rb_ec_stack_overflow (rb_execution_context_t *ec, int crit)
| STATIC_ASSERT (VM_ENV_DATA_INDEX_ME_CREF, VM_ENV_DATA_INDEX_ME_CREF==-2)
| STATIC_ASSERT (VM_ENV_DATA_INDEX_SPECVAL, VM_ENV_DATA_INDEX_SPECVAL==-1)
| STATIC_ASSERT (VM_ENV_DATA_INDEX_FLAGS, VM_ENV_DATA_INDEX_FLAGS==-0)
void | rb_vm_pop_frame (rb_execution_context_t *ec)
void | rb_error_arity (int argc, int min, int max)
VALUE | rb_vm_bh_to_procval (const rb_execution_context_t *ec, VALUE block_handler)
const rb_callable_method_entry_t * | rb_vm_frame_method_entry (const rb_control_frame_t *cfp)
void | rb_vm_rewrite_cref (rb_cref_t *cref, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr)
const struct rb_callcache * | rb_vm_search_method_slowpath (const struct rb_callinfo *ci, VALUE klass)
VALUE | rb_equal_opt (VALUE obj1, VALUE obj2)
VALUE | rb_eql_opt (VALUE obj1, VALUE obj2)
VALUE | rb_vm_call0 (rb_execution_context_t *ec, VALUE, ID, int, const VALUE *, const rb_callable_method_entry_t *, int kw_splat)
bool | rb_simple_iseq_p (const rb_iseq_t *iseq)
bool | rb_splat_or_kwargs_p (const struct rb_callinfo *restrict ci)
VALUE | rb_find_defined_class_by_owner (VALUE current_class, VALUE target_owner)
VALUE | rb_false (VALUE obj)
rb_event_flag_t | rb_iseq_event_flags (const rb_iseq_t *iseq, size_t pos)
bool | rb_vm_opt_cfunc_p (CALL_CACHE cc, int insn)
void | Init_vm_stack_canary (void)
VALUE | rb_vm_lvar_exposed (rb_execution_context_t *ec, int index)

## Macro Definition Documentation

## ◆ CHECK_CFP_CONSISTENCY

#define CHECK_CFP_CONSISTENCY | ( |  | func | ) |

Value:
(LIKELY(vm_cfp_consistent_p(ec, reg_cfp)) ? (void)0 : \
rb_bug(func ": cfp consistency error (%p, %p)", (void *)reg_cfp, (void *)(ec->cfp+1)))
LIKELY
#define LIKELY(x)
Definition: ffi_common.h:125
rb_bug
void rb_bug(const char *fmt,...)
Definition: error.c:768

Definition at line 2865 of file vm_insnhelper.c.

## ◆ CHECK_CMP_NAN

#define CHECK_CMP_NAN | ( |  | a,
|  |  | b
| ) |  | /* do nothing */

Definition at line 2056 of file vm_insnhelper.c.

## ◆ EQ_UNREDEFINED_P

#define EQ_UNREDEFINED_P | ( |  | t | ) | BASIC_OP_UNREDEFINED_P(BOP_EQ, t##_REDEFINED_OP_FLAG)

Definition at line 1866 of file vm_insnhelper.c.

## ◆ id_cmp

#define id_cmp idCmp

Definition at line 4587 of file vm_insnhelper.c.

## ◆ IMEMO_CONST_CACHE_SHAREABLE

#define IMEMO_CONST_CACHE_SHAREABLE IMEMO_FL_USER0

Definition at line 4643 of file vm_insnhelper.c.

## ◆ USE_OPT_HIST

#define USE_OPT_HIST 0

Definition at line 2259 of file vm_insnhelper.c.

## ◆ vm_check_canary

#define vm_check_canary | ( |  | ec,
|  |  | sp
| ) |  |

Definition at line 290 of file vm_insnhelper.c.

## ◆ vm_check_frame

#define vm_check_frame | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d
| ) |  |

Definition at line 291 of file vm_insnhelper.c.

## ◆ vm_push_frame_debug_counter_inc

#define vm_push_frame_debug_counter_inc | ( |  | ec,
|  |  | cfp,
|  |  | t
| ) |  | /* void */

Definition at line 341 of file vm_insnhelper.c.

## ◆ VM_TRACE_HOOK

#define VM_TRACE_HOOK | ( |  | target_event,
|  |  | val
| ) |  |

Value:
do { \
if ((pc_events & (target_event)) & enabled_flags) { \
vm_trace_hook(ec, reg_cfp, pc, pc_events, (target_event), global_hooks, local_hooks, (val)); \
} \
} while (0)

Definition at line 5314 of file vm_insnhelper.c.

## Typedef Documentation

## ◆ builtin_invoker

typedef VALUE(* builtin_invoker) (rb_execution_context_t *ec, VALUE self, const VALUE *argv, rb_insn_func_t funcptr)

Definition at line 5550 of file vm_insnhelper.c.

## Enumeration Type Documentation

## ◆ method_explorer_type

enum method_explorer_type

Enumerator
mexp_search_method |
mexp_search_invokeblock |
mexp_search_super |

Definition at line 4485 of file vm_insnhelper.c.

## Function Documentation

## ◆ Init_vm_stack_canary()

void Init_vm_stack_canary | ( | void |  | ) |

Definition at line 5410 of file vm_insnhelper.c.

## ◆ rb_ec_stack_overflow()

void rb_ec_stack_overflow | ( | rb_execution_context_t * | ec,
|  | int | crit
| ) |  |

Definition at line 84 of file vm_insnhelper.c.

References EC_JUMP_TAG, rb_execution_context_struct::errinfo, FALSE, rb_execution_context_struct::raised_flag, RAISED_STACKOVERFLOW, rb_bug(), rb_during_gc(), ruby_error_stackfatal, TAG_RAISE, and TRUE.

## ◆ rb_eql_opt()

VALUE rb_eql_opt | ( | VALUE | obj1,
|  | VALUE | obj2
| ) |  |

Definition at line 2016 of file vm_insnhelper.c.

References idEqlP.

Referenced by rb_eql().

## ◆ rb_equal_opt()

VALUE rb_equal_opt | ( | VALUE | obj1,
|  | VALUE | obj2
| ) |  |

Definition at line 2010 of file vm_insnhelper.c.

References idEq.

Referenced by rb_equal().

## ◆ rb_error_arity()

void rb_error_arity | ( | int | argc,
|  | int | min,
|  | int | max
| ) |  |

Definition at line 442 of file vm_insnhelper.c.

References argc, max, and rb_exc_raise().

## ◆ rb_find_defined_class_by_owner()

VALUE rb_find_defined_class_by_owner | ( | VALUE | current_class,
|  | VALUE | target_owner
| ) |  |

Definition at line 3011 of file vm_insnhelper.c.

References FL_TEST, RBASIC_CLASS, RCLASS_SUPER, RICLASS_IS_ORIGIN, RTEST, T_CLASS, and T_ICLASS.

## ◆ rb_iseq_event_flags()

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().

## ◆ rb_make_no_method_exception()

VALUE rb_make_no_method_exception | ( | VALUE | exc,
|  | VALUE | format,
|  | VALUE | obj,
|  | int | argc,
|  | const VALUE * | argv,
|  | int | priv
| ) |  |

Definition at line 886 of file vm_eval.c.

References argc, argv, name, rb_ary_new4, rb_eNoMethodError, rb_fstring_lit, rb_name_err_new(), and rb_nomethod_err_new().

## ◆ rb_method_definition_create()

rb_method_definition_t * rb_method_definition_create | ( | rb_method_type_t | type,
|  | ID | mid
| ) |  |

Definition at line 546 of file vm_method.c.

References def(), and ZALLOC.

Referenced by rb_method_entry_complement_defined_class().

## ◆ rb_method_definition_eq()

int rb_method_definition_eq | ( | const rb_method_definition_t * | d1,
|  | const rb_method_definition_t * | d2
| ) |  |

Definition at line 1849 of file vm_method.c.

References rb_method_cfunc_struct::argc, rb_method_definition_struct::attr, rb_method_definition_struct::bmethod, rb_method_definition_struct::body, rb_method_definition_struct::cfunc, d1, rb_method_cfunc_struct::func, rb_method_attr_struct::id, rb_method_definition_struct::iseq, rb_method_iseq_struct::iseqptr, rb_method_definition_struct::optimize_type, rb_method_definition_struct::original_id, rb_method_bmethod_struct::proc, rb_bug(), rb_equal(), RTEST, VM_METHOD_TYPE_ALIAS, VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_IVAR, VM_METHOD_TYPE_MISSING, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, VM_METHOD_TYPE_REFINED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by rb_method_entry_eq().

## ◆ rb_method_definition_set()

void rb_method_definition_set | ( | const rb_method_entry_t * | me,
|  | rb_method_definition_t * | def,
|  | void * | opts
| ) |  |

Definition at line 428 of file vm_method.c.

References rb_method_cfunc_struct::argc, rb_execution_context_struct::cfp, rb_method_iseq_struct::cref, def(), rb_method_entry_struct::def, rb_method_cfunc_struct::func, if(), INT2FIX, rb_control_frame_struct::iseq, rb_method_iseq_struct::iseqptr, NULL, rb_method_refined_struct::orig_me, rb_method_refined_struct::owner, rb_ary_freeze(), rb_ary_new3, rb_f_notimplement(), rb_iseq_path(), RB_OBJ_WRITE, rb_vm_get_ruby_level_next_cfp(), rb_vm_get_sourceline(), UNALIGNED_MEMBER_PTR, VM_ASSERT, VM_METHOD_TYPE_ALIAS, VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_IVAR, VM_METHOD_TYPE_MISSING, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, VM_METHOD_TYPE_REFINED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by rb_method_entry_complement_defined_class().

## ◆ rb_simple_iseq_p()

bool rb_simple_iseq_p | ( | const rb_iseq_t * | iseq | ) |

Definition at line 2152 of file vm_insnhelper.c.

References rb_iseq_constant_body::accepts_no_kwarg, rb_iseq_struct::body, FALSE, 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_opt, rb_iseq_constant_body::has_post, rb_iseq_constant_body::has_rest, and rb_iseq_constant_body::param.

## ◆ rb_splat_or_kwargs_p()

bool rb_splat_or_kwargs_p | ( | const struct rb_callinfo *restrict | ci | ) |

Definition at line 2188 of file vm_insnhelper.c.

References IS_ARGS_KW_OR_KW_SPLAT, and IS_ARGS_SPLAT.

## ◆ rb_vm_bh_to_procval()

VALUE rb_vm_bh_to_procval | ( | const rb_execution_context_t * | ec,
|  | VALUE | block_handler
| ) |  |

Definition at line 474 of file vm_insnhelper.c.

References block_handler_type_ifunc, block_handler_type_iseq, block_handler_type_proc, block_handler_type_symbol, Qnil, rb_cProc, rb_sym_to_proc(), rb_vm_bh_to_procval(), VM_BLOCK_HANDLER_NONE, and VM_UNREACHABLE.

Referenced by rb_vm_bh_to_procval().

## ◆ rb_vm_call0()

VALUE rb_vm_call0 | ( | rb_execution_context_t * | ec,
|  | VALUE | recv,
|  | ID | id,
|  | int | argc,
|  | const VALUE * | argv,
|  | const rb_callable_method_entry_t * | cme,
|  | int | kw_splat
| ) |  |

Definition at line 46 of file vm_eval.c.

References argc, argv, rb_calling_info::block_handler, rb_calling_info::ci, rb_calling_info::kw_splat, NULL, Qfalse, rb_calling_info::recv, VM_CALL_KW_SPLAT, VM_CC_ON_STACK, and VM_CI_ON_STACK.

Referenced by rb_check_funcall_basic_kw(), and rb_vm_call_kw().

## ◆ rb_vm_frame_method_entry()

const rb_callable_method_entry_t * rb_vm_frame_method_entry | ( | const rb_control_frame_t * | cfp | ) |

Definition at line 667 of file vm_insnhelper.c.

References rb_control_frame_struct::ep, FALSE, NULL, TRUE, and VM_ENV_DATA_INDEX_ME_CREF.

Referenced by rb_profile_frames(), rb_raise_jump(), rb_vm_control_frame_id_and_class(), and rb_vm_pop_cfunc_frame().

## ◆ rb_vm_lvar_exposed()

VALUE rb_vm_lvar_exposed | ( | rb_execution_context_t * | ec,
|  | int | index
| ) |  |

Definition at line 5617 of file vm_insnhelper.c.

References rb_execution_context_struct::cfp, and rb_control_frame_struct::ep.

## ◆ rb_vm_opt_cfunc_p()

bool rb_vm_opt_cfunc_p | ( | CALL_CACHE | cc,
|  | int | insn
| ) |  |

Definition at line 5300 of file vm_insnhelper.c.

References rb_false(), rb_obj_equal(), and rb_obj_not().

## ◆ rb_vm_pop_frame()

void rb_vm_pop_frame | ( | rb_execution_context_t * | ec | ) |

Definition at line 419 of file vm_insnhelper.c.

References rb_execution_context_struct::cfp, and rb_control_frame_struct::ep.

Referenced by rb_binding_add_dynavars(), rb_exec_event_hooks(), rb_raise_jump(), rb_vm_call_cfunc(), and rb_vm_rewind_cfp().

## ◆ rb_vm_rewrite_cref()

void rb_vm_rewrite_cref | ( | rb_cref_t * | cref,
|  | VALUE | old_klass,
|  | VALUE | new_klass,
|  | rb_cref_t ** | new_cref_ptr
| ) |  |

Definition at line 867 of file vm_insnhelper.c.

References FALSE, METHOD_VISI_UNDEF, rb_cref_struct::next, and NULL.

## ◆ rb_vm_search_method_slowpath()

const struct rb_callcache * rb_vm_search_method_slowpath | ( | const struct rb_callinfo * | ci,
|  | VALUE | klass
| ) |  |

Definition at line 1729 of file vm_insnhelper.c.

References imemo_callcache, IMEMO_TYPE_P, rb_callcache::klass, METHOD_ENTRY_INVALIDATED, RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, T_CLASS, T_ICLASS, VM_ASSERT, and vm_cc_empty.

## ◆ ruby_vm_special_exception_copy()

VALUE ruby_vm_special_exception_copy | ( | VALUE | exc | ) |

Definition at line 48 of file vm_insnhelper.c.

References rb_class_real(), rb_obj_alloc(), rb_obj_copy_ivar(), and RBASIC_CLASS.

Referenced by rb_memerror(), and rb_threadptr_execute_interrupts().

## ◆ STATIC_ASSERT() [1/3]

STATIC_ASSERT | ( | VM_ENV_DATA_INDEX_FLAGS | ,
|  | VM_ENV_DATA_INDEX_FLAGS | = `=-0`
| ) |  |

## ◆ STATIC_ASSERT() [2/3]

STATIC_ASSERT | ( | VM_ENV_DATA_INDEX_ME_CREF | ,
|  | VM_ENV_DATA_INDEX_ME_CREF | = `=-2`
| ) |  |

## ◆ STATIC_ASSERT() [3/3]

STATIC_ASSERT | ( | VM_ENV_DATA_INDEX_SPECVAL | ,
|  | VM_ENV_DATA_INDEX_SPECVAL | = `=-1`
| ) |  |