[ruby-cvs:65599] shyouhei:r58427 (trunk): refactor hash literal

shyouhei at ruby-lang.org shyouhei at ruby-lang.org
Fri Apr 21 13:21:14 JST 2017

shyouhei	2017-04-21 13:21:14 +0900 (Fri, 21 Apr 2017)

  New Revision: 58427


    refactor hash literal
    Same as rb_ary_tmp_new_from_values(), it reduces vm_exec_core binary
    size from 26,176 bytes to 26,080 bytes.  But this time, also with a
    bit of optimizations:
      - Because we are allocating a new hash and no back references are
        introduced at all, we can safely skip write barriers.
      - Also, the iteration never recurs.  We can avoid complicated
        function callbacks by using st_insert instead of st_update.
    * hash.c (rb_hash_new_from_values): refactor
              extract the bulk insert into a function.
    * hash.c (rb_hash_new_from_object): also refactor.
    * hash.c (rb_hash_s_create): use the new functions.
    * insns.def (newhash): ditto.
    * vm.c (core_hash_from_ary): ditto.
    * iternal.h: export the new function.
    benchmark results:
    minimum results in each 7 measurements.
    Execution time (sec)
    name    before  after
    loop_whileloop2  0.135  0.134
    vm2_bighash*     1.236  0.687
    Speedup ratio: compare with the result of `before' (greater is better)
    name    after
    loop_whileloop2 1.008
    vm2_bighash*    1.798

  Modified files:

More information about the ruby-cvs mailing list