Skip to content

Commit e72aa01

Browse files
tenderloveKaanOzkan
authored andcommitted
reuse cc
1 parent e283b9b commit e72aa01

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

vm_insnhelper.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5281,7 +5281,6 @@ vm_invoke_iseq_block_cc(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
52815281
const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq);
52825282
const int arg_size = ISEQ_BODY(iseq)->param.size;
52835283
VALUE * const rsp = GET_SP() - calling->argc;
5284-
VALUE * const argv = rsp;
52855284

52865285
SET_SP(rsp);
52875286

@@ -6010,11 +6009,21 @@ vm_invokeblock_fastpath(struct rb_execution_context_struct *ec,
60106009
if (!ISEQ_BODY(iseq)->block_ccs) {
60116010
ISEQ_BODY(iseq)->block_ccs = ZALLOC(struct rb_class_cc_entries);
60126011
}
6012+
6013+
struct rb_class_cc_entries * ccs = ISEQ_BODY(iseq)->block_ccs;
6014+
unsigned int argc = vm_ci_argc(ci);
6015+
unsigned int flag = vm_ci_flag(ci);
6016+
6017+
for (int i = 0; i < ccs->len; i++) {
6018+
if (ccs->entries[i].argc == argc && ccs->entries[i].flag == flag) {
6019+
return ccs->entries[i].cc;
6020+
}
6021+
}
60136022
ret = vm_cc_new((VALUE)iseq, NULL, vm_invoke_iseq_block_cc, cc_type_block);
6014-
//ret = vm_cc_new((VALUE)iseq, NULL, vm_invokeblock_i, cc_type_block);
60156023
vm_ccs_push((VALUE)iseq, ISEQ_BODY(iseq)->block_ccs, ci, ret);
60166024
cd->cc = ret;
6017-
RUBY_ASSERT(ret->klass == iseq);
6025+
// TODO: write barrier
6026+
RUBY_ASSERT(ret->klass == (VALUE)iseq);
60186027
}
60196028
}
60206029
}

0 commit comments

Comments
 (0)