Box: mark/move Box object referred via ENV/rb_env_t

This commit is contained in:
Satoshi Tagomori 2025-11-26 00:36:55 +09:00 committed by Satoshi Tagomori
parent 0654bcd4f8
commit e84b91a292
Notes: git 2025-11-26 01:11:18 +00:00
2 changed files with 14 additions and 0 deletions

View File

@ -426,6 +426,13 @@ rb_imemo_mark_and_move(VALUE obj, bool reference_updating)
rb_gc_mark_and_move_ptr(&env->iseq);
if (VM_ENV_LOCAL_P(env->ep) && VM_ENV_BOXED_P(env->ep)) {
const rb_box_t *box = VM_ENV_BOX(env->ep);
if (BOX_USER_P(box)) {
rb_gc_mark_and_move((VALUE *)&box->box_object);
}
}
if (reference_updating) {
((VALUE *)env->ep)[VM_ENV_DATA_INDEX_ENV] = rb_gc_location(env->ep[VM_ENV_DATA_INDEX_ENV]);
}

7
vm.c
View File

@ -3677,6 +3677,13 @@ rb_execution_context_mark(const rb_execution_context_t *ec)
rb_gc_mark_movable((VALUE)cfp->iseq);
rb_gc_mark_movable((VALUE)cfp->block_code);
if (VM_ENV_LOCAL_P(ep) && VM_ENV_BOXED_P(ep)) {
const rb_box_t *box = VM_ENV_BOX(ep);
if (BOX_USER_P(box)) {
rb_gc_mark_movable(box->box_object);
}
}
if (!VM_ENV_LOCAL_P(ep)) {
const VALUE *prev_ep = VM_ENV_PREV_EP(ep);
if (VM_ENV_FLAGS(prev_ep, VM_ENV_FLAG_ESCAPED)) {