ruby-changes:42664
From: naruse <ko1@a...>
Date: Sun, 24 Apr 2016 06:34:07 +0900 (JST)
Subject: [ruby-changes:42664] naruse:r54738 (trunk): * vm_insnhelper.c (INLINE): define as `inline` when it is optimized.
naruse 2016-04-24 07:30:42 +0900 (Sun, 24 Apr 2016) New Revision: 54738 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54738 Log: * vm_insnhelper.c (INLINE): define as `inline` when it is optimized. define as `static inline` when it is not optimized to keep the symbol generated. * vm_insnhelper.c (vm_getivar): use `INLINE` to force inline so that a compiler inlines it into vm_getinstancevariable and optimizes out is_attr and related branches. * vm_insnhelper.c (vm_getivar): use `inline` to recommend inline. Without this vm1_ivar_set is degraded. benchmark results: minimum results in each 5 measurements. Execution time (sec) name ruby 2.4.0dev (2016-04-23 trunk 54727) [x86_64-linux] ruby 2.4.0dev (2016-04-23 trunk 54733) [x86_64-linux] built-ruby loop_whileloop 0.641 0.642 0.646 vm1_ivar* 1.002 0.999 0.831 vm1_ivar_set* 0.369 1.106 0.362 Speedup ratio: compare with the result of `ruby 2.4.0dev (2016-04-23 trunk 54727) [x86_64-linux]' (greater is better) name ruby 2.4.0dev (2016-04-23 trunk 54733) [x86_64-linux] built-ruby loop_whileloop 0.998 0.991 vm1_ivar* 1.003 1.205 vm1_ivar_set* 0.334 1.018 Modified files: trunk/ChangeLog trunk/vm_insnhelper.c Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 54737) +++ vm_insnhelper.c (revision 54738) @@ -18,8 +18,11 @@ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L18 /* control stack frame */ -#ifndef INLINE +#undef INLINE +#ifdef __OPTIMIZE__ #define INLINE inline +#else +#define INLINE static inline #endif static rb_control_frame_t *vm_get_ruby_level_caller_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp); @@ -774,7 +777,7 @@ vm_search_const_defined_class(const VALU https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L777 #define USE_IC_FOR_IVAR 1 #endif -static VALUE +INLINE VALUE vm_getivar(VALUE obj, ID id, IC ic, struct rb_call_cache *cc, int is_attr) { #if USE_IC_FOR_IVAR @@ -824,7 +827,7 @@ vm_getivar(VALUE obj, ID id, IC ic, stru https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L827 return rb_ivar_get(obj, id); } -static VALUE +static inline VALUE vm_setivar(VALUE obj, ID id, VALUE val, IC ic, struct rb_call_cache *cc, int is_attr) { #if USE_IC_FOR_IVAR Index: ChangeLog =================================================================== --- ChangeLog (revision 54737) +++ ChangeLog (revision 54738) @@ -1,3 +1,35 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Apr 24 04:21:27 2016 NARUSE, Yui <naruse@r...> + + * vm_insnhelper.c (INLINE): define as `inline` when it is optimized. + define as `static inline` when it is not optimized to keep + the symbol generated. + + * vm_insnhelper.c (vm_getivar): use `INLINE` to force inline + so that a compiler inlines it into vm_getinstancevariable + and optimizes out is_attr and related branches. + + * vm_insnhelper.c (vm_getivar): use `inline` to recommend inline. + Without this vm1_ivar_set is degraded. + + benchmark results: + minimum results in each 5 measurements. + Execution time (sec) + name ruby 2.4.0dev (2016-04-23 trunk 54727) [x86_64-linux] ruby 2.4.0dev (2016-04-23 trunk 54733) [x86_64-linux] built-ruby + loop_whileloop 0.641 0.642 0.646 + vm1_ivar* 1.002 0.999 0.831 + vm1_ivar_set* 0.369 1.106 0.362 + + Speedup ratio: compare with the result of `ruby 2.4.0dev (2016-04-23 + trunk 54727) [x86_64-linux]' (greater is better) + name ruby 2.4.0dev (2016-04-23 trunk 54733) [x86_64-linux] + built-ruby + loop_whileloop + 0.998 0.991 + vm1_ivar* + 1.003 1.205 + vm1_ivar_set* + 0.334 1.018 + Sat Apr 23 18:01:21 2016 NARUSE, Yui <naruse@r...> * vm_insnhelper.c (vm_getivar): specify inline instead of static inline. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/