Ruby  2.7.1p83(2020-03-31revisiona0c7c23c9cec0d0ffcba012279cd652d28ad5bf3)
Data Structures | Macros | Functions
vm_method.c File Reference
#include "id_table.h"

Go to the source code of this file.

Data Structures

struct  cache_entry
 

Macros

#define METHOD_DEBUG   0
 
#define GLOBAL_METHOD_CACHE(c, m)   (rb_bug("global method cache disabled improperly"), NULL)
 
#define object_id   idObject_id
 
#define added   idMethod_added
 
#define singleton_added   idSingleton_method_added
 
#define removed   idMethod_removed
 
#define singleton_removed   idSingleton_method_removed
 
#define undefined   idMethod_undefined
 
#define singleton_undefined   idSingleton_method_undefined
 
#define attached   id__attached__
 
#define ruby_running   (GET_VM()->running)
 
#define CALL_METHOD_HOOK(klass, hook, mid)
 
#define UNDEF_ALLOC_FUNC   ((rb_alloc_func_t)-1)
 
#define BOUND_PRIVATE   0x01
 
#define BOUND_RESPONDS   0x02
 
#define rb_intern(str)   rb_intern_const(str)
 
#define REPLICATE_METHOD(klass, id)
 

Functions

void rb_clear_constant_cache (void)
 
void rb_clear_method_cache_by_class (VALUE klass)
 
VALUE rb_f_notimplement (int argc, const VALUE *argv, VALUE obj, VALUE marker)
 
void rb_add_method_cfunc (VALUE klass, ID mid, VALUE(*func)(ANYARGS), int argc, rb_method_visibility_t visi)
 
void rb_free_method_entry (const rb_method_entry_t *me)
 
int rb_method_definition_eq (const rb_method_definition_t *d1, const rb_method_definition_t *d2)
 
MJIT_FUNC_EXPORTED void rb_method_definition_set (const rb_method_entry_t *me, rb_method_definition_t *def, void *opts)
 
MJIT_FUNC_EXPORTED rb_method_definition_trb_method_definition_create (rb_method_type_t type, ID mid)
 
rb_method_entry_trb_method_entry_create (ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def)
 
const rb_method_entry_trb_method_entry_clone (const rb_method_entry_t *src_me)
 
const MJIT_FUNC_EXPORTED rb_callable_method_entry_trb_method_entry_complement_defined_class (const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
 
void rb_method_entry_copy (rb_method_entry_t *dst, const rb_method_entry_t *src)
 
void rb_add_refined_method_entry (VALUE refined_class, ID mid)
 
void rb_add_method (VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_visibility_t visi)
 
MJIT_FUNC_EXPORTED void rb_add_method_iseq (VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi)
 
rb_method_entry_trb_method_entry_set (VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_visibility_t visi)
 
void rb_define_alloc_func (VALUE klass, VALUE(*func)(VALUE))
 
void rb_undef_alloc_func (VALUE klass)
 
rb_alloc_func_t rb_get_alloc_func (VALUE klass)
 
const rb_method_entry_trb_method_entry_at (VALUE klass, ID id)
 
const MJIT_FUNC_EXPORTED rb_method_entry_trb_method_entry (VALUE klass, ID id)
 
const MJIT_FUNC_EXPORTED rb_callable_method_entry_trb_callable_method_entry (VALUE klass, ID id)
 
const rb_method_entry_trb_method_entry_with_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const MJIT_FUNC_EXPORTED rb_callable_method_entry_trb_callable_method_entry_with_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const rb_method_entry_trb_method_entry_without_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const MJIT_FUNC_EXPORTED rb_callable_method_entry_trb_callable_method_entry_without_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const rb_method_entry_trb_resolve_refined_method (VALUE refinements, const rb_method_entry_t *me)
 
const MJIT_FUNC_EXPORTED rb_callable_method_entry_trb_resolve_refined_method_callable (VALUE refinements, const rb_callable_method_entry_t *me)
 
void rb_remove_method_id (VALUE klass, ID mid)
 
void rb_remove_method (VALUE klass, const char *name)
 
int rb_method_boundp (VALUE klass, ID id, int ex)
 
void rb_scope_visibility_set (rb_method_visibility_t visi)
 
const rb_cref_trb_vm_cref_in_context (VALUE self, VALUE cbase)
 
void rb_attr (VALUE klass, ID id, int read, int write, int ex)
 
void rb_undef (VALUE klass, ID id)
 
int rb_method_entry_eq (const rb_method_entry_t *m1, const rb_method_entry_t *m2)
 
st_index_t rb_hash_method_entry (st_index_t hash, const rb_method_entry_t *me)
 
void rb_alias (VALUE klass, ID alias_name, ID original_name)
 
bool rb_method_basic_definition_p_with_cc (struct rb_call_data *cd, VALUE klass, ID mid)
 
int rb_method_basic_definition_p (VALUE klass, ID id)
 
int rb_obj_respond_to (VALUE obj, ID id, int priv)
 
int rb_respond_to (VALUE obj, ID id)
 
void Init_Method (void)
 
void Init_eval_method (void)
 

Macro Definition Documentation

◆ added

#define added   idMethod_added

Definition at line 32 of file vm_method.c.

◆ attached

#define attached   id__attached__

Definition at line 38 of file vm_method.c.

◆ BOUND_PRIVATE

#define BOUND_PRIVATE   0x01

Definition at line 1098 of file vm_method.c.

◆ BOUND_RESPONDS

#define BOUND_RESPONDS   0x02

Definition at line 1099 of file vm_method.c.

◆ CALL_METHOD_HOOK

#define CALL_METHOD_HOOK (   klass,
  hook,
  mid 
)
Value:
do { \
const VALUE arg = ID2SYM(mid); \
VALUE recv_class = (klass); \
ID hook_id = (hook); \
if (FL_TEST((klass), FL_SINGLETON)) { \
recv_class = rb_ivar_get((klass), attached); \
hook_id = singleton_##hook; \
} \
rb_funcallv(recv_class, hook_id, 1, &arg); \
} while (0)

