8000 Wrap "call data" with an IMEMO object by tenderlove · Pull Request #2627 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

Wrap "call data" with an IMEMO object #2627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/objspace/objspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ count_imemo_objects(int argc, VALUE *argv, VALUE self)
imemo_type_ids[8] = rb_intern("imemo_tmpbuf");
imemo_type_ids[9] = rb_intern("imemo_ast");
imemo_type_ids[10] = rb_intern("imemo_parser_strterm");
imemo_type_ids[11] = rb_intern("imemo_call_data");
}

rb_objspace_each_objects(count_imemo_objects_i, (void *)hash);
Expand Down
1 change: 1 addition & 0 deletions ext/objspace/objspace_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ imemo_name(int imemo)
TYPE_STR(tmpbuf);
TYPE_STR(ast);
TYPE_STR(parser_strterm);
TYPE_STR(call_data);
default:
return "unknown";
#undef TYPE_STR
Expand Down
7 changes: 7 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,7 @@ imemo_memsize(VALUE obj)
case imemo_ifunc:
case imemo_memo:
case imemo_parser_strterm:
case imemo_call_data:
break;
default:
/* unreachable */
Expand Down Expand Up @@ -2826,6 +2827,9 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case imemo_parser_strterm:
RB_DEBUG_COUNTER_INC(obj_imemo_parser_strterm);
break;
case imemo_call_data:
RB_DEBUG_COUNTER_INC(obj_imemo_call_data);
break;
default:
/* unreachable */
break;
Expand Down Expand Up @@ -5227,6 +5231,8 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
case imemo_parser_strterm:
rb_strterm_mark(obj);
return;
case imemo_call_data:
return;
#if VM_CHECK_MODE > 0
default:
VM_UNREACHABLE(gc_mark_imemo);
Expand Down Expand Up @@ -8095,6 +8101,7 @@ gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
break;
case imemo_parser_strterm:
case imemo_tmpbuf:
case imemo_call_data:
break;
default:
rb_bug("not reachable %d", imemo_type(obj));
Expand Down
13 changes: 12 additions & 1 deletion internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,8 @@ enum imemo_type {
imemo_iseq = 7,
imemo_tmpbuf = 8,
imemo_ast = 9,
imemo_parser_strterm = 10
imemo_parser_strterm = 10,
imemo_call_data = 11
};
#define IMEMO_MASK 0x0f

Expand Down Expand Up @@ -2396,11 +2397,21 @@ RUBY_FUNC_NONNULL(1, bool rb_method_basic_definition_p_with_cc(struct rb_call_da
# define rb_funcallv(recv, mid, argc, argv) \
__extension__({ \
static struct rb_call_data rb_funcallv_data; \
static VALUE wrapper = 0; \
if (!wrapper) { \
wrapper = rb_imemo_new(imemo_call_data, 0, 0, 0, (VALUE)&rb_funcallv_data); \
rb_gc_register_mark_object(wrapper); \
} \
rb_funcallv_with_cc(&rb_funcallv_data, recv, mid, argc, argv); \
})
# define rb_method_basic_definition_p(klass, mid) \
__extension__({ \
static struct rb_call_data rb_mbdp; \
static VALUE wrapper = 0; \
if (!wrapper) { \
wrapper = rb_imemo_new(imemo_call_data, 0, 0, 0, (VALUE)&rb_mbdp); \
rb_gc_register_mark_object(wrapper); \
} \
(klass == Qfalse) ? /* hidden object cannot be overridden */ true : \
rb_method_basic_definition_p_with_cc(&rb_mbdp, klass, mid); \
})
Expand Down
0