[ruby-cvs:60084] normal:r52931 (trunk): compile optimized case dispatch for nil/true/false

normal at ruby-lang.org normal at ruby-lang.org
Tue Dec 8 10:46:47 JST 2015


normal	2015-12-08 10:46:45 +0900 (Tue, 08 Dec 2015)

  New Revision: 52931

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52931

  Log:
    compile optimized case dispatch for nil/true/false
    
    nil/true/false are special literals just like floats, integers,
    literal strings, and symbols.  Optimize when statements with
    them by using a jump table, too.
    
    target 0: a (ruby 2.3.0dev (2015-12-08 trunk 52928) [x86_64-linux]) at "/home/ew/rrrr/b/ruby"
    target 1: b (ruby 2.3.0dev (2015-12-08 master 52928) [x86_64-linux]) at "/home/ew/ruby/b/ruby"
    
    benchmark results:
    minimum results in each 5 measurements.
    Execution time (sec)
    name	a	b
    loop_whileloop2	0.102	0.103
    vm2_case_lit*	1.657	0.549
    
    Speedup ratio: compare with the result of `a' (greater is better)
    name	b
    loop_whileloop2	0.988
    vm2_case_lit*	3.017
    
    * benchmark/bm_vm2_case_lit.rb: new benchmark
    * compile.c (case_when_optimizable_literal): add nil/true/false
    * insns.def (opt_case_dispatch): ditto
    * vm.c (vm_redefinition_check_flag): ditto
    * vm.c (vm_init_redefined_flag): ditto
    * vm_core.h: ditto
    * object.c (InitVM_Object): define === explicitly for nil/true/false
    * test/ruby/test_case.rb (test_deoptimize_nil): new test
    * test/ruby/test_optimization.rb (test_opt_case_dispatch): update
      (test_eqq): new test
      [ruby-core:71923] [Feature #11769]
      Original patch by Aaron Patterson <tenderlove at ruby-lang.org>

  Added files:
    trunk/benchmark/bm_vm2_case_lit.rb
  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/insns.def
    trunk/object.c
    trunk/test/ruby/test_case.rb
    trunk/test/ruby/test_optimization.rb
    trunk/vm.c
    trunk/vm_core.h


More information about the ruby-cvs mailing list