https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2019-09-12T09:43:38Z
Ruby Issue Tracking System
Ruby master - Bug #16161: tailcall_optimization may be disabled after r67315
https://redmine.ruby-lang.org/issues/16161?journal_id=81535
2019-09-12T09:43:38Z
wanabe (_ wanabe)
s.wanabe@gmail.com
<ul></ul><p>How about adding <code>vm_call_iseq_setup_tailcall_opt_start</code> as same as <code>vm_call_iseq_setup_normal_opt_start</code>?<br>
(Copy-and-paste code, sorry!)</p>
<pre><code class="patch syntaxhl" data-language="patch"><span class="gh">diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index a83e3a952a..4abee2fadd 100644
</span><span class="gd">--- a/vm_insnhelper.c
</span><span class="gi">+++ b/vm_insnhelper.c
</span><span class="p">@@ -1825,6 +1825,30 @@</span> vm_call_iseq_setup_normal_opt_start(rb_execution_context_t *ec, rb_control_frame
return vm_call_iseq_setup_normal(ec, cfp, calling, cc->me, opt_pc, param - delta, local);
}
<span class="gi">+static VALUE
+vm_call_iseq_setup_tailcall_opt_start(rb_execution_context_t *ec, rb_control_frame_t *cfp,
+ struct rb_calling_info *calling,
+ const struct rb_call_info *ci, struct rb_call_cache *cc)
+{
+ const rb_iseq_t *iseq = def_iseq_ptr(cc->me->def);
+ const int lead_num = iseq->body->param.lead_num;
+ const int opt = calling->argc - lead_num;
+ const int opt_pc = (int)iseq->body->param.opt_table[opt];
+
+ RB_DEBUG_COUNTER_INC(ccf_iseq_opt);
+
+#if USE_OPT_HIST
+ if (opt_pc < OPT_HIST_MAX) {
+ opt_hist[opt]++;
+ }
+ else {
+ opt_hist[OPT_HIST_MAX]++;
+ }
+#endif
+
+ return vm_call_iseq_setup_tailcall(ec, cfp, calling, ci, cc, opt_pc);
+}
+
</span> static void
args_setup_kw_parameters(rb_execution_context_t *const ec, const rb_iseq_t *const iseq,
VALUE *const passed_values, const int passed_keyword_len, const VALUE *const passed_keywords,
<span class="p">@@ -1909,9 +1933,16 @@</span> vm_callee_setup_arg(rb_execution_context_t *ec, struct rb_calling_info *calling,
argument_arity_error(ec, iseq, argc, lead_num, lead_num + opt_num);
}
<span class="gd">- CC_SET_FASTPATH(cc, vm_call_iseq_setup_normal_opt_start,
- !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
- !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED));
</span><span class="gi">+ if (LIKELY(!(ci->flag & VM_CALL_TAILCALL))) {
+ CC_SET_FASTPATH(cc, vm_call_iseq_setup_normal_opt_start,
+ !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
+ !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED));
+ }
+ else {
+ CC_SET_FASTPATH(cc, vm_call_iseq_setup_tailcall_opt_start,
+ !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
+ !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED));
+ }
</span>
/* initialize opt vars for self-references */
VM_ASSERT((int)iseq->body->param.size == lead_num + opt_num);
</code></pre>
Ruby master - Bug #16161: tailcall_optimization may be disabled after r67315
https://redmine.ruby-lang.org/issues/16161?journal_id=81914
2019-10-06T06:19:13Z
wanabe (_ wanabe)
s.wanabe@gmail.com
<ul><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li></ul>
Ruby master - Bug #16161: tailcall_optimization may be disabled after r67315
https://redmine.ruby-lang.org/issues/16161?journal_id=81916
2019-10-06T07:00:47Z
wanabe (_ wanabe)
s.wanabe@gmail.com
<ul></ul><p>I created Pull-Request <a href="https://github.com/ruby/ruby/pull/2528" class="external">https://github.com/ruby/ruby/pull/2528</a></p>
Ruby master - Bug #16161: tailcall_optimization may be disabled after r67315
https://redmine.ruby-lang.org/issues/16161?journal_id=81918
2019-10-06T09:20:36Z
wanabe (_ wanabe)
s.wanabe@gmail.com
<ul></ul><p>Oh I've pushed wrong commit on <a href="https://github.com/ruby/ruby/pull/2528" class="external">https://github.com/ruby/ruby/pull/2528</a> .<br>
I retry to push my working branch on <a href="https://github.com/ruby/ruby/pull/2529" class="external">https://github.com/ruby/ruby/pull/2529</a> .<br>
Sorry!</p>
Ruby master - Bug #16161: tailcall_optimization may be disabled after r67315
https://redmine.ruby-lang.org/issues/16161?journal_id=82312
2019-10-25T02:10:01Z
wanabe (_ wanabe)
s.wanabe@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Thank you to merge <a href="https://github.com/ruby/ruby/pull/2529" class="external">https://github.com/ruby/ruby/pull/2529</a> on 4ff2c58f919153b9a47f69f855a0b9d2bb0e0bbe.<br>
I confirmed this issue is fixed now.</p>
<pre><code>$ ./miniruby -v -e 'iseq = RubyVM::InstructionSequence.compile("def foo(n, s = 0);return s if n < 1;foo(n - 1, n + s); end", tailcall_optimization: true); iseq.eval; p foo(900_000)'
ruby 2.7.0dev (2019-10-25T01:45:46Z master a7ec88ad61) [x86_64-linux]
405000450000
</code></pre>
Ruby master - Bug #16161: tailcall_optimization may be disabled after r67315
https://redmine.ruby-lang.org/issues/16161?journal_id=82314
2019-10-25T05:13:52Z
wanabe (_ wanabe)
s.wanabe@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.5: UNKNOWN, 2.6: UNKNOWN</i> to <i>2.5: DONTNEED, 2.6: DONTNEED</i></li></ul>