ruby-changes:58435
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 25 Oct 2019 12:50:40 +0900 (JST)
Subject: [ruby-changes:58435] 356e203a3a (master): more on struct rb_call_data
https://git.ruby-lang.org/ruby.git/commit/?id=356e203a3a From 356e203a3acd4d3d20ba12f956fd22e17b6363e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 24 Oct 2019 18:08:52 +0900 Subject: more on struct rb_call_data Replacing adjacent struct rb_call_info and struct rb_call_cache into a struct rb_call_data. diff --git a/internal.h b/internal.h index 6d63bcf..53091e2 100644 --- a/internal.h +++ b/internal.h @@ -2356,7 +2356,7 @@ struct rb_method_definition_struct; https://github.com/ruby/ruby/blob/trunk/internal.h#L2356 struct rb_execution_context_struct; struct rb_control_frame_struct; struct rb_calling_info; -struct rb_call_info; +struct rb_call_data; struct rb_call_cache { /* inline cache: keys */ rb_serial_t method_state; @@ -2369,8 +2369,7 @@ struct rb_call_cache { https://github.com/ruby/ruby/blob/trunk/internal.h#L2369 VALUE (*call)(struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, - const struct rb_call_info *ci, - struct rb_call_cache *cc); + struct rb_call_data *cd); union { unsigned int index; /* used by ivar */ @@ -2378,19 +2377,23 @@ struct rb_call_cache { https://github.com/ruby/ruby/blob/trunk/internal.h#L2377 int inc_sp; /* used by cfunc */ } aux; }; -struct rb_call_cache_and_mid { - struct rb_call_cache cc; +struct rb_call_info { + /* fixed at compile time */ ID mid; + unsigned int flag; + int orig_argc; +}; +struct rb_call_data { + struct rb_call_cache cc; + struct rb_call_info ci; }; -VALUE rb_funcallv_with_cc(struct rb_call_cache_and_mid*, VALUE, ID, int, const VALUE*) +VALUE rb_funcallv_with_cc(struct rb_call_data*, VALUE, ID, int, const VALUE*) #if GCC_VERSION_SINCE(3, 3, 0) && defined(__OPTIMIZE__) __attribute__((__visibility__("default"), __nonnull__(1))) # define rb_funcallv(recv, mid, argc, argv) \ __extension__({ \ - static struct rb_call_cache_and_mid \ - rb_funcallv_opaque_cc = { {0, }, 0, }; \ - rb_funcallv_with_cc(&rb_funcallv_opaque_cc, \ - recv, mid, argc,argv); \ + static struct rb_call_data rb_funcallv_data = { { 0, }, { 0, }, }; \ + rb_funcallv_with_cc(&rb_funcallv_data, recv, mid, argc, argv); \ }) #endif ; diff --git a/tool/mk_call_iseq_optimized.rb b/tool/mk_call_iseq_optimized.rb index 9fd84aa..eba4453 100644 --- a/tool/mk_call_iseq_optimized.rb +++ b/tool/mk_call_iseq_optimized.rb @@ -21,10 +21,10 @@ P.each{|param| https://github.com/ruby/ruby/blob/trunk/tool/mk_call_iseq_optimized.rb#L21 L.each{|local| puts <<EOS static VALUE -#{fname(param, local)}(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc) +#{fname(param, local)}(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd) { RB_DEBUG_COUNTER_INC(ccf_iseq_fix); - return vm_call_iseq_setup_normal(ec, cfp, calling, cc->me, 0, #{param}, #{local}); + return vm_call_iseq_setup_normal(ec, cfp, calling, cd->cc.me, 0, #{param}, #{local}); } EOS @@ -61,7 +61,7 @@ vm_call_iseq_setup_func(const struct rb_call_info *ci, const int param_size, con https://github.com/ruby/ruby/blob/trunk/tool/mk_call_iseq_optimized.rb#L61 static inline vm_call_handler -vm_call_iseq_setup_func(const struct rb_call_info *ci, struct rb_call_cache *cc) +vm_call_iseq_setup_func(const struct rb_call_info *ci, const int param_size, const int local_size) { if (UNLIKELY(ci->flag & VM_CALL_TAILCALL)) { return &vm_call_iseq_setup_tailcall_0start; diff --git a/vm_core.h b/vm_core.h index 5c8c91b..53d4217 100644 --- a/vm_core.h +++ b/vm_core.h @@ -234,13 +234,6 @@ union iseq_inline_storage_entry { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L234 struct iseq_inline_cache_entry cache; }; -struct rb_call_info { - /* fixed at compile time */ - ID mid; - unsigned int flag; - int orig_argc; -}; - struct rb_call_info_kw_arg { int keyword_len; VALUE keywords[1]; @@ -258,18 +251,13 @@ struct rb_calling_info { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L251 int kw_splat; }; -struct rb_call_data { - struct rb_call_cache cc; - struct rb_call_info ci; -}; - struct rb_kwarg_call_data { struct rb_call_cache cc; struct rb_call_info_with_kwarg ci_kw; }; struct rb_execution_context_struct; -typedef VALUE (*vm_call_handler)(struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc); +typedef VALUE (*vm_call_handler)(struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, struct rb_call_data *cd); #if 1 #define CoreDataFromValue(obj, type) (type*)DATA_PTR(obj) diff --git a/vm_eval.c b/vm_eval.c index 797338a..bad5170 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -38,34 +38,28 @@ typedef enum call_type { https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L38 } call_type; static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope); -static VALUE vm_call0_body(rb_execution_context_t* ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv); +static VALUE vm_call0_body(rb_execution_context_t* ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv); #ifndef MJIT_HEADER MJIT_FUNC_EXPORTED VALUE rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat) { - struct rb_calling_info calling_entry, *calling; - struct rb_call_info ci_entry; - struct rb_call_cache cc_entry; - - calling = &calling_entry; - - ci_entry.flag = kw_splat ? VM_CALL_KW_SPLAT : 0; - ci_entry.mid = id; - - cc_entry.me = me; - - calling->recv = recv; - calling->argc = argc; - calling->kw_splat = kw_splat; - - return vm_call0_body(ec, calling, &ci_entry, &cc_entry, argv); + return vm_call0_body( + ec, + &(struct rb_calling_info) { + Qundef, recv, argc, kw_splat, }, + &(struct rb_call_data) { + { 0, 0, me, me->def, vm_call_general, { 0, }, }, + { id, (kw_splat ? VM_CALL_KW_SPLAT : 0), argc, }, }, + argv); } static VALUE -vm_call0_cfunc_with_frame(rb_execution_context_t* ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv) +vm_call0_cfunc_with_frame(rb_execution_context_t* ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv) { + const struct rb_call_info *ci = &cd->ci; + const struct rb_call_cache *cc = &cd->cc; VALUE val; const rb_callable_method_entry_t *me = cc->me; const rb_method_cfunc_t *cfunc = UNALIGNED_MEMBER_PTR(me->def, body.cfunc); @@ -109,15 +103,18 @@ vm_call0_cfunc_with_frame(rb_execution_context_t* ec, struct rb_calling_info *ca https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L103 } static VALUE -vm_call0_cfunc(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv) +vm_call0_cfunc(rb_execution_context_t *ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv) { - return vm_call0_cfunc_with_frame(ec, calling, ci, cc, argv); + return vm_call0_cfunc_with_frame(ec, calling, cd, argv); } /* `ci' should point temporal value (on stack value) */ static VALUE -vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv) +vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv) { + const struct rb_call_info *ci = &cd->ci; + struct rb_call_cache *cc = &cd->cc; + VALUE ret; calling->block_handler = vm_passed_block_handler(ec); @@ -137,13 +134,13 @@ vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, const https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L134 *reg_cfp->sp++ = argv[i]; } - vm_call_iseq_setup(ec, reg_cfp, calling, ci, cc); + vm_call_iseq_setup(ec, reg_cfp, calling, cd); VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH); return vm_exec(ec, TRUE); /* CHECK_INTS in this function */ } case VM_METHOD_TYPE_NOTIMPLEMENTED: case VM_METHOD_TYPE_CFUNC: - ret = vm_call0_cfunc(ec, calling, ci, cc, argv); + ret = vm_call0_cfunc(ec, calling, cd, argv); goto success; case VM_METHOD_TYPE_ATTRSET: if (calling->kw_splat && @@ -173,7 +170,7 @@ vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, const https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L170 ret = rb_attr_get(calling->recv, cc->me->def->body.attr.id); goto success; case VM_METHOD_TYPE_BMETHOD: - ret = vm_call_bmethod_body(ec, calling, ci, cc, argv); + ret = vm_call_bmethod_body(ec, calling, cd, argv); goto success; case VM_METHOD_TYPE_ZSUPER: case VM_METHOD_TYPE_REFINED: @@ -1001,20 +998,22 @@ rb_funcallv_public_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_sp https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L998 /*! * Calls a method * \private - * \param cc opaque call cache + * \param cd opaque call data * \param recv receiver of the method * \param mid an ID that represents the name of the method * \param argc the number of arguments * \param argv pointer to an array of method arguments */ VALUE -rb_funcallv_with_cc(struct rb_call_cache_and_mid *cc, VALUE recv, ID mid, int argc, const VALUE *argv) +rb_funcallv_with_cc(struct rb_call_data *cd, VALUE re (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/