From 8dced4d2c0f284bd17a3cb4a4fbed6d459cc71e0 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 8 Mar 2015 21:22:43 +0000 Subject: * internal.h: define rb_cref_t and change to use it. rb_cref_t is data type of CREF. Now, the body is still NODE. It is easy to understand what is CREF and what is pure NODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 ++++ class.c | 2 +- eval.c | 20 ++++++------ eval_intern.h | 2 +- insns.def | 8 ++--- internal.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++------ method.h | 4 +-- node.c | 8 ++--- node.h | 2 -- proc.c | 6 ++-- vm.c | 32 +++++++++---------- vm_core.h | 4 +-- vm_eval.c | 21 ++++++------ vm_insnhelper.c | 48 ++++++++++++++-------------- vm_insnhelper.h | 10 +++--- vm_method.c | 8 ++--- 16 files changed, 181 insertions(+), 100 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2cd878e3f9..9d1fe22972 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Mar 9 06:19:06 2015 Koichi Sasada + + * internal.h: define rb_cref_t and change to use it. + + rb_cref_t is data type of CREF. Now, the body is still NODE. + It is easy to understand what is CREF and what is pure NODE. + Mon Mar 9 06:00:37 2015 Koichi Sasada * vm_insnhelper.h (COPY_CREF_OMOD): fix translation miss. diff --git a/class.c b/class.c index 73e7003d6a..f11eb52f4d 100644 --- a/class.c +++ b/class.c @@ -246,7 +246,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) VALUE newiseqval; if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) { rb_iseq_t *iseq; - NODE *new_cref; + rb_cref_t *new_cref; newiseqval = rb_iseq_clone(me->def->body.iseq_body.iseq->self, klass); GetISeqPtr(newiseqval, iseq); rb_vm_rewrite_cref_stack(me->def->body.iseq_body.cref, me->klass, klass, &new_cref); diff --git a/eval.c b/eval.c index 7efc4c7be0..1ca414a704 100644 --- a/eval.c +++ b/eval.c @@ -341,7 +341,7 @@ static VALUE rb_mod_nesting(void) { VALUE ary = rb_ary_new(); - const NODE *cref = rb_vm_cref(); + const rb_cref_t *cref = rb_vm_cref(); while (cref && CREF_NEXT(cref)) { VALUE klass = CREF_CLASS(cref); @@ -379,7 +379,7 @@ rb_mod_nesting(void) static VALUE rb_mod_s_constants(int argc, VALUE *argv, VALUE mod) { - const NODE *cref = rb_vm_cref(); + const rb_cref_t *cref = rb_vm_cref(); VALUE klass; VALUE cbase = 0; void *data = 0; @@ -1154,18 +1154,18 @@ hidden_identity_hash_new(void) } void -rb_using_refinement(NODE *cref, VALUE klass, VALUE module) +rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module) { VALUE iclass, c, superclass = klass; Check_Type(klass, T_CLASS); Check_Type(module, T_MODULE); if (NIL_P(CREF_REFINEMENTS(cref))) { - RB_OBJ_WRITE(cref, &CREF_REFINEMENTS(cref), hidden_identity_hash_new()); + CREF_REFINEMENTS_SET(cref, hidden_identity_hash_new()); } else { if (CREF_OMOD_SHARED(cref)) { - RB_OBJ_WRITE(cref, &CREF_REFINEMENTS(cref), rb_hash_dup(CREF_REFINEMENTS(cref))); + CREF_REFINEMENTS_SET(cref, rb_hash_dup(CREF_REFINEMENTS(cref))); CREF_OMOD_SHARED_UNSET(cref); } if (!NIL_P(c = rb_hash_lookup(CREF_REFINEMENTS(cref), klass))) { @@ -1199,14 +1199,14 @@ rb_using_refinement(NODE *cref, VALUE klass, VALUE module) static int using_refinement(VALUE klass, VALUE module, VALUE arg) { - NODE *cref = (NODE *) arg; + rb_cref_t *cref = (rb_cref_t *) arg; rb_using_refinement(cref, klass, module); return ST_CONTINUE; } static void -using_module_recursive(NODE *cref, VALUE klass) +using_module_recursive(const rb_cref_t *cref, VALUE klass) { ID id_refinements; VALUE super, module, refinements; @@ -1236,7 +1236,7 @@ using_module_recursive(NODE *cref, VALUE klass) } void -rb_using_module(NODE *cref, VALUE module) +rb_using_module(const rb_cref_t *cref, VALUE module) { Check_Type(module, T_MODULE); using_module_recursive(cref, module); @@ -1348,7 +1348,7 @@ rb_mod_refine(VALUE module, VALUE klass) static VALUE mod_using(VALUE self, VALUE module) { - NODE *cref = rb_vm_cref(); + const rb_cref_t *cref = rb_vm_cref(); rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD()); if (prev_frame_func()) { @@ -1485,7 +1485,7 @@ top_include(int argc, VALUE *argv, VALUE self) static VALUE top_using(VALUE self, VALUE module) { - NODE *cref = rb_vm_cref(); + const rb_cref_t *cref = rb_vm_cref(); rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD()); if (CREF_NEXT(cref) || (prev_cfp && prev_cfp->me)) { diff --git a/eval_intern.h b/eval_intern.h index 9e3ef45fca..a8fd7161fa 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -245,7 +245,7 @@ NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, const VALUE *ar VALUE obj, int call_status)); VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val); -NODE *rb_vm_cref(void); +rb_cref_t *rb_vm_cref(void); VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename); void rb_vm_set_progname(VALUE filename); void rb_thread_terminate_all(void); diff --git a/insns.def b/insns.def index 761d1fc5eb..7cfd2ee521 100644 --- a/insns.def +++ b/insns.def @@ -159,8 +159,7 @@ getclassvariable () (VALUE val) { - NODE *cref = rb_vm_get_cref(GET_EP()); - val = rb_cvar_get(vm_get_cvar_base(cref, GET_CFP()), id); + val = rb_cvar_get(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id); } /** @@ -174,8 +173,7 @@ setclassvariable (VALUE val) () { - NODE *cref = rb_vm_get_cref(GET_EP()); - rb_cvar_set(vm_get_cvar_base(cref, GET_CFP()), id, val); + rb_cvar_set(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id, val); } /** @@ -738,7 +736,7 @@ defined } break; case DEFINED_CVAR: { - NODE *cref = rb_vm_get_cref(GET_EP()); + const rb_cref_t *cref = rb_vm_get_cref(GET_EP()); klass = vm_get_cvar_base(cref, GET_CFP()); if (rb_cvar_defined(klass, SYM2ID(obj))) { expr_type = DEFINED_CVAR; diff --git a/internal.h b/internal.h index 016d4d4fcf..b146b46d30 100644 --- a/internal.h +++ b/internal.h @@ -506,16 +506,95 @@ RCLASS_SET_SUPER(VALUE klass, VALUE super) } /* CREF */ -#define CREF_CLASS(cref) ((cref)->nd_clss_) -#define CREF_NEXT(cref) ((cref)->nd_next) -#define CREF_VISI(cref) ((cref)->nd_visi_) -#define CREF_VISI_SET(cref, v) ((cref)->nd_visi_ = (v)) -#define CREF_REFINEMENTS(cref) ((cref)->nd_refinements_) -#define CREF_PUSHED_BY_EVAL(cref) ((cref)->flags & NODE_FL_CREF_PUSHED_BY_EVAL_) -#define CREF_PUSHED_BY_EVAL_SET(cref) ((cref)->flags |= NODE_FL_CREF_PUSHED_BY_EVAL_) -#define CREF_OMOD_SHARED(cref) ((cref)->flags & NODE_FL_CREF_OMOD_SHARED_) -#define CREF_OMOD_SHARED_SET(cref) ((cref)->flags |= NODE_FL_CREF_OMOD_SHARED_) -#define CREF_OMOD_SHARED_UNSET(cref) ((cref)->flags &= ~NODE_FL_CREF_OMOD_SHARED_) + +typedef struct rb_cref_struct { + VALUE flags; + VALUE refinements; + VALUE klass; + VALUE visi; + struct rb_cref_struct *next; +} rb_cref_t; + +#define NODE_FL_CREF_PUSHED_BY_EVAL_ (((VALUE)1)<<15) +#define NODE_FL_CREF_OMOD_SHARED_ (((VALUE)1)<<16) + +static inline VALUE +CREF_CLASS(const rb_cref_t *cref) +{ + return cref->klass; +} + +static inline void +CREF_CLASS_SET(rb_cref_t *cref, VALUE klass) +{ + RB_OBJ_WRITE(cref, &cref->klass, klass); +} + +static inline rb_cref_t * +CREF_NEXT(const rb_cref_t *cref) +{ + return cref->next; +} + +static inline void +CREF_NEXT_SET(rb_cref_t *cref, const rb_cref_t *next_cref) +{ + RB_OBJ_WRITE(cref, &cref->next, next_cref); +} + +static inline long +CREF_VISI(const rb_cref_t *cref) +{ + return (long)cref->visi; +} + +static inline void +CREF_VISI_SET(rb_cref_t *cref, long v) +{ + cref->visi = v; +} + +static inline VALUE +CREF_REFINEMENTS(const rb_cref_t *cref) +{ + return cref->refinements; +} + +static inline void +CREF_REFINEMENTS_SET(rb_cref_t *cref, VALUE refs) +{ + RB_OBJ_WRITE(cref, &cref->refinements, refs); +} + +static inline int +CREF_PUSHED_BY_EVAL(const rb_cref_t *cref) +{ + return cref->flags & NODE_FL_CREF_PUSHED_BY_EVAL_; +} + +static inline void +CREF_PUSHED_BY_EVAL_SET(rb_cref_t *cref) +{ + cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL_; +} + +static inline int +CREF_OMOD_SHARED(const rb_cref_t *cref) +{ + return cref->flags & NODE_FL_CREF_OMOD_SHARED_; +} + +static inline void +CREF_OMOD_SHARED_SET(rb_cref_t *cref) +{ + cref->flags |= NODE_FL_CREF_OMOD_SHARED_; +} + +static inline void +CREF_OMOD_SHARED_UNSET(rb_cref_t *cref) +{ + cref->flags &= ~NODE_FL_CREF_OMOD_SHARED_; +} struct vtm; /* defined by timev.h */ diff --git a/method.h b/method.h index 9df9430946..2e6897f1d7 100644 --- a/method.h +++ b/method.h @@ -84,7 +84,7 @@ typedef struct rb_method_definition_struct { union { struct { rb_iseq_t *const iseq; /* should be mark */ - NODE *cref; + rb_cref_t *cref; } iseq_body; rb_method_cfunc_t cfunc; rb_method_attr_t attr; @@ -118,7 +118,7 @@ struct unlinked_method_entry_list_entry { UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me)) void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); -void rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, NODE *cref, rb_method_flag_t noex); +void rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, rb_cref_t *cref, rb_method_flag_t noex); rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex); rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr); rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id); diff --git a/node.c b/node.c index c401100179..2d33554121 100644 --- a/node.c +++ b/node.c @@ -947,7 +947,7 @@ rb_gc_mark_node(NODE *obj) { switch (nd_type(obj)) { case NODE_IF: /* 1,2,3 */ - rb_gc_mark(CREF_REFINEMENTS(obj)); /* use as SVAR */ + rb_gc_mark(CREF_REFINEMENTS((rb_cref_t *)obj)); /* use as SVAR */ case NODE_FOR: case NODE_ITER: case NODE_WHEN: @@ -1070,9 +1070,9 @@ rb_gc_mark_node(NODE *obj) break; case NODE_CREF: - rb_gc_mark(CREF_REFINEMENTS(obj)); - rb_gc_mark(CREF_CLASS(obj)); - return (VALUE)CREF_NEXT(obj);; + rb_gc_mark(CREF_REFINEMENTS((rb_cref_t *)obj)); + rb_gc_mark(CREF_CLASS((rb_cref_t *)obj)); + return (VALUE)CREF_NEXT((rb_cref_t *)obj); default: /* unlisted NODE */ rb_gc_mark_maybe(RNODE(obj)->u1.value); diff --git a/node.h b/node.h index f3e5c72d05..c3546a7b1e 100644 --- a/node.h +++ b/node.h @@ -273,8 +273,6 @@ typedef struct RNode { * 16: NODE_FL_CREF_OMOD_SHARED */ #define NODE_FL_NEWLINE (((VALUE)1)<<7) -#define NODE_FL_CREF_PUSHED_BY_EVAL_ (((VALUE)1)<<15) -#define NODE_FL_CREF_OMOD_SHARED_ (((VALUE)1)<<16) #define NODE_TYPESHIFT 8 #define NODE_TYPEMASK (((VALUE)0x7f)<type) { diff --git a/vm.c b/vm.c index 0f7f98bdec..da25fbd04b 100644 --- a/vm.c +++ b/vm.c @@ -79,20 +79,20 @@ rb_vm_control_frame_block_ptr(const rb_control_frame_t *cfp) return VM_CF_BLOCK_PTR(cfp); } -static NODE * -vm_cref_new(VALUE klass, long visi, NODE *prev_cref) +static rb_cref_t * +vm_cref_new(VALUE klass, long visi, const rb_cref_t *prev_cref) { - NODE *cref = NEW_CREF(klass); - CREF_REFINEMENTS(cref) = Qnil; + rb_cref_t *cref = (rb_cref_t *)NEW_CREF(klass); + CREF_REFINEMENTS_SET(cref, Qnil); CREF_VISI_SET(cref, visi); - CREF_NEXT(cref) = prev_cref; + CREF_NEXT_SET(cref, prev_cref); return cref; } -static NODE * +static rb_cref_t * vm_cref_new_toplevel(rb_thread_t *th) { - NODE *cref = vm_cref_new(rb_cObject, NOEX_PRIVATE /* toplevel visibility is private */, NULL); + rb_cref_t *cref = vm_cref_new(rb_cObject, NOEX_PRIVATE /* toplevel visibility is private */, NULL); if (th->top_wrapper) { cref = vm_cref_new(th->top_wrapper, NOEX_PRIVATE, cref); @@ -102,7 +102,7 @@ vm_cref_new_toplevel(rb_thread_t *th) } static void -vm_cref_dump(const char *mesg, const NODE *cref) +vm_cref_dump(const char *mesg, const rb_cref_t *cref) { fprintf(stderr, "vm_cref_dump: %s (%p)\n", mesg, cref); @@ -251,7 +251,7 @@ vm_set_top_stack(rb_thread_t *th, VALUE iseqval) } static void -vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block) +vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const rb_cref_t *cref, rb_block_t *base_block) { rb_iseq_t *iseq; GetISeqPtr(iseqval, iseq); @@ -795,7 +795,7 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars) static inline VALUE invoke_block_from_c(rb_thread_t *th, const rb_block_t *block, VALUE self, int argc, const VALUE *argv, - const rb_block_t *blockptr, const NODE *cref, + const rb_block_t *blockptr, const rb_cref_t *cref, VALUE defined_class, int splattable) { if (SPECIAL_CONST_P(block->iseq)) { @@ -870,7 +870,7 @@ check_block(rb_thread_t *th) } static inline VALUE -vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref) +vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref) { const rb_block_t *blockptr = check_block(th); return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, 0, cref, @@ -1039,7 +1039,7 @@ rb_sourceline(void) } } -NODE * +rb_cref_t * rb_vm_cref(void) { rb_thread_t *th = GET_THREAD(); @@ -1052,12 +1052,12 @@ rb_vm_cref(void) return rb_vm_get_cref(cfp->ep); } -const NODE * +const rb_cref_t * rb_vm_cref_in_context(VALUE self, VALUE cbase) { rb_thread_t *th = GET_THREAD(); const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); - const NODE *cref; + const rb_cref_t *cref; if (cfp->self != self) return NULL; cref = rb_vm_get_cref(cfp->ep); if (CREF_CLASS(cref) != cbase) return NULL; @@ -1066,7 +1066,7 @@ rb_vm_cref_in_context(VALUE self, VALUE cbase) #if 0 void -debug_cref(NODE *cref) +debug_cref(rb_cref_t *cref) { while (cref) { dp(CREF_CLASS(cref)); @@ -2264,7 +2264,7 @@ rb_thread_alloc(VALUE klass) static void vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, - rb_num_t is_singleton, NODE *cref) + rb_num_t is_singleton, rb_cref_t *cref) { VALUE klass = CREF_CLASS(cref); int noex = CREF_VISI(cref); diff --git a/vm_core.h b/vm_core.h index 5b364129bb..5c2cc2a5ed 100644 --- a/vm_core.h +++ b/vm_core.h @@ -117,7 +117,7 @@ typedef struct rb_compile_option_struct rb_compile_option_t; struct iseq_inline_cache_entry { rb_serial_t ic_serial; - NODE *ic_cref; + rb_cref_t *ic_cref; union { size_t index; VALUE value; @@ -1000,7 +1000,7 @@ void rb_gc_mark_machine_stack(rb_thread_t *th); int rb_autoloading_value(VALUE mod, ID id, VALUE* value); -void rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr); +void rb_vm_rewrite_cref_stack(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr); #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] diff --git a/vm_eval.c b/vm_eval.c index 9a97f2b805..dbc77a583e 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -16,12 +16,11 @@ struct local_var_list { }; static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status); -static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref); +static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref); static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv); static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr); -static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr); static VALUE vm_exec(rb_thread_t *th); -static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block); +static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const rb_cref_t *cref, rb_block_t *base_block); static int vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *dfp, const struct local_var_list *vars); static VALUE rb_eUncaughtThrow; @@ -1229,7 +1228,7 @@ rb_each(VALUE obj) } static VALUE -eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, volatile VALUE file, volatile int line) +eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_arg, volatile VALUE file, volatile int line) { int state; VALUE result = Qundef; @@ -1239,7 +1238,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, rb_block_t block, *base_block; volatile int parse_in_eval; volatile int mild_compile_error; - NODE *orig_cref; + rb_cref_t *orig_cref; VALUE crefval; if (file == 0) { @@ -1251,7 +1250,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, mild_compile_error = th->mild_compile_error; TH_PUSH_TAG(th); if ((state = TH_EXEC_TAG()) == 0) { - NODE *cref = cref_arg; + rb_cref_t *cref = cref_arg; rb_binding_t *bind = 0; rb_iseq_t *iseq; volatile VALUE iseqval; @@ -1308,7 +1307,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, if (!cref && base_block->iseq) { if (NIL_P(scope)) { orig_cref = rb_vm_get_cref(base_block->ep); - cref = NEW_CREF(Qnil); + cref = (rb_cref_t *)NEW_CREF(Qnil); crefval = (VALUE) cref; COPY_CREF(cref, orig_cref); } @@ -1559,7 +1558,7 @@ yield_under(VALUE under, VALUE self, VALUE values) { rb_thread_t *th = GET_THREAD(); rb_block_t block, *blockptr; - NODE *cref; + rb_cref_t *cref; if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) { block = *blockptr; @@ -1582,7 +1581,7 @@ rb_yield_refine_block(VALUE refinement, VALUE refinements) { rb_thread_t *th = GET_THREAD(); rb_block_t block, *blockptr; - NODE *cref; + rb_cref_t *cref; if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) { block = *blockptr; @@ -1591,7 +1590,7 @@ rb_yield_refine_block(VALUE refinement, VALUE refinements) } cref = vm_cref_push(th, refinement, NOEX_PUBLIC, blockptr); CREF_PUSHED_BY_EVAL_SET(cref); - RB_OBJ_WRITE(cref, &CREF_REFINEMENTS(cref), refinements); + CREF_REFINEMENTS_SET(cref, refinements); return vm_yield_with_cref(th, 0, NULL, cref); } @@ -1600,7 +1599,7 @@ rb_yield_refine_block(VALUE refinement, VALUE refinements) static VALUE eval_under(VALUE under, VALUE self, VALUE src, VALUE file, int line) { - NODE *cref = vm_cref_push(GET_THREAD(), under, NOEX_PUBLIC, NULL); + rb_cref_t *cref = vm_cref_push(GET_THREAD(), under, NOEX_PUBLIC, NULL); if (SPECIAL_CONST_P(self) && !NIL_P(under)) { CREF_PUSHED_BY_EVAL_SET(cref); diff --git a/vm_insnhelper.c b/vm_insnhelper.c index e1547cee69..e0db79902f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -46,7 +46,7 @@ vm_push_frame(rb_thread_t *th, VALUE self, VALUE klass, VALUE specval, - const NODE *cref, + const rb_cref_t *cref, const VALUE *pc, VALUE *sp, int local_size, @@ -194,7 +194,7 @@ lep_svar_set(rb_thread_t *th, VALUE *lep, rb_num_t key, VALUE val) svar->nd_reserved = Qfalse; } else if (nd_type(svar) == NODE_CREF) { - NODE *cref = svar; + const rb_cref_t *cref = (rb_cref_t *)svar; svar = *svar_place = NEW_IF(Qnil, Qnil, Qnil); svar->nd_reserved = (VALUE)cref; } @@ -253,7 +253,7 @@ vm_getspecial(rb_thread_t *th, VALUE *lep, rb_num_t key, rb_num_t type) return val; } -static NODE * +static rb_cref_t * ep_cref(const VALUE *ep) { const VALUE svar = ep[-1]; @@ -262,29 +262,29 @@ ep_cref(const VALUE *ep) return NULL; } else if (nd_type(svar) == NODE_CREF) { - return (NODE *)svar; + return (rb_cref_t *)svar; } else { - return (NODE *)((NODE *)svar)->nd_reserved; + return (rb_cref_t *)((NODE *)svar)->nd_reserved; } } -static NODE * +static rb_cref_t * vm_get_cref0(const VALUE *ep) { while (!VM_EP_LEP_P(ep)) { if (ep[-1]) { - return (NODE *)ep[-1]; + return (rb_cref_t *)ep[-1]; } ep = VM_EP_PREV_EP(ep); } return ep_cref(ep); } -NODE * +rb_cref_t * rb_vm_get_cref(const VALUE *ep) { - NODE *cref = vm_get_cref0(ep); + rb_cref_t *cref = vm_get_cref0(ep); if (cref == 0) { rb_bug("rb_vm_get_cref: unreachable"); @@ -294,32 +294,32 @@ rb_vm_get_cref(const VALUE *ep) } void -rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr) +rb_vm_rewrite_cref_stack(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr) { - NODE *new_node; + rb_cref_t *new_node; while (node) { if (CREF_CLASS(node) == old_klass) { - new_node = NEW_CREF(new_klass); + new_node = (rb_cref_t *)NEW_CREF(new_klass); COPY_CREF_OMOD(new_node, node); - RB_OBJ_WRITE(new_node, &CREF_NEXT(new_node), CREF_NEXT(node)); + CREF_NEXT_SET(new_node, CREF_NEXT(node)); *new_cref_ptr = new_node; return; } - new_node = NEW_CREF(CREF_CLASS(node)); + new_node = (rb_cref_t *)NEW_CREF(CREF_CLASS(node)); COPY_CREF_OMOD(new_node, node); node = CREF_NEXT(node); *new_cref_ptr = new_node; - new_cref_ptr = &CREF_NEXT(new_node); + new_cref_ptr = &new_node->next; } *new_cref_ptr = NULL; } -static NODE * +static rb_cref_t * vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr) { - NODE *prev_cref = NULL; - NODE *cref = NULL; + const rb_cref_t *prev_cref = NULL; + rb_cref_t *cref = NULL; if (blockptr) { prev_cref = vm_get_cref0(blockptr->ep); @@ -345,7 +345,7 @@ vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr) static inline VALUE vm_get_cbase(const VALUE *ep) { - NODE *cref = rb_vm_get_cref(ep); + const rb_cref_t *cref = rb_vm_get_cref(ep); VALUE klass = Qundef; while (cref) { @@ -361,7 +361,7 @@ vm_get_cbase(const VALUE *ep) static inline VALUE vm_get_const_base(const VALUE *ep) { - NODE *cref = rb_vm_get_cref(ep); + const rb_cref_t *cref = rb_vm_get_cref(ep); VALUE klass = Qundef; while (cref) { @@ -407,8 +407,8 @@ vm_get_ev_const(rb_thread_t *th, VALUE orig_klass, ID id, int is_defined) if (orig_klass == Qnil) { /* in current lexical scope */ - const NODE *root_cref = rb_vm_get_cref(th->cfp->ep); - const NODE *cref; + const rb_cref_t *root_cref = rb_vm_get_cref(th->cfp->ep); + const rb_cref_t *cref; VALUE klass = orig_klass; while (root_cref && CREF_PUSHED_BY_EVAL(root_cref)) { @@ -477,7 +477,7 @@ vm_get_ev_const(rb_thread_t *th, VALUE orig_klass, ID id, int is_defined) } static inline VALUE -vm_get_cvar_base(NODE *cref, rb_control_frame_t *cfp) +vm_get_cvar_base(const rb_cref_t *cref, rb_control_frame_t *cfp) { VALUE klass; @@ -1784,7 +1784,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) case VM_METHOD_TYPE_UNDEF: break; case VM_METHOD_TYPE_REFINED:{ - NODE *cref = rb_vm_get_cref(cfp->ep); + const rb_cref_t *cref = rb_vm_get_cref(cfp->ep); VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil; VALUE refinement, defined_class; rb_method_entry_t *me; diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 20edcc62e7..f88557e22b 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -146,7 +146,7 @@ enum vm_regan_acttype { /**********************************************************/ #define COPY_CREF_OMOD(c1, c2) do { \ - RB_OBJ_WRITE((c1), &CREF_REFINEMENTS(c1), CREF_REFINEMENTS(c2)); \ + CREF_REFINEMENTS_SET(c1, CREF_REFINEMENTS(c2)); \ if (!NIL_P(CREF_REFINEMENTS(c2))) { \ CREF_OMOD_SHARED_SET(c1); \ CREF_OMOD_SHARED_SET(c2); \ @@ -154,11 +154,11 @@ enum vm_regan_acttype { } while (0) #define COPY_CREF(c1, c2) do { \ - NODE *__tmp_c2 = (c2); \ - COPY_CREF_OMOD(c1, __tmp_c2); \ - RB_OBJ_WRITE((c1), &CREF_CLASS(c1), CREF_CLASS(__tmp_c2)); \ + rb_cref_t *__tmp_c2 = (c2); \ + COPY_CREF_OMOD((c1), __tmp_c2); \ + CREF_CLASS_SET((c1), CREF_CLASS(__tmp_c2));\ CREF_VISI_SET((c1), CREF_VISI(__tmp_c2));\ - RB_OBJ_WRITE((c1), &CREF_NEXT(c1), CREF_NEXT(__tmp_c2)); \ + CREF_NEXT_SET((c1), CREF_NEXT(__tmp_c2));\ if (CREF_PUSHED_BY_EVAL(__tmp_c2)) { \ CREF_PUSHED_BY_EVAL_SET(c1); \ } \ diff --git a/vm_method.c b/vm_method.c index 48c518ffeb..c7caccb32f 100644 --- a/vm_method.c +++ b/vm_method.c @@ -447,7 +447,7 @@ setup_method_cfunc_struct(rb_method_cfunc_t *cfunc, VALUE (*func)(), int argc) } rb_method_entry_t * -rb_add_method0(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex, NODE *cref) +rb_add_method0(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex, rb_cref_t *cref) { rb_thread_t *th; rb_control_frame_t *cfp; @@ -471,7 +471,7 @@ rb_add_method0(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method switch (type) { case VM_METHOD_TYPE_ISEQ: { rb_iseq_t *iseq = (rb_iseq_t *)opts; - NODE *private_cref; + rb_cref_t *private_cref; *(rb_iseq_t **)&def->body.iseq_body.iseq = iseq; RB_OBJ_WRITTEN(klass, Qundef, iseq->self); /* should be set iseq before newobj */ @@ -531,7 +531,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_ } void -rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, NODE *cref, rb_method_flag_t noex) +rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, rb_cref_t *cref, rb_method_flag_t noex) { rb_add_method0(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, noex, cref); } @@ -743,7 +743,7 @@ rb_method_entry_with_refinements(VALUE klass, ID id, rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class); if (me && me->def->type == VM_METHOD_TYPE_REFINED) { - NODE *cref = rb_vm_cref(); + const rb_cref_t *cref = rb_vm_cref(); VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil; me = rb_resolve_refined_method(refinements, me, &defined_class); -- cgit v1.2.3