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

ruby-changes:52075

From: k0kubun <ko1@a...>
Date: Sat, 11 Aug 2018 14:33:22 +0900 (JST)
Subject: [ruby-changes:52075] k0kubun:r64283 (trunk): _mjit_compile_pc_and_sp.erb: always move pc

k0kubun	2018-08-11 14:33:15 +0900 (Sat, 11 Aug 2018)

  New Revision: 64283

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

  Log:
    _mjit_compile_pc_and_sp.erb: always move pc
    
    to fix the wrong line number on #caller_locations or rb_profile_frames.
    
    Actually we would be able to move it only when method call (of
    caller_locations) or C extension invocation (calling rb_profile_frames)
    can happen.
    
    This degrades performance. Optcarrot fps becomes...
    before: 71.78976052783555
    after: 67.65429356624131
    
    I think I can lazily move it and fix the performance issue, even
    improving the performance for the situation catch table exists.
    But let me fix this bug first...

  Modified files:
    trunk/test/ruby/test_jit.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 64282)
+++ tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb	(revision 64283)
@@ -7,9 +7,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb#L7
 %
 % # JIT: Move pc so that catch table lookup condition is met. If the ISeq might not catch an exception,
 % # the pc motion is optimized away and thus pc should be set properly before `goto cancel`.
-        if (body->catch_except_p) {
-            fprintf(f, "    reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
-        }
+        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: test/ruby/test_jit.rb
===================================================================
--- test/ruby/test_jit.rb	(revision 64282)
+++ test/ruby/test_jit.rb	(revision 64283)
@@ -795,6 +795,25 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L795
     end;
   end
 
+  def test_caller_locations_without_catch_table
+    out, _ = eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 1)
+    begin;
+      def b                             # 2
+        caller_locations.first          # 3
+      end                               # 4
+                                        # 5
+      def a                             # 6
+        print # <-- don't leave PC here # 7
+        b                               # 8
+      end
+      puts a
+      puts a
+    end;
+    lines = out.lines
+    assert_equal("-e:8:in `a'\n", lines[0])
+    assert_equal("-e:8:in `a'\n", lines[1])
+  end
+
   private
 
   # Some tests are stil failing on VC++.

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

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