[ruby-cvs:65562] shyouhei:r58390 (trunk): split insns.def into functions

shyouhei at ruby-lang.org shyouhei at ruby-lang.org
Tue Apr 18 19:58:49 JST 2017

shyouhei	2017-04-18 19:58:49 +0900 (Tue, 18 Apr 2017)

  New Revision: 58390


    split insns.def into functions
    Contemporary C compilers are good at function inlining.  They fold
    multiple functions into one.  However they are not yet smart enough to
    unfold a function into several ones.  So generally speaking, it is
    wiser for a C programmer to manually split C functions whenever
    possible.  That should make rooms for compilers to optimize at will.
    Before this changeset insns.def was converted into single HUGE
    function called vm_exec_core().  By moving each instruction's core
    into individual functions, generated C source code is reduced from
    3,428 lines to 2,847 lines.  Looking at the generated assembly
    however, it seems my compiler (gcc 6.2) is extraordinary smart so that
    it inlines almost all functions I introduced in this changeset back
    into that vm_exec_core.  On my machine compiled machine binary of the
    function does not shrink very much in size (28,432 bytes to 26,816
    bytes, according to nm(1)).
    I believe this change is zero-cost.  Several benchmarks I exercised
    showed no significant difference beyond error mergin.  For instance
    3 repeated runs of optcarrot benchmark on my machine resulted in:
       before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
       after  this: 27.107195867280414, 25.549324021385907, 30.31581919050884
    in fps (greater==faster).
    * internal.h (rb_obj_not_equal): used from vm_insnhelper.c
    * insns.def: move vast majority of lines into vm_insnhelper.c
    * vm_insnhelper.c: moved here.

  Modified files:

More information about the ruby-cvs mailing list