ruby-changes:50508
From: k0kubun <ko1@a...>
Date: Sat, 3 Mar 2018 13:50:22 +0900 (JST)
Subject: [ruby-changes:50508] k0kubun:r62643 (trunk): insns.def: unwrap vm_exec for yield
k0kubun 2018-03-03 13:50:14 +0900 (Sat, 03 Mar 2018) New Revision: 62643 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62643 Log: insns.def: unwrap vm_exec for yield Outer vm_exec can catch longjmp. We don't need to call vm_exec first here. This optimizes JIT-ed yield: * Benchmark script ``` require 'benchmark_driver' Benchmark.driver do |x| x.prelude %{ def yielder yield + 1 end } x.report 'yielder', %{ yielder { 1 } } x.loop_count 300_000_000 x.rbenv 'before', 'before,--jit', 'after', 'after,--jit' x.verbose end ``` * Result before: ruby 2.6.0dev (2018-03-03 trunk 62642) [x86_64-linux] before,--jit: ruby 2.6.0dev (2018-03-03 trunk 62642) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-03-03 trunk 62642) [x86_64-linux] last_commit=insns.def: unwrap vm_exec for yield after,--jit: ruby 2.6.0dev (2018-03-03 trunk 62642) +JIT [x86_64-linux] last_commit=insns.def: unwrap vm_exec for yield Calculating ------------------------------------- before before,--jit after after,--jit yielder 37.214M 29.222M 35.904M 38.035M i/s - 300.000M times in 8.061581s 10.266312s 8.355716s 7.887447s Comparison: yielder after,--jit: 38035121.0 i/s before: 37213544.0 i/s - 1.02x slower after: 35903565.7 i/s - 1.06x slower before,--jit: 29221787.6 i/s - 1.30x slower Modified files: trunk/insns.def Index: insns.def =================================================================== --- insns.def (revision 62642) +++ insns.def (revision 62643) @@ -819,8 +819,8 @@ invokeblock https://github.com/ruby/ruby/blob/trunk/insns.def#L819 } val = vm_invoke_block(ec, GET_CFP(), &calling, ci, block_handler); - if (val == Qundef) { - EXEC_EC_CFP(TRUE); + if (val == Qundef && (val = mjit_exec(ec)) == Qundef) { + EXEC_EC_CFP(FALSE); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/