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

ruby-changes:50992

From: k0kubun <ko1@a...>
Date: Fri, 20 Apr 2018 01:58:04 +0900 (JST)
Subject: [ruby-changes:50992] k0kubun:r63199 (trunk): _mjit_compile_send.erb: simplify control flow

k0kubun	2018-04-20 01:57:59 +0900 (Fri, 20 Apr 2018)

  New Revision: 63199

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

  Log:
    _mjit_compile_send.erb: simplify control flow
    
    to introduce additional optimization for another `cc->me->def->type`
    later. I carved out the `cc->me->def->type == VM_METHOD_TYPE_ISEQ`
    part because I wanted to check other types as well.
    
    mjit_compile.c: drop get_iseq_if_available and define simplified version
    of it, has_valid_method_type.

  Modified files:
    trunk/mjit_compile.c
    trunk/tool/ruby_vm/views/_mjit_compile_send.erb
Index: mjit_compile.c
===================================================================
--- mjit_compile.c	(revision 63198)
+++ mjit_compile.c	(revision 63199)
@@ -39,16 +39,12 @@ struct case_dispatch_var { https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L39
     VALUE last_value;
 };
 
-/* Returns iseq from cc if it's available and still not obsoleted. */
-static const rb_iseq_t *
-get_iseq_if_available(CALL_CACHE cc)
+/* Returns TRUE if call cache is still not obsoleted and cc->me->def->type is available. */
+static int
+has_valid_method_type(CALL_CACHE cc)
 {
-    if (GET_GLOBAL_METHOD_STATE() == cc->method_state
-        && mjit_valid_class_serial_p(cc->class_serial)
-        && cc->me && cc->me->def->type == VM_METHOD_TYPE_ISEQ) {
-        return rb_iseq_check(cc->me->def->body.iseq.iseqptr);
-    }
-    return NULL;
+    return GET_GLOBAL_METHOD_STATE() == cc->method_state
+        && mjit_valid_class_serial_p(cc->class_serial) && cc->me;
 }
 
 /* Returns TRUE if iseq is inlinable, otherwise NULL. This becomes TRUE in the same condition
Index: tool/ruby_vm/views/_mjit_compile_send.erb
===================================================================
--- tool/ruby_vm/views/_mjit_compile_send.erb	(revision 63198)
+++ tool/ruby_vm/views/_mjit_compile_send.erb	(revision 63199)
@@ -7,19 +7,20 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L7
 % # details.
 %
 % # Optimized case of send / opt_send_without_block instructions.
-    {
+{
 % # compiler: Prepare operands which may be used by `insn.call_attribute`
 % insn.opes.each_with_index do |ope, i|
-        MAYBE_UNUSED(<%= ope.fetch(:decl) %>) = (<%= ope.fetch(:type) %>)operands[<%= i %>];
+    MAYBE_UNUSED(<%= ope.fetch(:decl) %>) = (<%= ope.fetch(:type) %>)operands[<%= i %>];
 % end
 %
+    if (has_valid_method_type(cc)) {
         const rb_iseq_t *iseq;
         unsigned int argc = ci->orig_argc; /* unlike `ci->orig_argc`, `argc` may include blockarg */
 % if insn.name == 'send'
         argc += ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0);
 % end
 
-        if (inlinable_iseq_p(ci, cc, iseq = get_iseq_if_available(cc))) {
+        if (cc->me->def->type == VM_METHOD_TYPE_ISEQ && inlinable_iseq_p(ci, cc, iseq = rb_iseq_check(cc->me->def->body.iseq.iseqptr))) {
             int param_size = iseq->body->param.size; /* TODO: check calling->argc for argument_arity_error */
 
             fprintf(f, "{\n");
@@ -88,3 +89,4 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L89
             break;
         }
     }
+}

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

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