Skip to content

Commit e84b91a

Browse files
committed
Box: mark/move Box object referred via ENV/rb_env_t
1 parent 0654bcd commit e84b91a

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

imemo.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,13 @@ rb_imemo_mark_and_move(VALUE obj, bool reference_updating)
426426

427427
rb_gc_mark_and_move_ptr(&env->iseq);
428428

429+
if (VM_ENV_LOCAL_P(env->ep) && VM_ENV_BOXED_P(env->ep)) {
430+
const rb_box_t *box = VM_ENV_BOX(env->ep);
431+
if (BOX_USER_P(box)) {
432+
rb_gc_mark_and_move((VALUE *)&box->box_object);
433+
}
434+
}
435+
429436
if (reference_updating) {
430437
((VALUE *)env->ep)[VM_ENV_DATA_INDEX_ENV] = rb_gc_location(env->ep[VM_ENV_DATA_INDEX_ENV]);
431438
}

vm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,6 +3677,13 @@ rb_execution_context_mark(const rb_execution_context_t *ec)
36773677
rb_gc_mark_movable((VALUE)cfp->iseq);
36783678
rb_gc_mark_movable((VALUE)cfp->block_code);
36793679

3680+
if (VM_ENV_LOCAL_P(ep) && VM_ENV_BOXED_P(ep)) {
3681+
const rb_box_t *box = VM_ENV_BOX(ep);
3682+
if (BOX_USER_P(box)) {
3683+
rb_gc_mark_movable(box->box_object);
3684+
}
3685+
}
3686+
36803687
if (!VM_ENV_LOCAL_P(ep)) {
36813688
const VALUE *prev_ep = VM_ENV_PREV_EP(ep);
36823689
if (VM_ENV_FLAGS(prev_ep, VM_ENV_FLAG_ESCAPED)) {

0 commit comments

Comments
 (0)