Fix comment for VM_CALL_ARGS_SIMPLE (#11067)

* Set VM_CALL_KWARG flag first and reuse it to avoid checking kw_arg twice

* Fix comment for VM_CALL_ARGS_SIMPLE

* Make VM_CALL_ARGS_SIMPLE set-site match its comment
This commit is contained in:
Gabriel Lacroix 2024-06-28 10:11:35 -04:00 коммит произвёл GitHub
Родитель 5c826ebea5
Коммит 1652c194c8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -1439,16 +1439,16 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, unsigned int flag, struct rb_cal
{ {
VM_ASSERT(argc >= 0); VM_ASSERT(argc >= 0);
if (!(flag & (VM_CALL_ARGS_SPLAT | VM_CALL_ARGS_BLOCKARG | VM_CALL_KW_SPLAT | VM_CALL_FORWARDING)) &&
kw_arg == NULL && !has_blockiseq) {
flag |= VM_CALL_ARGS_SIMPLE;
}
if (kw_arg) { if (kw_arg) {
flag |= VM_CALL_KWARG; flag |= VM_CALL_KWARG;
argc += kw_arg->keyword_len; argc += kw_arg->keyword_len;
} }
if (!(flag & (VM_CALL_ARGS_SPLAT | VM_CALL_ARGS_BLOCKARG | VM_CALL_KWARG | VM_CALL_KW_SPLAT | VM_CALL_FORWARDING))
&& !has_blockiseq) {
flag |= VM_CALL_ARGS_SIMPLE;
}
ISEQ_BODY(iseq)->ci_size++; ISEQ_BODY(iseq)->ci_size++;
const struct rb_callinfo *ci = vm_ci_new(mid, flag, argc, kw_arg); const struct rb_callinfo *ci = vm_ci_new(mid, flag, argc, kw_arg);
RB_OBJ_WRITTEN(iseq, Qundef, ci); RB_OBJ_WRITTEN(iseq, Qundef, ci);

Просмотреть файл

@ -17,7 +17,7 @@ enum vm_call_flag_bits {
VM_CALL_ARGS_BLOCKARG_bit, // m(&block) VM_CALL_ARGS_BLOCKARG_bit, // m(&block)
VM_CALL_FCALL_bit, // m(args) # receiver is self VM_CALL_FCALL_bit, // m(args) # receiver is self
VM_CALL_VCALL_bit, // m # method call that looks like a local variable VM_CALL_VCALL_bit, // m # method call that looks like a local variable
VM_CALL_ARGS_SIMPLE_bit, // (ci->flag & (SPLAT|BLOCKARG)) && blockiseq == NULL && ci->kw_arg == NULL VM_CALL_ARGS_SIMPLE_bit, // !(ci->flag & (SPLAT|BLOCKARG|KWARG|KW_SPLAT|FORWARDING)) && !has_block_iseq
VM_CALL_KWARG_bit, // has kwarg VM_CALL_KWARG_bit, // has kwarg
VM_CALL_KW_SPLAT_bit, // m(**opts) VM_CALL_KW_SPLAT_bit, // m(**opts)
VM_CALL_TAILCALL_bit, // located at tail position VM_CALL_TAILCALL_bit, // located at tail position