From e1e84fbb4f7df57d48fd2b1331edd0d521df7812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Wed, 3 Jun 2020 18:25:13 +0900 Subject: [PATCH] VM_CI_NEW_ID: USE_EMBED_CI could be false It was a wrong idea to assume CIs are always embedded. --- vm_callinfo.h | 14 ++++++++------ vm_insnhelper.c | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/vm_callinfo.h b/vm_callinfo.h index f9ede405b9..03d9e2d2be 100644 --- a/vm_callinfo.h +++ b/vm_callinfo.h @@ -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 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index a9ce512506..15ccf23386 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -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); }