Bug #5047 » 5047.patch
gc.c | ||
---|---|---|
rb_gc_mark_parser();
|
||
rb_gc_mark_unlinked_live_method_entries(th->vm);
|
||
/* gc_mark objects whose marking are not completed*/
|
||
while (!MARK_STACK_EMPTY) {
|
||
if (mark_stack_overflow) {
|
proc.c | ||
---|---|---|
VALUE recv;
|
||
VALUE rclass;
|
||
ID id;
|
||
rb_method_entry_t me;
|
||
rb_method_entry_t *me;
|
||
};
|
||
VALUE rb_cUnboundMethod;
|
||
... | ... | |
struct METHOD *data = ptr;
|
||
rb_gc_mark(data->rclass);
|
||
rb_gc_mark(data->recv);
|
||
rb_mark_method_entry(&data->me);
|
||
rb_mark_method_entry(data->me);
|
||
}
|
||
static void
|
||
bm_free(void *ptr)
|
||
{
|
||
struct METHOD *data = ptr;
|
||
rb_method_definition_t *def = data->me.def;
|
||
if (def->alias_count == 0)
|
||
xfree(def);
|
||
else if (def->alias_count > 0)
|
||
def->alias_count--;
|
||
rb_unlink_method_entry(data->me);
|
||
xfree(ptr);
|
||
}
|
||
... | ... | |
VALUE rclass = klass;
|
||
ID rid = id;
|
||
struct METHOD *data;
|
||
rb_method_entry_t *me, meb;
|
||
rb_method_entry_t *me, *me2, meb;
|
||
rb_method_definition_t *def = 0;
|
||
rb_method_flag_t flag = NOEX_UNDEF;
|
||
... | ... | |
}
|
||
gen_method:
|
||
me2 = ALLOC(rb_method_entry_t);
|
||
method = TypedData_Make_Struct(mclass, struct METHOD, &method_data_type, data);
|
||
data->recv = obj;
|
||
data->rclass = rclass;
|
||
data->id = rid;
|
||
data->me = *me;
|
||
if (def) def->alias_count++;
|
||
data->me = me2;
|
||
*data->me = *me;
|
||
data->me->def->alias_count++;
|
||
OBJ_INFECT(method, klass);
|
||
... | ... | |
m1 = (struct METHOD *)DATA_PTR(method);
|
||
m2 = (struct METHOD *)DATA_PTR(other);
|
||
if (!rb_method_entry_eq(&m1->me, &m2->me) ||
|
||
if (!rb_method_entry_eq(m1->me, m2->me) ||
|
||
m1->rclass != m2->rclass ||
|
||
m1->recv != m2->recv) {
|
||
return Qfalse;
|
||
... | ... | |
TypedData_Get_Struct(method, struct METHOD, &method_data_type, m);
|
||
hash = rb_hash_start((st_index_t)m->rclass);
|
||
hash = rb_hash_uint(hash, (st_index_t)m->recv);
|
||
hash = rb_hash_uint(hash, (st_index_t)m->me.def);
|
||
hash = rb_hash_uint(hash, (st_index_t)m->me->def);
|
||
hash = rb_hash_end(hash);
|
||
return INT2FIX(hash);
|
||
... | ... | |
{
|
||
VALUE method;
|
||
struct METHOD *orig, *data;
|
||
rb_method_entry_t *me2;
|
||
me2 = ALLOC(rb_method_entry_t);
|
||
TypedData_Get_Struct(obj, struct METHOD, &method_data_type, orig);
|
||
method = TypedData_Make_Struct(rb_cUnboundMethod, struct METHOD,
|
||
&method_data_type, data);
|
||
data->recv = Qundef;
|
||
data->id = orig->id;
|
||
data->me = orig->me;
|
||
if (orig->me.def) orig->me.def->alias_count++;
|
||
data->me = me2;
|
||
*data->me = *orig->me;
|
||
if (orig->me->def) orig->me->def->alias_count++;
|
||
data->rclass = orig->rclass;
|
||
OBJ_INFECT(method, obj);
|
||
... | ... | |
struct METHOD *data;
|
||
TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data);
|
||
return data->me.klass;
|
||
return data->me->klass;
|
||
}
|
||
static void
|
||
... | ... | |
rb_class2name(rclass));
|
||
}
|
||
}
|
||
rb_method_entry_set(mod, id, &method->me, noex);
|
||
rb_method_entry_set(mod, id, method->me, noex);
|
||
}
|
||
else if (rb_obj_is_proc(body)) {
|
||
rb_proc_t *proc;
|
||
... | ... | |
{
|
||
VALUE clone;
|
||
struct METHOD *orig, *data;
|
||
rb_method_entry_t *me2;
|
||
me2 = ALLOC(rb_method_entry_t);
|
||
TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig);
|
||
clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data);
|
||
CLONESETUP(clone, self);
|
||
*data = *orig;
|
||
if (data->me.def) data->me.def->alias_count++;
|
||
data->me = me2;
|
||
*data->me = *orig->me;
|
||
if (data->me->def) data->me->def->alias_count++;
|
||
return clone;
|
||
}
|
||
... | ... | |
rb_thread_t *th = GET_THREAD();
|
||
PASS_PASSED_BLOCK_TH(th);
|
||
result = rb_vm_call(th, data->recv, data->id, argc, argv, &data->me);
|
||
result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me);
|
||
}
|
||
POP_TAG();
|
||
if (safe >= 0)
|
||
... | ... | |
umethod_bind(VALUE method, VALUE recv)
|
||
{
|
||
struct METHOD *data, *bound;
|
||
rb_method_entry_t *me2;
|
||
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
||
... | ... | |
}
|
||
}
|
||
me2 = ALLOC(rb_method_entry_t);
|
||
method = TypedData_Make_Struct(rb_cMethod, struct METHOD, &method_data_type, bound);
|
||
*bound = *data;
|
||
if (bound->me.def) bound->me.def->alias_count++;
|
||
bound->me = me2;
|
||
*bound->me = *data->me;
|
||
if (bound->me->def) bound->me->def->alias_count++;
|
||
bound->recv = recv;
|
||
bound->rclass = CLASS_OF(recv);
|
||
... | ... | |
struct METHOD *data;
|
||
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
||
return rb_method_entry_arity(&data->me);
|
||
return rb_method_entry_arity(data->me);
|
||
}
|
||
int
|
||
... | ... | |
struct METHOD *data;
|
||
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
|
||
return data->me.def;
|
||
return data->me->def;
|
||
}
|
||
static rb_iseq_t *
|
||
... | ... | |
rb_str_buf_cat2(str, s);
|
||
rb_str_buf_cat2(str, ": ");
|
||
if (FL_TEST(data->me.klass, FL_SINGLETON)) {
|
||
VALUE v = rb_ivar_get(data->me.klass, attached);
|
||
if (FL_TEST(data->me->klass, FL_SINGLETON)) {
|
||
VALUE v = rb_ivar_get(data->me->klass, attached);
|
||
if (data->recv == Qundef) {
|
||
rb_str_buf_append(str, rb_inspect(data->me.klass));
|
||
rb_str_buf_append(str, rb_inspect(data->me->klass));
|
||
}
|
||
else if (data->recv == v) {
|
||
rb_str_buf_append(str, rb_inspect(v));
|
||
... | ... | |
}
|
||
else {
|
||
rb_str_buf_cat2(str, rb_class2name(data->rclass));
|
||
if (data->rclass != data->me.klass) {
|
||
if (data->rclass != data->me->klass) {
|
||
rb_str_buf_cat2(str, "(");
|
||
rb_str_buf_cat2(str, rb_class2name(data->me.klass));
|
||
rb_str_buf_cat2(str, rb_class2name(data->me->klass));
|
||
rb_str_buf_cat2(str, ")");
|
||
}
|
||
}
|
||
rb_str_buf_cat2(str, sharp);
|
||
rb_str_append(str, rb_id2str(data->me.def->original_id));
|
||
if (data->me.def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
|
||
rb_str_append(str, rb_id2str(data->me->def->original_id));
|
||
if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) {
|
||
rb_str_buf_cat2(str, " (not-implemented)");
|
||
}
|
||
rb_str_buf_cat2(str, ">");
|
vm_core.h | ||
---|---|---|
void rb_vm_gvl_destroy(rb_vm_t *vm);
|
||
VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc,
|
||
const VALUE *argv, const rb_method_entry_t *me);
|
||
void rb_unlink_method_entry(rb_method_entry_t *me);
|
||
void rb_gc_mark_unlinked_live_method_entries(void *pvm);
|
||
void rb_thread_start_timer_thread(void);
|
||
void rb_thread_stop_timer_thread(int);
|
vm_method.c | ||
---|---|---|
}
|
||
}
|
||
static void
|
||
void
|
||
rb_unlink_method_entry(rb_method_entry_t *me)
|
||
{
|
||
struct unlinked_method_entry_list_entry *ume = ALLOC(struct unlinked_method_entry_list_entry);
|
||
... | ... | |
}
|
||
void
|
||
rb_gc_mark_unlinked_live_method_entries(void *pvm)
|
||
{
|
||
rb_vm_t *vm = pvm;
|
||
struct unlinked_method_entry_list_entry *ume = vm->unlinked_method_entry_list, *prev_ume = 0, *curr_ume;
|
||
while (ume) {
|
||
if (ume->me->mark) {
|
||
rb_mark_method_entry(ume->me);
|
||
}
|
||
ume = ume->next;
|
||
}
|
||
}
|
||
void
|
||
rb_sweep_method_entry(void *pvm)
|
||
{
|
||
rb_vm_t *vm = pvm;
|
- « Previous
- 1
- 2
- Next »