Make all of the references of iseq movable

This commit is contained in:
Peter Zhu 2023-01-19 14:47:17 -05:00
parent 76e3d853ab
commit 056e7a0154
Notes: git 2023-01-20 13:51:59 +00:00
5 changed files with 30 additions and 29 deletions

View File

@ -10736,7 +10736,7 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
} }
void void
rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *storage) rb_iseq_mark_and_update_insn_storage(struct iseq_compile_data_storage *storage)
{ {
INSN *iobj = 0; INSN *iobj = 0;
size_t size = sizeof(INSN); size_t size = sizeof(INSN);
@ -10772,13 +10772,7 @@ rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *storage)
case TS_VALUE: case TS_VALUE:
case TS_IC: // constant path array case TS_IC: // constant path array
case TS_CALLDATA: // ci is stored. case TS_CALLDATA: // ci is stored.
{ rb_gc_mark_and_move(&OPERAND_AT(iobj, j));
VALUE op = OPERAND_AT(iobj, j);
if (!SPECIAL_CONST_P(op)) {
rb_gc_mark(op);
}
}
break; break;
default: default:
break; break;

35
iseq.c
View File

@ -373,28 +373,23 @@ rb_iseq_mark_and_update(rb_iseq_t *iseq, bool reference_updating)
} }
} }
// TODO: make these not pinned if (FL_TEST_RAW((VALUE)iseq, ISEQ_NOT_LOADED_YET)) {
if (!reference_updating) { rb_gc_mark_and_move(&iseq->aux.loader.obj);
if (FL_TEST_RAW((VALUE)iseq, ISEQ_NOT_LOADED_YET)) { }
rb_gc_mark(iseq->aux.loader.obj); else if (FL_TEST_RAW((VALUE)iseq, ISEQ_USE_COMPILE_DATA)) {
} const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
else if (FL_TEST_RAW((VALUE)iseq, ISEQ_USE_COMPILE_DATA)) {
const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
rb_iseq_mark_insn_storage(compile_data->insn.storage_head); rb_iseq_mark_and_update_insn_storage(compile_data->insn.storage_head);
RUBY_MARK_UNLESS_NULL(compile_data->err_info); rb_gc_mark_and_move((VALUE *)&compile_data->err_info);
if (RTEST(compile_data->catch_table_ary)) { rb_gc_mark_and_move((VALUE *)&compile_data->catch_table_ary);
rb_gc_mark(compile_data->catch_table_ary); }
} else {
VM_ASSERT(compile_data != NULL); /* executable */
} VM_ASSERT(ISEQ_EXECUTABLE_P(iseq));
else {
/* executable */ if (iseq->aux.exec.local_hooks) {
VM_ASSERT(ISEQ_EXECUTABLE_P(iseq)); rb_hook_list_mark_and_update(iseq->aux.exec.local_hooks);
if (iseq->aux.exec.local_hooks) {
rb_hook_list_mark(iseq->aux.exec.local_hooks);
}
} }
} }

2
iseq.h
View File

@ -186,7 +186,7 @@ VALUE *rb_iseq_original_iseq(const rb_iseq_t *iseq);
void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
VALUE locals, VALUE args, VALUE locals, VALUE args,
VALUE exception, VALUE body); VALUE exception, VALUE body);
void rb_iseq_mark_insn_storage(struct iseq_compile_data_storage *arena); void rb_iseq_mark_and_update_insn_storage(struct iseq_compile_data_storage *arena);
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt); VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc); VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);

View File

@ -2015,6 +2015,7 @@ struct rb_trace_arg_struct {
}; };
void rb_hook_list_mark(rb_hook_list_t *hooks); void rb_hook_list_mark(rb_hook_list_t *hooks);
void rb_hook_list_mark_and_update(rb_hook_list_t *hooks);
void rb_hook_list_free(rb_hook_list_t *hooks); void rb_hook_list_free(rb_hook_list_t *hooks);
void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line); void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval); void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval);

View File

@ -66,6 +66,17 @@ rb_hook_list_mark(rb_hook_list_t *hooks)
} }
} }
void
rb_hook_list_mark_and_update(rb_hook_list_t *hooks)
{
rb_event_hook_t *hook = hooks->hooks;
while (hook) {
rb_gc_mark_and_move(&hook->data);
hook = hook->next;
}
}
static void clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list); static void clean_hooks(const rb_execution_context_t *ec, rb_hook_list_t *list);
void void