summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class.c6
-rw-r--r--ext/coverage/coverage.c2
-rw-r--r--gc.c2
-rw-r--r--method.h43
-rw-r--r--proc.c8
-rw-r--r--vm.c2
-rw-r--r--vm_backtrace.c4
-rw-r--r--vm_insnhelper.c12
-rw-r--r--vm_method.c118
9 files changed, 88 insertions, 109 deletions
diff --git a/class.c b/class.c
index 3160444..aaf7541 100644
--- a/class.c
+++ b/class.c
@@ -965,7 +965,7 @@ static enum rb_id_table_iterator_result
inject_refined_method(ID *key, VALUE *value, void *data, int _)
{
const tuple *ptr = data;
- const rb_method_entry_t *me = *(rb_method_entry_t **) value;
+ const rb_method_entry_t *me = *(const rb_method_entry_t **) value;
const rb_method_entry_t *orig_me = me->def->body.refined.orig_me;
const rb_method_entry_t *new_me =
rb_method_entry_from_template(
@@ -982,8 +982,8 @@ inject_refined_method(ID *key, VALUE *value, void *data, int _)
static enum rb_id_table_iterator_result
move_refined_method(ID key, VALUE value, void *data)
{
- const tuple *ptr = data;
- rb_method_entry_t *me = (rb_method_entry_t *) value;
+ const tuple *ptr = data;
+ const rb_method_entry_t *me = (const rb_method_entry_t *) value;
if (me->def->type == VM_METHOD_TYPE_REFINED) {
if (me->def->body.refined.orig_me) {
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index 8503c9d..cb571ca 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -123,7 +123,7 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
if (RB_TYPE_P(v, T_IMEMO) && imemo_type(v) == imemo_ment) {
- const rb_method_entry_t *me = (rb_method_entry_t *) v;
+ const rb_method_entry_t *me = (const rb_method_entry_t *) v;
VALUE path, first_lineno, first_column, last_lineno, last_column;
VALUE data[5], ncoverage, methods;
VALUE methods_id = ID2SYM(rb_intern("methods"));
diff --git a/gc.c b/gc.c
index 0caee4c..52b3a66 100644
--- a/gc.c
+++ b/gc.c
@@ -7829,7 +7829,7 @@ void rb_update_st_references(struct st_table *ht)
}
static void
-gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me)
+gc_ref_update_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
{
const rb_method_definition_t *def = me->def;
diff --git a/method.h b/method.h
index 105e4b6..b203f71 100644
--- a/method.h
+++ b/method.h
@@ -49,53 +49,24 @@ typedef struct rb_cref_struct {
/* method data type */
typedef struct rb_method_entry_struct {
- VALUE flags;
- VALUE defined_class;
+ const VALUE flags;
+ const VALUE defined_class;
struct rb_method_definition_struct * const def;
- ID called_id;
- VALUE owner;
+ const ID called_id;
+ const VALUE owner;
} rb_method_entry_t;
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
- VALUE flags;
+ const VALUE flags;
const VALUE defined_class;
struct rb_method_definition_struct * const def;
- ID called_id;
+ const ID called_id;
const VALUE owner;
} rb_callable_method_entry_t;
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
-static inline void
-METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
-{
- VM_ASSERT((int)visi >= 0 && visi <= 3);
- me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
-}
-static inline void
-METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
-{
- VM_ASSERT(basic <= 1);
- me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
-}
-static inline void
-METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
-{
- VM_ASSERT((int)visi >= 0 && visi <= 3);
- VM_ASSERT(basic <= 1);
- me->flags =
- (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
- ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
-}
-static inline void
-METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
-{
- dst->flags =
- (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
- (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
-}
-
typedef enum {
VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
VM_METHOD_TYPE_CFUNC, /*!< C method */
@@ -190,7 +161,7 @@ void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *c
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 *option, rb_method_visibility_t visi);
-rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
+const rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
const rb_method_entry_t *rb_method_entry_from_template(const rb_method_entry_t *template, const void *opts);
const rb_method_entry_t *rb_method_entry_for_missing(ID mid, VALUE klass);
diff --git a/proc.c b/proc.c
index 09b3103..0fd2126 100644
--- a/proc.c
+++ b/proc.c
@@ -1426,7 +1426,7 @@ bm_compact(void *ptr)
UPDATE_REFERENCE(data->recv);
UPDATE_REFERENCE(data->klass);
UPDATE_REFERENCE(data->iclass);
- UPDATE_TYPED_REFERENCE(rb_method_entry_t *, data->me);
+ UPDATE_TYPED_REFERENCE(const rb_method_entry_t *, data->me);
}
static size_t
@@ -1519,7 +1519,7 @@ mnew_internal(const rb_method_entry_t *me, VALUE klass, VALUE iclass,
if (me->defined_class) {
VALUE klass = RCLASS_SUPER(RCLASS_ORIGIN(me->defined_class));
id = me->def->original_id;
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
+ me = (const rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
}
else {
VALUE klass = RCLASS_SUPER(me->owner);
@@ -1557,7 +1557,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
me = rb_method_entry_with_refinements(klass, id, &iclass);
}
else {
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
+ me = (const rb_method_entry_t *)rb_callable_method_entry_with_refinements(klass, id, &iclass);
}
return mnew_from_me(me, klass, iclass, obj, id, mclass, scope);
}
@@ -2947,7 +2947,7 @@ method_super_method(VALUE method)
super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass));
mid = data->me->called_id;
if (!super_class) return Qnil;
- me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(super_class, mid, &iclass);
+ me = (const rb_method_entry_t *)rb_callable_method_entry_with_refinements(super_class, mid, &iclass);
if (!me) return Qnil;
return mnew_internal(me, me->owner, iclass, data->recv, mid, rb_obj_class(method), FALSE, FALSE);
}
diff --git a/vm.c b/vm.c
index 2483180..16a15c2 100644
--- a/vm.c
+++ b/vm.c
@@ -1595,7 +1595,7 @@ static enum rb_id_table_iterator_result
check_redefined_method(ID mid, VALUE value, void *data)
{
VALUE klass = (VALUE)data;
- const rb_method_entry_t *me = (rb_method_entry_t *)value;
+ const rb_method_entry_t *me = (const rb_method_entry_t *)value;
const rb_method_entry_t *newme = rb_method_entry(klass, mid);
if (newme != me) rb_vm_check_redefinition_opt_method(me, me->owner);
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 44a4ac0..3a8ad91 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1349,7 +1349,7 @@ frame2iseq(VALUE frame)
return (const rb_iseq_t *)frame;
case imemo_ment:
{
- const rb_callable_method_entry_t *cme = (rb_callable_method_entry_t *)frame;
+ const rb_callable_method_entry_t *cme = (const rb_callable_method_entry_t *)frame;
switch (cme->def->type) {
case VM_METHOD_TYPE_ISEQ:
return cme->def->body.iseq.iseqptr;
@@ -1405,7 +1405,7 @@ frame2klass(VALUE frame)
if (frame == Qnil) return Qnil;
if (RB_TYPE_P(frame, T_IMEMO)) {
- const rb_callable_method_entry_t *cme = (rb_callable_method_entry_t *)frame;
+ const rb_callable_method_entry_t *cme = (const rb_callable_method_entry_t *)frame;
if (imemo_type(frame) == imemo_ment) {
return cme->defined_class;
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index adad1df..197e100 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -578,8 +578,8 @@ vm_getspecial(const rb_execution_context_t *ec, const VALUE *lep, rb_num_t key,
return val;
}
-PUREFUNC(static rb_callable_method_entry_t *check_method_entry(VALUE obj, int can_be_svar));
-static rb_callable_method_entry_t *
+PUREFUNC(static const rb_callable_method_entry_t *check_method_entry(VALUE obj, int can_be_svar));
+static const rb_callable_method_entry_t *
check_method_entry(VALUE obj, int can_be_svar)
{
if (obj == Qfalse) return NULL;
@@ -590,7 +590,7 @@ check_method_entry(VALUE obj, int can_be_svar)
switch (imemo_type(obj)) {
case imemo_ment:
- return (rb_callable_method_entry_t *)obj;
+ return (const rb_callable_method_entry_t *)obj;
case imemo_cref:
return NULL;
case imemo_svar:
@@ -609,7 +609,7 @@ MJIT_STATIC const rb_callable_method_entry_t *
rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
{
const VALUE *ep = cfp->ep;
- rb_callable_method_entry_t *me;
+ const rb_callable_method_entry_t *me;
while (!VM_ENV_LOCAL_P(ep)) {
if ((me = check_method_entry(ep[VM_ENV_DATA_INDEX_ME_CREF], FALSE)) != NULL) return me;
@@ -620,7 +620,7 @@ rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
}
static rb_cref_t *
-method_entry_cref(rb_callable_method_entry_t *me)
+method_entry_cref(const rb_callable_method_entry_t *me)
{
switch (me->def->type) {
case VM_METHOD_TYPE_ISEQ:
@@ -644,7 +644,7 @@ check_cref(VALUE obj, int can_be_svar)
switch (imemo_type(obj)) {
case imemo_ment:
- return method_entry_cref((rb_callable_method_entry_t *)obj);
+ return method_entry_cref((const rb_callable_method_entry_t *)obj);
case imemo_cref:
return (rb_cref_t *)obj;
case imemo_svar:
diff --git a/vm_method.c b/vm_method.c
index ce703f3..38da273 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -41,7 +41,7 @@ struct cache_entry {
rb_serial_t method_state;
rb_serial_t class_serial;
ID mid;
- rb_method_entry_t* me;
+ const rb_method_entry_t* me;
VALUE defined_class;
};
@@ -167,17 +167,17 @@ rb_free_method_entry(const rb_method_entry_t *me)
}
}
-static inline rb_method_entry_t *search_method(VALUE klass, ID id, VALUE *defined_class_ptr);
+static inline const rb_method_entry_t *search_method(VALUE klass, ID id, VALUE *defined_class_ptr);
extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
-static inline rb_method_entry_t *
+static inline const rb_method_entry_t *
lookup_method_table(VALUE klass, ID id)
{
st_data_t body;
struct rb_id_table *m_tbl = RCLASS_M_TBL(klass);
if (rb_id_table_lookup(m_tbl, id, &body)) {
- return (rb_method_entry_t *) body;
+ return (const rb_method_entry_t *) body;
}
else {
return 0;
@@ -477,15 +477,15 @@ method_definition_addref_complement(rb_method_definition_t *def)
return def;
}
-static rb_method_entry_t *
+static const rb_method_entry_t *
rb_method_entry_alloc(VALUE flags, ID called_id, VALUE owner, VALUE defined_class, const rb_method_definition_t *def)
{
- rb_method_entry_t tmp = { flags, };
- rb_method_entry_t *me = (rb_method_entry_t *)rb_imemo_new(imemo_ment, (VALUE)def, (VALUE)called_id, owner, defined_class);
- METHOD_ENTRY_FLAGS_COPY(me, &tmp);
- if (def) {
- method_definition_reset(me);
- }
+ VALUE v = rb_imemo_new(imemo_ment, (VALUE)def, (VALUE)called_id, owner, defined_class);
+ RBASIC(v)->flags =
+ (RBASIC(v)->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
+ (flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
+ const rb_method_entry_t *me = (void *)v;
+ method_definition_reset(me);
return me;
}
@@ -506,9 +506,8 @@ filter_defined_class(VALUE klass)
static inline VALUE
method_entry_flags(rb_method_visibility_t visi)
{
- rb_method_entry_t tmp = { 0, };
- METHOD_ENTRY_FLAGS_SET(&tmp, visi, !ruby_running);
- return tmp.flags;
+ return (visi << (IMEMO_FL_USHIFT+0)) |
+ ((!ruby_running) << (IMEMO_FL_USHIFT+2));
}
MJIT_FUNC_EXPORTED const rb_method_entry_t *
@@ -556,7 +555,6 @@ MJIT_FUNC_EXPORTED const rb_callable_method_entry_t *
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
{
const rb_method_definition_t *def = src_me->def;
- rb_method_entry_t *me;
if (!src_me->defined_class &&
def->type == VM_METHOD_TYPE_REFINED &&
@@ -570,24 +568,26 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal
&(rb_method_refined_t) {
.orig_me = orig_me,
.owner = orig_me->owner});
+
}
else {
- def = method_definition_addref_complement((rb_method_definition_t *)def);
+ def = method_definition_addref_complement((rb_method_definition_t *)def);
}
- me = rb_method_entry_alloc(
- src_me->flags,
- called_id,
- src_me->owner,
- defined_class,
- def);
+ const rb_method_entry_t *me =
+ rb_method_entry_alloc(
+ src_me->flags,
+ called_id,
+ src_me->owner,
+ defined_class,
+ def);
VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE));
- return (rb_callable_method_entry_t *)me;
+ return (const rb_callable_method_entry_t *)me;
}
-static rb_method_entry_t*
-make_method_entry_refined(VALUE owner, rb_method_entry_t *me)
+static const rb_method_entry_t*
+make_method_entry_refined(VALUE owner, const rb_method_entry_t *me)
{
if (me->def->type == VM_METHOD_TYPE_REFINED) {
return me;
@@ -620,7 +620,7 @@ make_method_entry_refined(VALUE owner, rb_method_entry_t *me)
void
rb_add_refined_method_entry(VALUE refined_class, ID mid)
{
- rb_method_entry_t *me = lookup_method_table(refined_class, mid);
+ const rb_method_entry_t *me = lookup_method_table(refined_class, mid);
if (me) {
me = make_method_entry_refined(refined_class, me);
@@ -654,11 +654,10 @@ check_override_opt_method(VALUE klass, VALUE arg)
* If def is given (!= NULL), then just use it and ignore original_id and otps.
* If not given, then make a new def with original_id and opts.
*/
-static rb_method_entry_t *
+static const rb_method_entry_t *
rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibility_t visi,
rb_method_type_t type, const rb_method_definition_t *def, ID original_id, void *opts)
{
- rb_method_entry_t *me;
struct rb_id_table *mtbl;
st_data_t data;
int make_refined = 0;
@@ -686,7 +685,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
rb_add_refined_method_entry(refined_class, mid);
}
if (type == VM_METHOD_TYPE_REFINED) {
- rb_method_entry_t *old_me = lookup_method_table(RCLASS_ORIGIN(klass), mid);
+ const rb_method_entry_t *old_me = lookup_method_table(RCLASS_ORIGIN(klass), mid);
if (old_me) rb_vm_check_redefinition_opt_method(old_me, klass);
}
else {
@@ -696,8 +695,8 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
/* check re-definition */
if (rb_id_table_lookup(mtbl, mid, &data)) {
- rb_method_entry_t *old_me = (rb_method_entry_t *)data;
- const rb_method_definition_t *old_def = old_me->def;
+ const rb_method_entry_t *old_me = (const rb_method_entry_t *)data;
+ const rb_method_definition_t *old_def = old_me->def;
if (rb_method_definition_eq(old_def, def)) return old_me;
rb_vm_check_redefinition_opt_method(old_me, klass);
@@ -737,12 +736,13 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
if (!def) {
def = rb_method_definition_create(type, original_id, opts);
}
- me = rb_method_entry_alloc(
- method_entry_flags(visi),
- mid,
- defined_class,
- filter_defined_class(defined_class),
- def);
+ const rb_method_entry_t *me =
+ rb_method_entry_alloc(
+ method_entry_flags(visi),
+ mid,
+ defined_class,
+ filter_defined_class(defined_class),
+ def);
rb_clear_method_cache_by_class(klass);
@@ -816,17 +816,17 @@ rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref,
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi);
}
-static rb_method_entry_t *
+static const rb_method_entry_t *
method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me,
rb_method_visibility_t visi, VALUE defined_class)
{
- rb_method_entry_t *newme = rb_method_entry_make(klass, mid, defined_class, visi,
+ const rb_method_entry_t *newme = rb_method_entry_make(klass, mid, defined_class, visi,
me->def->type, method_definition_addref(me->def), 0, NULL);
method_added(klass, mid);
return newme;
}
-rb_method_entry_t *
+const rb_method_entry_t *
rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_visibility_t visi)
{
return method_entry_set(klass, mid, me, visi, klass);
@@ -860,10 +860,10 @@ rb_get_alloc_func(VALUE klass)
return 0;
}
-static inline rb_method_entry_t*
+static inline const rb_method_entry_t*
search_method(VALUE klass, ID id, VALUE *defined_class_ptr)
{
- rb_method_entry_t *me;
+ const rb_method_entry_t *me;
for (; klass; klass = RCLASS_SUPER(klass)) {
RB_DEBUG_COUNTER_INC(mc_search_super);
@@ -887,12 +887,12 @@ rb_method_entry_at(VALUE klass, ID id)
* if you need method entry with method cache (normal case), use
* rb_method_entry() simply.
*/
-static rb_method_entry_t *
+static const rb_method_entry_t *
method_entry_get_without_cache(VALUE klass, ID id,
VALUE *defined_class_ptr)
{
VALUE defined_class;
- rb_method_entry_t *me = search_method(klass, id, &defined_class);
+ const rb_method_entry_t *me = search_method(klass, id, &defined_class);
if (ruby_running) {
if (OPT_GLOBAL_METHOD_CACHE) {
@@ -924,11 +924,11 @@ method_entry_get_without_cache(VALUE klass, ID id,
}
static void
-verify_method_cache(VALUE klass, ID id, VALUE defined_class, rb_method_entry_t *me)
+verify_method_cache(VALUE klass, ID id, VALUE defined_class, const rb_method_entry_t *me)
{
if (!VM_DEBUG_VERIFY_METHOD_CACHE) return;
VALUE actual_defined_class;
- rb_method_entry_t *actual_me =
+ const rb_method_entry_t *actual_me =
method_entry_get_without_cache(klass, id, &actual_defined_class);
if (me != actual_me || defined_class != actual_defined_class) {
@@ -936,7 +936,7 @@ verify_method_cache(VALUE klass, ID id, VALUE defined_class, rb_method_entry_t *
}
}
-static rb_method_entry_t *
+static const rb_method_entry_t *
method_entry_get(VALUE klass, ID id, VALUE *defined_class_ptr)
{
struct cache_entry *ent;
@@ -977,7 +977,7 @@ prepare_callable_method_entry(VALUE defined_class, ID id, const rb_method_entry_
if (mtbl && rb_id_table_lookup(mtbl, id, (VALUE *)&me)) {
RB_DEBUG_COUNTER_INC(mc_cme_complement_hit);
- cme = (rb_callable_method_entry_t *)me;
+ cme = (const rb_callable_method_entry_t *)me;
VM_ASSERT(callable_method_entry_p(cme));
}
else {
@@ -1001,7 +1001,7 @@ MJIT_FUNC_EXPORTED const rb_callable_method_entry_t *
rb_callable_method_entry(VALUE klass, ID id)
{
VALUE defined_class;
- rb_method_entry_t *me = method_entry_get(klass, id, &defined_class);
+ const rb_method_entry_t *me = method_entry_get(klass, id, &defined_class);
return prepare_callable_method_entry(defined_class, id, me);
}
@@ -1115,7 +1115,7 @@ static void
remove_method(VALUE klass, ID mid)
{
VALUE data;
- rb_method_entry_t *me = 0;
+ const rb_method_entry_t *me = NULL;
VALUE self = klass;
klass = RCLASS_ORIGIN(klass);
@@ -1125,7 +1125,7 @@ remove_method(VALUE klass, ID mid)
}
if (!rb_id_table_lookup(RCLASS_M_TBL(klass), mid, &data) ||
- !(me = (rb_method_entry_t *)data) ||
+ !(me = (const rb_method_entry_t *)data) ||
(!me->def || me->def->type == VM_METHOD_TYPE_UNDEF) ||
UNDEFINED_REFINED_METHOD_P(me->def)) {
rb_name_err_raise("method `%1$s' not defined in %2$s",
@@ -1183,10 +1183,18 @@ rb_mod_remove_method(int argc, VALUE *argv, VALUE mod)
return mod;
}
+static inline void
+METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
+{
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
+ VALUE flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
+ memcpy((void *)&me->flags, &flags, sizeof flags);
+}
+
static void
rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
{
- rb_method_entry_t *me;
+ const rb_method_entry_t *me;
VALUE defined_class;
VALUE origin_class = RCLASS_ORIGIN(klass);
@@ -1204,7 +1212,7 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
rb_vm_check_redefinition_opt_method(me, klass);
if (klass == defined_class || origin_class == defined_class) {
- METHOD_ENTRY_VISI_SET(me, visi);
+ METHOD_ENTRY_VISI_SET((rb_method_entry_t *)me, visi);
if (me->def->type == VM_METHOD_TYPE_REFINED && me->def->body.refined.orig_me) {
METHOD_ENTRY_VISI_SET((rb_method_entry_t *)me->def->body.refined.orig_me, visi);
@@ -1732,7 +1740,7 @@ rb_alias(VALUE klass, ID alias_name, ID original_name)
method_added(target_klass, alias_name);
}
else {
- rb_method_entry_t *alias_me;
+ const rb_method_entry_t *alias_me;
alias_me = method_entry_set(target_klass, alias_name, orig_me, visi, orig_me->owner);
RB_OBJ_WRITE(alias_me, &alias_me->owner, target_klass);
@@ -1923,7 +1931,7 @@ rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module)
for (i = 0; i < argc; i++) {
VALUE v = argv[i];
ID name = rb_check_id(&v);
- rb_method_entry_t *me;
+ const rb_method_entry_t *me;
VALUE defined_class;
if (!name) {