diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-15 14:59:41 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-15 14:59:41 +0000 |
commit | c330876d7c5065f89234becc5125426d0d136bdc (patch) | |
tree | d7a65121d7250d0137a2c75d7b7d454737815e7d /vm.c | |
parent | d3cbda6e8dc5732f64b06cacb4c137f01ebe0461 (diff) | |
download | ruby-c330876d7c5065f89234becc5125426d0d136bdc.tar.gz |
* method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
method management. This change affect some VM control stack structure.
* vm.c, vm_insnhelper.c, vm_method.c, vm_eval.c: ditto. and make some
refactoring.
* insns.def, class.c, eval.c, proc.c, vm_dump.c : ditto.
* vm_core.h, compile.c (iseq_specialized_instruction): remove
VM_CALL_SEND_BIT. use another optimization tech for Kernel#send.
* node.h: remove unused node types.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c: add mark/free functions for method entry.
* include/ruby/intern.h: remove decl of
rb_define_notimplement_method_id(). nobody can use it
because noex is not opend.
* iseq.c (iseq_mark): fix to check ic_method is available.
* iseq.c (rb_iseq_disasm): fix to use rb_method_get_iseq().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 37 |
1 files changed, 18 insertions, 19 deletions
@@ -575,7 +575,7 @@ vm_yield(rb_thread_t *th, int argc, const VALUE *argv) VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, - int argc, const VALUE *argv, rb_block_t * blockptr) + int argc, const VALUE *argv, const rb_block_t * blockptr) { VALUE val = Qundef; int state; @@ -734,7 +734,7 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void * } } else if (RUBYVM_CFUNC_FRAME_P(cfp)) { - if ((*iter)(arg, file, line_no, rb_id2name(cfp->method_id))) break; + if ((*iter)(arg, file, line_no, rb_id2name(cfp->me->original_id))) break; } cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp); } @@ -929,22 +929,23 @@ rb_iter_break(void) static st_table *vm_opt_method_table = 0; static void -rb_vm_check_redefinition_opt_method(const NODE *node) +rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me) { VALUE bop; - - if (st_lookup(vm_opt_method_table, (st_data_t)node, &bop)) { - ruby_vm_redefined_flag[bop] = 1; + if (me->type == VM_METHOD_TYPE_CFUNC) { + if (st_lookup(vm_opt_method_table, (st_data_t)me, &bop)) { + ruby_vm_redefined_flag[bop] = 1; + } } } static void add_opt_method(VALUE klass, ID mid, VALUE bop) { - NODE *node; - if (st_lookup(RCLASS_M_TBL(klass), mid, (void *)&node) && - nd_type(node->nd_body->nd_body) == NODE_CFUNC) { - st_insert(vm_opt_method_table, (st_data_t)node, (st_data_t)bop); + rb_method_entry_t *me; + if (st_lookup(RCLASS_M_TBL(klass), mid, (void *)&me) && + me->type == VM_METHOD_TYPE_CFUNC) { + st_insert(vm_opt_method_table, (st_data_t)me, (st_data_t)bop); } else { rb_bug("undefined optimized method: %s", rb_id2name(mid)); @@ -1323,8 +1324,8 @@ rb_thread_method_id_and_class(rb_thread_t *th, rb_control_frame_t *cfp = th->cfp; rb_iseq_t *iseq = cfp->iseq; if (!iseq) { - if (idp) *idp = cfp->method_id; - if (klassp) *klassp = cfp->method_class; + if (idp) *idp = cfp->me->original_id; + if (klassp) *klassp = cfp->me->klass; return 1; } while (iseq) { @@ -1367,10 +1368,10 @@ rb_thread_current_status(const rb_thread_t *th) file, line_no, RSTRING_PTR(iseq->name)); } } - else if (cfp->method_id) { + else if (cfp->me->original_id) { str = rb_sprintf("`%s#%s' (cfunc)", - RSTRING_PTR(rb_class_name(cfp->method_class)), - rb_id2name(cfp->method_id)); + RSTRING_PTR(rb_class_name(cfp->me->klass)), + rb_id2name(cfp->me->original_id)); } return str; @@ -1739,7 +1740,6 @@ static void vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, rb_num_t is_singleton, NODE *cref) { - NODE *newbody; VALUE klass = cref->nd_clss; int noex = (int)cref->nd_visi; rb_iseq_t *miseq; @@ -1768,11 +1768,10 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, COPY_CREF(miseq->cref_stack, cref); miseq->klass = klass; miseq->defined_method_id = id; - newbody = NEW_NODE_LONGLIFE(RUBY_VM_METHOD_NODE, 0, rb_gc_write_barrier(miseq->self), 0); - rb_add_method(klass, id, newbody, noex); + rb_add_method(klass, id, VM_METHOD_TYPE_ISEQ, miseq, noex); if (!is_singleton && noex == NOEX_MODFUNC) { - rb_add_method(rb_singleton_class(klass), id, newbody, NOEX_PUBLIC); + rb_add_method(rb_singleton_class(klass), id, VM_METHOD_TYPE_ISEQ, miseq, NOEX_PUBLIC); } INC_VM_STATE_VERSION(); } |