15#include "internal/imemo.h"
16#include "internal/compilers.h"
17#include "internal/static_assert.h"
20#ifndef END_OF_ENUMERATION
21# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
22# define END_OF_ENUMERATION(key)
24# define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
31 METHOD_VISI_UNDEF = 0x00,
32 METHOD_VISI_PUBLIC = 0x01,
33 METHOD_VISI_PRIVATE = 0x02,
34 METHOD_VISI_PROTECTED = 0x03,
36 METHOD_VISI_MASK = 0x03
37} rb_method_visibility_t;
40 BITFIELD(rb_method_visibility_t, method_visi, 3);
41 unsigned int module_func : 1;
65 const VALUE defined_class;
71#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
72#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
73#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
74#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
75#define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
76#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
77#define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
78#define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
83 VM_ASSERT((
int)visi >= 0 && visi <= 3);
84 me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
89 VM_ASSERT(basic <= 1);
90 me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
93METHOD_ENTRY_FLAGS_SET(
rb_method_entry_t *me, rb_method_visibility_t visi,
unsigned int basic)
95 VM_ASSERT((
int)visi >= 0 && visi <= 3);
96 VM_ASSERT(basic <= 1);
98 (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
99 ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
105 (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2
107 (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3));
112 VM_METHOD_TYPE_CFUNC,
113 VM_METHOD_TYPE_ATTRSET,
115 VM_METHOD_TYPE_BMETHOD,
116 VM_METHOD_TYPE_ZSUPER,
117 VM_METHOD_TYPE_ALIAS,
118 VM_METHOD_TYPE_UNDEF,
119 VM_METHOD_TYPE_NOTIMPLEMENTED,
120 VM_METHOD_TYPE_OPTIMIZED,
121 VM_METHOD_TYPE_MISSING,
122 VM_METHOD_TYPE_REFINED,
124 END_OF_ENUMERATION(VM_METHOD_TYPE)
126#define VM_METHOD_TYPE_MINIMUM_BITS 4
127STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
128 VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
132#define rb_iseq_t rb_iseq_t
163 VALUE defined_ractor;
166enum method_optimized_type {
167 OPTIMIZED_METHOD_TYPE_SEND,
168 OPTIMIZED_METHOD_TYPE_CALL,
169 OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
170 OPTIMIZED_METHOD_TYPE_STRUCT_AREF,
171 OPTIMIZED_METHOD_TYPE_STRUCT_ASET,
172 OPTIMIZED_METHOD_TYPE__MAX
176 enum method_optimized_type type;
181 BITFIELD(rb_method_type_t,
type, VM_METHOD_TYPE_MINIMUM_BITS);
182 unsigned int iseq_overload: 1;
183 unsigned int no_redef_warning: 1;
184 unsigned int aliased : 1;
199 uintptr_t method_serial;
207#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
208#define UNDEFINED_REFINED_METHOD_P(def) \
209 ((def)->type == VM_METHOD_TYPE_REFINED && \
210 UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
212void rb_add_method(
VALUE klass,
ID mid, rb_method_type_t
type,
void *option, rb_method_visibility_t visi);
213void rb_add_method_cfunc(
VALUE klass,
ID mid,
VALUE (*func)(
ANYARGS),
int argc, rb_method_visibility_t visi);
215void rb_add_method_optimized(
VALUE klass,
ID mid,
enum method_optimized_type,
unsigned int index, rb_method_visibility_t visi);
216void rb_add_refined_method_entry(
VALUE refined_class,
ID mid);
227RUBY_SYMBOL_EXPORT_BEGIN
229RUBY_SYMBOL_EXPORT_END
251void rb_scope_visibility_set(rb_method_visibility_t);
253VALUE rb_unnamed_parameters(
int arity);
255void rb_clear_method_cache(
VALUE klass_or_module,
ID mid);
256void rb_clear_all_refinement_method_cache(
void);
std::atomic< unsigned > rb_atomic_t
Type that is eligible for atomic operations.
VALUE type(ANYARGS)
ANYARGS-ed function type.
#define ANYARGS
Functions declared using this macro take arbitrary arguments, including void.
rb_cref_t * cref
class reference, should be marked
const rb_iseq_t * iseqptr
iseq pointer, should be separated from iseqval
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.