From a5fa5f34b051e4d77ea0d768deb006a45acd9245 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 10 Jun 2015 23:55:33 +0000 Subject: * method.h: embed rb_method_entry_t::attr::flags (5 bits) into rb_method_entry_t::flags to make one word spare space. Add some macros to access these flags. * vm_method.c: use these macros. * internal.h: define IMEMO_FL_USHIFT and IMEMO_FL_USER[0-4] for T_IMEMO local flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_method.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'vm_method.c') diff --git a/vm_method.c b/vm_method.c index e9d3ee2484..d559cd8d0d 100644 --- a/vm_method.c +++ b/vm_method.c @@ -335,9 +335,7 @@ rb_method_entry_t * rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, rb_method_definition_t *def) { rb_method_entry_t *me = (rb_method_entry_t *)rb_imemo_new(imemo_ment, (VALUE)NULL, (VALUE)called_id, (VALUE)klass, 0); - METHOD_ENTRY_VISI(me) = visi; - METHOD_ENTRY_BASIC(me) = ruby_running ? FALSE : TRUE; - METHOD_ENTRY_SAFE(me) = rb_safe_level(); + METHOD_ENTRY_FLAGS_SET(me, visi, ruby_running ? FALSE : TRUE, rb_safe_level()); rb_method_definition_reset(me, def); VM_ASSERT(def != NULL); @@ -373,7 +371,7 @@ make_method_entry_refined(rb_method_entry_t *me) new_def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id, rb_method_entry_clone(me)); rb_method_definition_reset(me, new_def); - METHOD_ENTRY_VISI(me) = METHOD_VISI_PUBLIC; + METHOD_ENTRY_VISI_SET(me, METHOD_VISI_PUBLIC); } void @@ -561,7 +559,7 @@ method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me, { rb_method_definition_t *def = rb_method_definition_addref(me->def); rb_method_entry_t *newme = rb_method_entry_make(klass, mid, me->def->type, def, visi, defined_class); - METHOD_ENTRY_SAFE(newme) = METHOD_ENTRY_SAFE(me); + METHOD_ENTRY_SAFE_SET(newme, METHOD_ENTRY_SAFE(me)); method_added(klass, mid); return newme; } @@ -877,10 +875,10 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi) rb_vm_check_redefinition_opt_method(me, klass); if (klass == defined_class || RCLASS_ORIGIN(klass) == defined_class) { - METHOD_ENTRY_VISI(me) = visi; + METHOD_ENTRY_VISI_SET(me, visi); if (me->def->type == VM_METHOD_TYPE_REFINED && me->def->body.refined.orig_me) { - METHOD_ENTRY_VISI((rb_method_entry_t *)me->def->body.refined.orig_me) = visi; + METHOD_ENTRY_VISI_SET((rb_method_entry_t *)me->def->body.refined.orig_me, visi); } rb_clear_method_cache_by_class(klass); } @@ -1403,7 +1401,7 @@ rb_alias(VALUE klass, ID alias_name, ID original_name) RB_OBJ_WRITE(alias_me, &alias_me->klass, defined_class); alias_me->def->original_id = orig_me->called_id; *(ID *)&alias_me->def->body.alias.original_me->called_id = alias_name; - METHOD_ENTRY_SAFE(alias_me) = METHOD_ENTRY_SAFE(orig_me); + METHOD_ENTRY_SAFE_SET(alias_me, METHOD_ENTRY_SAFE(orig_me)); } else { method_entry_set(target_klass, alias_name, orig_me, visi, defined_class); -- cgit v1.2.3