mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
34ed81ea89
commit
833cade2dc
10 changed files with 122 additions and 23 deletions
7
method.h
7
method.h
|
|
@ -74,11 +74,17 @@ typedef struct rb_method_definition_struct {
|
|||
|
||||
typedef struct rb_method_entry_struct {
|
||||
rb_method_flag_t flag;
|
||||
char mark;
|
||||
rb_method_definition_t *def;
|
||||
ID called_id;
|
||||
VALUE klass; /* should be mark */
|
||||
} rb_method_entry_t;
|
||||
|
||||
struct unlinked_method_entry_list_entry {
|
||||
struct unlinked_method_entry_list_entry *next;
|
||||
rb_method_entry_t *me;
|
||||
};
|
||||
|
||||
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
||||
|
||||
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
|
||||
|
|
@ -92,5 +98,6 @@ int rb_method_entry_arity(const rb_method_entry_t *me);
|
|||
|
||||
void rb_mark_method_entry(const rb_method_entry_t *me);
|
||||
void rb_free_method_entry(rb_method_entry_t *me);
|
||||
void rb_sweep_method_entry(void *vm);
|
||||
|
||||
#endif /* METHOD_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue