Skip to content

Commit cb756da

Browse files
committed
Avoid unnecessary writes to imemo_env during GC
Similar to the previous commit, to avoid unnecessary Copy-on-Write memory use we should only set this flag when it has not previously been set.
1 parent 1a6b13d commit cb756da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7228,7 +7228,9 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
72287228
GC_ASSERT(env->ep[VM_ENV_DATA_INDEX_ENV] == obj);
72297229
GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
72307230
rb_gc_mark_values((long)env->env_size, env->env);
7231-
VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
7231+
if (!VM_ENV_FLAGS(env->ep, VM_ENV_FLAG_WB_REQUIRED)) {
7232+
VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
7233+
}
72327234
gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
72337235
gc_mark(objspace, (VALUE)env->iseq);
72347236
}

0 commit comments

Comments
 (0)