From fc2764e58c0265e5ba71909b9ed771ec381fa872 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Sat, 3 Mar 2018 04:50:14 +0000 Subject: [PATCH] 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- insns.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/insns.def b/insns.def index 3b65942e5a..3fdfbdfa04 100644 --- a/insns.def +++ b/insns.def @@ -819,8 +819,8 @@ invokeblock } 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); } }