From 833cade2dce8ee8a9dd2091fcc84880030a51d54 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 5 May 2010 17:51:21 +0000 Subject: * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry): added. Unlinked method entries are collected to vm->unlinked_method_entry_list. On the GC timing, mark all method entries which are on all living threads. Only non-marked method entries are collected. This hack prevents releasing living method entry. [Performance Consideration] Since this Method Entry GC (MEGC) doesn't occuer frequently, MEGC will not be a performance bottleneck. However, to traverse living method entries, every control frame push needs to clear cfp->me field. This will be a performance issue (because pushing control frame is occurred frequently). Bug #2777 [ruby-dev:40457] * cont.c (fiber_init): init cfp->me. * gc.c (garbage_collect): kick rb_sweep_method_entry(). * method.h (rb_method_entry_t): add a mark field. * vm.c (invoke_block_from_c): set passed me. * vm.c (rb_thread_mark): mark cfp->me. * vm_core.h (rb_thread_t): add a field passed_me. * vm_core.h (rb_vm_t): add a field unlinked_method_entry_list. * vm_insnhelper.c (vm_push_frame): clear cfp->me at all times. * vm_insnhelper.c (vm_call_bmethod): pass me. * bootstraptest/test_method.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 5051d00e1e..be084b4126 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -59,6 +59,7 @@ vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq, cfp->lfp = lfp; cfp->dfp = sp; cfp->proc = 0; + cfp->me = 0; #define COLLECT_PROFILE 0 #if COLLECT_PROFILE @@ -419,7 +420,7 @@ vm_call_bmethod(rb_thread_t *th, VALUE recv, int argc, const VALUE *argv, VALUE val; /* control block frame */ - (cfp-2)->me = me; + th->passed_me = me; GetProcPtr(me->def->body.proc, proc); val = rb_vm_invoke_proc(th, proc, recv, argc, argv, blockptr); -- cgit v1.2.3