Skip to content

Commit 9bf6549

Browse files
committed
Directly mark once instruction values
1 parent 14d56b1 commit 9bf6549

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

iseq.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ iseq_extract_values(const VALUE *code, size_t pos, iseq_value_itr_t * func, void
159159
}
160160
break;
161161
}
162+
case TS_IC:
163+
if (BIN(once) == insn || BIN(trace_once) == insn) {
164+
union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)code[pos + op_no + 1];
165+
if (is->once.value) {
166+
func(data, is->once.value);
167+
}
168+
}
169+
break;
162170
default:
163171
break;
164172
}
@@ -397,13 +405,6 @@ set_relation(rb_iseq_t *iseq, const rb_iseq_t *piseq)
397405
}
398406
}
399407

400-
void
401-
rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj)
402-
{
403-
/* TODO: check dedup */
404-
rb_ary_push(ISEQ_MARK_ARY(iseq), obj);
405-
}
406-
407408
static VALUE
408409
prepare_iseq_build(rb_iseq_t *iseq,
409410
VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location,

iseq.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
174174
VALUE exception, VALUE body);
175175

176176
/* iseq.c */
177-
void rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj);
178177
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
179178
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
180179
struct st_table *ruby_insn_make_insn_table(void);

vm_insnhelper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,10 +3291,10 @@ vm_once_dispatch(rb_execution_context_t *ec, ISEQ iseq, IC ic)
32913291
else if (is->once.running_thread == NULL) {
32923292
VALUE val;
32933293
is->once.running_thread = th;
3294-
val = is->once.value = rb_ensure(vm_once_exec, (VALUE)iseq, vm_once_clear, (VALUE)is);
3294+
val = rb_ensure(vm_once_exec, (VALUE)iseq, vm_once_clear, (VALUE)is);
3295+
RB_OBJ_WRITE(ec->cfp->iseq, &is->once.value, val);
32953296
/* is->once.running_thread is cleared by vm_once_clear() */
32963297
is->once.running_thread = RUNNING_THREAD_ONCE_DONE; /* success */
3297-
rb_iseq_add_mark_object(ec->cfp->iseq, val);
32983298
return val;
32993299
}
33003300
else if (is->once.running_thread == th) {

0 commit comments

Comments
 (0)