[前][次][番号順一覧][スレッド一覧]

ruby-changes:52474

From: k0kubun <ko1@a...>
Date: Tue, 11 Sep 2018 21:53:56 +0900 (JST)
Subject: [ruby-changes:52474] k0kubun:r64683 (trunk): _mjit_compile_pc_and_sp.erb: skip moving pc

k0kubun	2018-09-11 21:53:52 +0900 (Tue, 11 Sep 2018)

  New Revision: 64683

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

  Log:
    _mjit_compile_pc_and_sp.erb: skip moving pc
    
    when catch_except_p is false and insn.always_leaf? is true (never makes
    arbitrary method call in the insn).
    
    On Optcarrot, unfortunately this didn't have measureable performance impact.
    But still this is a good direction since it becomes much faster when
    marking all insns as always leaf.
    
    bare_instructions.rb: add `#always_leaf?` that indicates the insn can
    always be considered as leaf. Using dynamic leaf for JIT would be hard
    since it requires to discard outdated code somehow.

  Modified files:
    trunk/tool/ruby_vm/models/bare_instructions.rb
    trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
Index: tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
===================================================================
--- tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb	(revision 64682)
+++ tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb	(revision 64683)
@@ -5,8 +5,10 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb#L5
 % # conditions mentioned  in the  file COPYING  are met.   Consult the  file for
 % # details.
 %
-% # JIT: Move pc so that catch table lookup condition is met, and for #caller_locations and rb_profile_frames.
-        fprintf(f, "    reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
+% # JIT: Move pc for catch table on catch_except_p, and for #caller_locations and rb_profile_frames on !insn.always_leaf?
+        if (body->catch_except_p || <%= insn.always_leaf? ? 'FALSE' : 'TRUE' %>) {
+            fprintf(f, "    reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
+        }
 %
 % # JIT: move sp to use or preserve stack variables
         if (status->local_stack_p) {
Index: tool/ruby_vm/models/bare_instructions.rb
===================================================================
--- tool/ruby_vm/models/bare_instructions.rb	(revision 64682)
+++ tool/ruby_vm/models/bare_instructions.rb	(revision 64683)
@@ -105,6 +105,10 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/bare_instructions.rb#L105
     /\b(false|0)\b/ !~ @attrs['handles_sp'].expr.expr
   end
 
+  def always_leaf?
+    @attrs['leaf'].expr.expr == 'true;'
+  end
+
   def complicated_return_values?
     @sig[:ret].any? {|i| i == '...' }
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]