1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

VM_CI_NEW_ID: USE_EMBED_CI could be false

It was a wrong idea to assume CIs are always embedded.
This commit is contained in:
卜部昌平 2020-06-03 18:25:13 +09:00
parent 324038c66e
commit e1e84fbb4f
Notes: git 2020-06-09 09:53:15 +09:00
2 changed files with 24 additions and 12 deletions

View file

@ -187,18 +187,20 @@ vm_ci_dump(const struct rb_callinfo *ci)
((argc) & ~CI_EMBED_ARGC_MASK) ? false : \
(kwarg) ? false : true)
#define vm_ci_new_id(mid, flag, argc, must_zero) \
((const struct rb_callinfo *) \
((((VALUE)(mid )) << CI_EMBED_ID_SHFT) | \
(((VALUE)(flag)) << CI_EMBED_FLAG_SHFT) | \
(((VALUE)(argc)) << CI_EMBED_ARGC_SHFT) | \
RUBY_FIXNUM_FLAG))
static inline const struct rb_callinfo *
vm_ci_new_(ID mid, unsigned int flag, unsigned int argc, const struct rb_callinfo_kwarg *kwarg, const char *file, int line)
{
#if USE_EMBED_CI
if (VM_CI_EMBEDDABLE_P(mid, flag, argc, kwarg)) {
VALUE embed_ci =
RUBY_FIXNUM_FLAG |
((VALUE)argc << CI_EMBED_ARGC_SHFT) |
((VALUE)flag << CI_EMBED_FLAG_SHFT) |
((VALUE)mid << CI_EMBED_ID_SHFT);
RB_DEBUG_COUNTER_INC(ci_packed);
return (const struct rb_callinfo *)embed_ci;
return vm_ci_new_id(mid, flag, argc, kwarg);
}
#endif

View file

@ -1784,19 +1784,22 @@ opt_equality(const rb_iseq_t *cd_owner, VALUE recv, VALUE obj, CALL_DATA cd)
#undef EQ_UNREDEFINED_P
#ifndef MJIT_HEADER
#define VM_CI_NEW_ID(mid) \
((const struct rb_callinfo *)\
((((VALUE)(mid)) << CI_EMBED_ID_SHFT) | RUBY_FIXNUM_FLAG))
VALUE
rb_equal_opt(VALUE obj1, VALUE obj2)
{
STATIC_ASSERT(idEq_is_embeddable, VM_CI_EMBEDDABLE_P(idEq, 0, 1, 0));
#if USE_EMBED_CI
static struct rb_call_data cd = {
.ci = VM_CI_NEW_ID(idEq),
.ci = vm_ci_new_id(idEq, 0, 1, 0),
.cc = &vm_empty_cc,
};
#else
struct rb_call_data cd = {
.ci = &VM_CI_ON_STACK(idEq, 0, 1, 0),
.cc = &vm_empty_cc,
};
#endif
return opt_equality(NULL, obj1, obj2, &cd);
}
@ -1806,10 +1809,17 @@ rb_eql_opt(VALUE obj1, VALUE obj2)
{
STATIC_ASSERT(idEqlP_is_embeddable, VM_CI_EMBEDDABLE_P(idEqlP, 0, 1, 0));
#if USE_EMBED_CI
static struct rb_call_data cd = {
.ci = VM_CI_NEW_ID(idEqlP),
.ci = vm_ci_new_id(idEqlP, 0, 1, 0),
.cc = &vm_empty_cc,
};
#else
struct rb_call_data cd = {
.ci = &VM_CI_ON_STACK(idEqlP, 0, 1, 0),
.cc = &vm_empty_cc,
};
#endif
return opt_equality(NULL, obj1, obj2, &cd);
}