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

ruby-changes:52502

From: k0kubun <ko1@a...>
Date: Thu, 13 Sep 2018 15:39:44 +0900 (JST)
Subject: [ruby-changes:52502] k0kubun:r64711 (trunk): vm_insnhelper.h: simplify EXEC_EC_CFP implementation

k0kubun	2018-09-13 15:39:40 +0900 (Thu, 13 Sep 2018)

  New Revision: 64711

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

  Log:
    vm_insnhelper.h: simplify EXEC_EC_CFP implementation
    
    and possibly memory access for iseq->body may be reduced.
    
    No significant impact for performance on Optcarrot.
    
    * before
    fps: 55.03865935187656
    fps: 57.16854675983188
    fps: 57.672458407661765
    fps: 58.28989837869383
    fps: 58.80503815099268
    fps: 59.068054176528534
    fps: 59.55736806358244
    fps: 61.01018920533034
    fps: 63.34167049232186
    fps: 65.20575018321766
    fps: 65.46758316561318
    
    * after
    fps: 55.21860411005677
    fps: 55.34840351179166
    fps: 58.23666596747484
    fps: 59.71987124578901
    fps: 61.131485120234935
    fps: 61.279905164649485
    fps: 61.66060774175459
    fps: 64.11215576508765
    fps: 64.63699742853154
    fps: 65.28260058920769
    fps: 65.85447796482678

  Modified files:
    trunk/mjit.h
    trunk/tool/ruby_vm/views/_mjit_compile_send.erb
    trunk/vm.c
    trunk/vm_insnhelper.h
Index: tool/ruby_vm/views/_mjit_compile_send.erb
===================================================================
--- tool/ruby_vm/views/_mjit_compile_send.erb	(revision 64710)
+++ tool/ruby_vm/views/_mjit_compile_send.erb	(revision 64711)
@@ -60,7 +60,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L60
                 fprintf(f, "            v = vm_exec(ec, TRUE);\n");
             }
             else {
-                fprintf(f, "            if ((v = mjit_exec(ec)) == Qundef) {\n");
+                fprintf(f, "            if ((v = mjit_exec(ec, FALSE)) == Qundef) {\n");
                 fprintf(f, "                VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH);\n"); /* This is vm_call0_body's code after vm_call_iseq_setup */
                 fprintf(f, "                v = vm_exec(ec, FALSE);\n");
                 fprintf(f, "            }\n");
Index: mjit.h
===================================================================
--- mjit.h	(revision 64710)
+++ mjit.h	(revision 64711)
@@ -89,7 +89,7 @@ mjit_target_iseq_p(struct rb_iseq_consta https://github.com/ruby/ruby/blob/trunk/mjit.h#L89
 /* Try to execute the current iseq in ec.  Use JIT code if it is ready.
    If it is not, add ISEQ to the compilation queue and return Qundef.  */
 static inline VALUE
-mjit_exec(rb_execution_context_t *ec)
+mjit_exec(rb_execution_context_t *ec, int guard_except_p)
 {
     const rb_iseq_t *iseq;
     struct rb_iseq_constant_body *body;
@@ -102,6 +102,8 @@ mjit_exec(rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/mjit.h#L102
     iseq = ec->cfp->iseq;
     body = iseq->body;
     total_calls = ++body->total_calls;
+    if (guard_except_p && body->catch_except_p)
+        return Qundef;
 
     func = body->jit_func;
     if (UNLIKELY((uintptr_t)func <= (uintptr_t)LAST_JIT_ISEQ_FUNC)) {
Index: vm_insnhelper.h
===================================================================
--- vm_insnhelper.h	(revision 64710)
+++ vm_insnhelper.h	(revision 64711)
@@ -144,11 +144,7 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L144
    the caller frame may have stack values in the local variables and the cancelling
    the caller frame will purge them. But directly calling mjit_exec is faster... */
 #define EXEC_EC_CFP(val) do { \
-    if (ec->cfp->iseq->body->catch_except_p) { \
-        VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH); \
-        val = vm_exec(ec, TRUE); \
-    } \
-    else if ((val = mjit_exec(ec)) == Qundef) { \
+    if ((val = mjit_exec(ec, TRUE)) == Qundef) { \
         VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH); \
         val = vm_exec(ec, FALSE); \
     } \
@@ -157,7 +153,7 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L153
 /* When calling from VM, longjmp in the callee won't purge any JIT-ed caller frames.
    So it's safe to directly call mjit_exec. */
 #define EXEC_EC_CFP(val) do { \
-    if ((val = mjit_exec(ec)) == Qundef) { \
+    if ((val = mjit_exec(ec, FALSE)) == Qundef) { \
         RESTORE_REGS(); \
         NEXT_INSN(); \
     } \
Index: vm.c
===================================================================
--- vm.c	(revision 64710)
+++ vm.c	(revision 64711)
@@ -1806,7 +1806,7 @@ vm_exec(rb_execution_context_t *ec, int https://github.com/ruby/ruby/blob/trunk/vm.c#L1806
 
     _tag.retval = Qnil;
     if ((state = EC_EXEC_TAG()) == TAG_NONE) {
-        if (!mjit_enable_p || (result = mjit_exec(ec)) == Qundef) {
+        if (!mjit_enable_p || (result = mjit_exec(ec, FALSE)) == Qundef) {
             result = vm_exec_core(ec, initial);
         }
         goto vm_loop_start; /* fallback to the VM */

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

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