diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-23 22:30:42 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-23 22:30:42 +0000 |
commit | 65a1cdafc83bc5e06130081589a444ae4c93f57a (patch) | |
tree | 9ead3e21c5d4fd7f36138aae78ecaf2726ce3aa5 /vm_insnhelper.c | |
parent | 9afc312b4fef21da91fde083f85533ffd5a9d95f (diff) | |
download | ruby-65a1cdafc83bc5e06130081589a444ae4c93f57a.tar.gz |
* 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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index b6059a4554..4ca09580bc 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -18,8 +18,11 @@ /* 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 VALUE cbase, ID id) #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, struct rb_call_cache *cc, int is_attr) 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 |