Definition at line 654 of file vm_method.c.

◆ GLOBAL_METHOD_CACHE

#define GLOBAL_METHOD_CACHE (   c,
 
)    (rb_bug("global method cache disabled improperly"), NULL)

Definition at line 25 of file vm_method.c.

◆ METHOD_DEBUG

#define METHOD_DEBUG   0

Definition at line 7 of file vm_method.c.

◆ object_id

#define object_id   idObject_id

Definition at line 31 of file vm_method.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ removed

#define removed   idMethod_removed

Definition at line 34 of file vm_method.c.

◆ REPLICATE_METHOD

#define REPLICATE_METHOD (   klass,
  id 
)
Value:
do { \
rb_method_entry_set((klass), (id), me, METHOD_ENTRY_VISI(me)); \
} while (0)

◆ ruby_running

#define ruby_running   (GET_VM()->running)

Definition at line 59 of file vm_method.c.

◆ singleton_added

#define singleton_added   idSingleton_method_added

Definition at line 33 of file vm_method.c.

◆ singleton_removed

#define singleton_removed   idSingleton_method_removed

Definition at line 35 of file vm_method.c.

◆ singleton_undefined

#define singleton_undefined   idSingleton_method_undefined

Definition at line 37 of file vm_method.c.

◆ UNDEF_ALLOC_FUNC

#define UNDEF_ALLOC_FUNC   ((rb_alloc_func_t)-1)

Definition at line 712 of file vm_method.c.

◆ undefined

#define undefined   idMethod_undefined

Definition at line 36 of file vm_method.c.

Function Documentation

◆ Init_eval_method()

void Init_eval_method ( void  )

Definition at line 2281 of file vm_method.c.

References rb_define_method(), and rb_mKernel.

◆ Init_Method()

void Init_Method ( void  )

Definition at line 2257 of file vm_method.c.

References atoi(), calloc(), exit(), EXIT_FAILURE, fprintf(), getenv, NULL, OPT_GLOBAL_METHOD_CACHE, ptr, and stderr.

◆ rb_add_method()

void rb_add_method ( VALUE  klass,
ID  mid,
rb_method_type_t  type,
void opts,
rb_method_visibility_t  visi 
)

Definition at line 674 of file vm_method.c.

Referenced by rb_add_method_cfunc(), rb_add_method_iseq(), and rb_undef_method().

◆ rb_add_method_cfunc()

