ruby-changes:61619
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 9 Jun 2020 09:53:19 +0900 (JST)
Subject: [ruby-changes:61619] 46728557c1 (master): rb_vm_call0: on-stack call info
https://git.ruby-lang.org/ruby.git/commit/?id=46728557c1 From 46728557c16be2693c81c7c5ca51ea161ef28f65 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: Mon, 1 Jun 2020 16:01:30 +0900 Subject: rb_vm_call0: on-stack call info This changeset reduces the generated binary of rb_vm_call0 from 281 bytes to 211 bytes on my machine. Should reduce GC pressure as well. diff --git a/vm_callinfo.h b/vm_callinfo.h index 7c73194..f9ede40 100644 --- a/vm_callinfo.h +++ b/vm_callinfo.h @@ -251,6 +251,17 @@ vm_ci_markable(const struct rb_callinfo *ci) https://github.com/ruby/ruby/blob/trunk/vm_callinfo.h#L251 } } +#define VM_CI_ON_STACK(mid_, flags_, argc_, kwarg_) \ + (struct rb_callinfo) { \ + .flags = T_IMEMO | \ + (imemo_callinfo << FL_USHIFT) | \ + VM_CALLINFO_NOT_UNDER_GC, \ + .mid = mid_, \ + .flag = flags_, \ + .argc = argc_, \ + .kwarg = kwarg_, \ + } + typedef VALUE (*vm_call_handler)( struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, @@ -290,22 +301,16 @@ vm_cc_new(VALUE klass, https://github.com/ruby/ruby/blob/trunk/vm_callinfo.h#L301 return cc; } -static inline const struct rb_callcache * -vm_cc_fill(struct rb_callcache *cc, - VALUE klass, - const struct rb_callable_method_entry_struct *cme, - vm_call_handler call) -{ - struct rb_callcache cc_body = { - .flags = T_IMEMO | (imemo_callcache << FL_USHIFT) | VM_CALLCACHE_UNMARKABLE, - .klass = klass, - .cme_ = cme, - .call_ = call, - .aux_.v = 0, - }; - MEMCPY(cc, &cc_body, struct rb_callcache, 1); - return cc; -} +#define VM_CC_ON_STACK(clazz, call, aux, cme) \ + (struct rb_callcache) { \ + .flags = T_IMEMO | \ + (imemo_callcache << FL_USHIFT) | \ + VM_CALLCACHE_UNMARKABLE, \ + .klass = clazz, \ + .cme_ = cme, \ + .call_ = call, \ + .aux_ = aux, \ + } static inline bool vm_cc_class_check(const struct rb_callcache *cc, VALUE klass) diff --git a/vm_eval.c b/vm_eval.c index 80b3e90..a03c614 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -45,12 +45,20 @@ static VALUE vm_call0_body(rb_execution_context_t* ec, struct rb_calling_info *c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L45 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 = { Qundef, recv, argc, kw_splat, }; - const struct rb_callinfo *ci = vm_ci_new_runtime(id, kw_splat ? VM_CALL_KW_SPLAT : 0, argc, NULL); - struct rb_callcache cc_body; - const struct rb_callcache *cc = vm_cc_fill(&cc_body, 0, me, vm_call_general); - struct rb_call_data cd = { ci, cc, }; - return vm_call0_body(ec, &calling, &cd, argv); + return vm_call0_body( + ec, + &(struct rb_calling_info) { + .block_handler = VM_BLOCK_HANDLER_NONE, + .recv = recv, + .argc = argc, + .kw_splat = kw_splat, + }, + &(struct rb_call_data) { + .ci = &VM_CI_ON_STACK(id, kw_splat ? VM_CALL_KW_SPLAT : 0, argc, NULL), + .cc = &VM_CC_ON_STACK(Qfalse, vm_call_general, { 0 }, me), + }, + argv + ); } static VALUE diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 93b97f5..6d4afa2 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2682,28 +2682,6 @@ aliased_callable_method_entry(const rb_callable_method_entry_t *me) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2682 return cme; } -#define VM_CI_ON_STACK(mid_, flags_, argc_, kwarg_) \ - (struct rb_callinfo) { \ - .flags = T_IMEMO | \ - (imemo_callinfo << FL_USHIFT) | \ - VM_CALLINFO_NOT_UNDER_GC, \ - .mid = mid_, \ - .flag = flags_, \ - .argc = argc_, \ - .kwarg = kwarg_, \ - } - -#define VM_CC_ON_STACK(clazz, call, aux, cme) \ - (struct rb_callcache) { \ - .flags = T_IMEMO | \ - (imemo_callcache << FL_USHIFT) | \ - VM_CALLCACHE_UNMARKABLE, \ - .klass = clazz, \ - .cme_ = cme, \ - .call_ = call, \ - .aux_ = aux, \ - } - static VALUE vm_call_alias(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/