void rb_add_method_cfunc ( VALUE  klass,
ID  mid,
VALUE(*)(ANYARGS func,
int  argc,
rb_method_visibility_t  visi 
)

◆ rb_add_method_iseq()

MJIT_FUNC_EXPORTED void rb_add_method_iseq ( VALUE  klass,
ID  mid,
const rb_iseq_t iseq,
rb_cref_t cref,
rb_method_visibility_t  visi 
)

Definition at line 684 of file vm_method.c.

References iseq, klass, rb_add_method(), and VM_METHOD_TYPE_ISEQ.

◆ rb_add_refined_method_entry()

void rb_add_refined_method_entry ( VALUE  refined_class,
ID  mid 
)

Definition at line 491 of file vm_method.c.

References me.

◆ rb_alias()

void rb_alias ( VALUE  klass,
ID  alias_name,
ID  original_name 
)

Definition at line 1581 of file vm_method.c.

References klass, METHOD_VISI_UNDEF, NIL_P, rb_class_modify_check(), rb_eTypeError, and rb_raise().

Referenced by rb_define_alias().

◆ rb_attr()

void rb_attr ( VALUE  klass,
ID  id,
int  read,
int  write,
int  ex 
)

Definition at line 1163 of file vm_method.c.

References GET_EC, klass, METHOD_VISI_PUBLIC, and rb_vm_cref_in_context().

Referenced by rb_define_attr().

◆ rb_callable_method_entry()

const MJIT_FUNC_EXPORTED rb_callable_method_entry_t* rb_callable_method_entry ( VALUE  klass,
ID  id 
)

Definition at line 878 of file vm_method.c.

References me.

Referenced by rb_vm_search_method_slowpath().

◆ rb_callable_method_entry_with_refinements()

const MJIT_FUNC_EXPORTED rb_callable_method_entry_t* rb_callable_method_entry_with_refinements ( VALUE  klass,
ID  id,
VALUE defined_class_ptr 
)

Definition at line 917 of file vm_method.c.

References me.

◆ rb_callable_method_entry_without_refinements()

const MJIT_FUNC_EXPORTED rb_callable_method_entry_t* rb_callable_method_entry_without_refinements ( VALUE  klass,
ID  id,
VALUE defined_class_ptr 
)

Definition at line 931 of file vm_method.c.

References me.

◆ rb_clear_constant_cache()

void rb_clear_constant_cache ( void  )

Definition at line 87 of file vm_method.c.

References INC_GLOBAL_CONSTANT_STATE.

◆ rb_clear_method_cache_by_class()

void rb_clear_method_cache_by_class ( VALUE  klass)

◆ rb_define_alloc_func()

void rb_define_alloc_func ( VALUE  klass,
VALUE(*)(VALUE func 
)

Definition at line 715 of file vm_method.c.

References Check_Type, klass, RCLASS_EXT, and T_CLASS.

Referenced by rb_undef_alloc_func().

◆ rb_f_notimplement()

VALUE rb_f_notimplement ( int  argc,
const VALUE argv,
VALUE  obj,
VALUE  marker 
)

Definition at line 120 of file vm_method.c.

References Qnil, rb_notimplement(), and UNREACHABLE_RETURN.

Referenced by rb_add_method_cfunc().

◆ rb_free_method_entry()

void rb_free_method_entry ( const rb_method_entry_t me)

Definition at line 174 of file vm_method.c.

◆ rb_get_alloc_func()

rb_alloc_func_t rb_get_alloc_func ( VALUE  klass)

Definition at line 728 of file vm_method.c.

References Check_Type, klass, RCLASS_EXT, RCLASS_SUPER, T_CLASS, and UNDEF_ALLOC_FUNC.

Referenced by rb_marshal_define_compat().

◆ rb_hash_method_entry()

st_index_t rb_hash_method_entry ( st_index_t  hash,
const rb_method_entry_t me 
)

Definition at line 1575 of file vm_method.c.

◆ rb_method_basic_definition_p()

int rb_method_basic_definition_p ( VALUE  klass,
ID  id 
)

Definition at line 2072 of file vm_method.c.

References FALSE, klass, me, METHOD_ENTRY_BASIC, rb_method_entry(), and TRUE.

◆ rb_method_basic_definition_p_with_cc()

bool rb_method_basic_definition_p_with_cc ( struct rb_call_data cd,
VALUE  klass,
ID  mid 
)

Definition at line 2057 of file vm_method.c.

References rb_call_data::ci, and rb_call_info::mid.

◆ rb_method_boundp()

int rb_method_boundp ( VALUE  klass,
ID  id,
int  ex 
)

Definition at line 1102 of file vm_method.c.

References BOUND_RESPONDS, and me.

◆ rb_method_definition_create()

MJIT_FUNC_EXPORTED rb_method_definition_t* rb_method_definition_create ( rb_method_type_t  type,
ID  mid 
)

◆ rb_method_definition_eq()

int rb_method_definition_eq ( const rb_method_definition_t d1,
const rb_method_definition_t d2 
)

Definition at line 1504 of file vm_method.c.

References d1.

Referenced by rb_method_entry_eq().

◆ rb_method_definition_set()

MJIT_FUNC_EXPORTED void rb_method_definition_set ( const rb_method_entry_t me,
rb_method_definition_t def,
void opts 
)

◆ rb_method_entry()

const MJIT_FUNC_EXPORTED rb_method_entry_t* rb_method_entry ( VALUE  klass,
ID  id 
)

Definition at line 837 of file vm_method.c.

Referenced by rb_method_basic_definition_p().

◆ rb_method_entry_at()

const rb_method_entry_t* rb_method_entry_at ( VALUE  klass,
ID  id 
)

Definition at line 756 of file vm_method.c.

◆ rb_method_entry_clone()

const rb_method_entry_t* rb_method_entry_clone ( const rb_method_entry_t src_me)

Definition at line 406 of file vm_method.c.

References me.

Referenced by rb_method_entry_complement_defined_class().

◆ rb_method_entry_complement_defined_class()

const MJIT_FUNC_EXPORTED rb_callable_method_entry_t* rb_method_entry_complement_defined_class ( const rb_method_entry_t src_me,
ID  called_id,
VALUE  defined_class 
)

◆ rb_method_entry_copy()

void rb_method_entry_copy ( rb_method_entry_t dst,
const rb_method_entry_t src 
)

Definition at line 451 of file vm_method.c.

References rb_method_entry_struct::def.

◆ rb_method_entry_create()

rb_method_entry_t* rb_method_entry_create ( ID  called_id,
VALUE  klass,
rb_method_visibility_t  visi,
const rb_method_definition_t def 
)

Definition at line 397 of file vm_method.c.

References me.

◆ rb_method_entry_eq()

int rb_method_entry_eq ( const rb_method_entry_t m1,
const rb_method_entry_t m2 
)

Definition at line 1476 of file vm_method.c.

References rb_method_entry_struct::def, and rb_method_definition_eq().

◆ rb_method_entry_set()

rb_method_entry_t* rb_method_entry_set ( VALUE  klass,
ID  mid,
const rb_method_entry_t me,
rb_method_visibility_t  visi 
)

Definition at line 707 of file vm_method.c.

◆ rb_method_entry_with_refinements()

const rb_method_entry_t* rb_method_entry_with_refinements ( VALUE  klass,
ID  id,
VALUE defined_class_ptr 
)

Definition at line 911 of file vm_method.c.

◆ rb_method_entry_without_refinements()

const rb_method_entry_t* rb_method_entry_without_refinements ( VALUE  klass,
ID  id,
VALUE defined_class_ptr 
)

Definition at line 925 of file vm_method.c.

◆ rb_obj_respond_to()

int rb_obj_respond_to ( VALUE  obj,
ID  id,
int  priv 
)

Definition at line 2180 of file vm_method.c.

References CLASS_OF, GET_EC, klass, and obj.

Referenced by rb_respond_to().

◆ rb_remove_method()

void rb_remove_method ( VALUE  klass,
const char name 
)

Definition at line 1032 of file vm_method.c.

◆ rb_remove_method_id()

void rb_remove_method_id ( VALUE  klass,
ID  mid 
)

Definition at line 1026 of file vm_method.c.

◆ rb_resolve_refined_method()

const rb_method_entry_t* rb_resolve_refined_method ( VALUE  refinements,
const rb_method_entry_t me 
)

Definition at line 972 of file vm_method.c.

◆ rb_resolve_refined_method_callable()

const MJIT_FUNC_EXPORTED rb_callable_method_entry_t* rb_resolve_refined_method_callable ( VALUE  refinements,
const rb_callable_method_entry_t me 
)

Definition at line 979 of file vm_method.c.

References rb_callable_method_entry_struct::defined_class, and me.

◆ rb_respond_to()

int rb_respond_to ( VALUE  obj,
ID  id 
)

Definition at line 2190 of file vm_method.c.

References FALSE, obj, and rb_obj_respond_to().

Referenced by ossl_to_der_if_possible(), and rb_str_equal().

◆ rb_scope_visibility_set()

void rb_scope_visibility_set ( rb_method_visibility_t  visi)

Definition at line 1138 of file vm_method.c.

◆ rb_undef()

void rb_undef ( VALUE  klass,
ID  id 
)

◆ rb_undef_alloc_func()

void rb_undef_alloc_func ( VALUE  klass)

◆ rb_vm_cref_in_context()

const rb_cref_t* rb_vm_cref_in_context ( VALUE  self,
VALUE  cbase 
)
klass
VALUE klass
Definition: rb_mjit_min_header-2.7.1.h:13259
VALUE
unsigned long VALUE
Definition: ruby.h:102
arg
VALUE arg
Definition: rb_mjit_min_header-2.7.1.h:5601
me
const rb_callable_method_entry_t * me
Definition: rb_mjit_min_header-2.7.1.h:13231
FL_TEST
#define FL_TEST(x, f)
Definition: ruby.h:1353
ID2SYM
#define ID2SYM(x)
Definition: ruby.h:414
rb_ivar_get
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1070
METHOD_ENTRY_VISI
#define METHOD_ENTRY_VISI(me)
Definition: method.h:67
rb_method_entry
const MJIT_FUNC_EXPORTED rb_method_entry_t * rb_method_entry(VALUE klass, ID id)
Definition: vm_method.c:837
attached
#define attached
Definition: vm_method.c:38
rb_method_entry_struct
Definition: method.h:51
FL_SINGLETON
#define FL_SINGLETON
Definition: ruby.h:1278