This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: How do i debug --no-inline or --full-tailcalls options?
- From: Per Bothner <per at bothner dot com>
- To: OKUMURA Yuki <mjt at cltn dot org>, kawa at sourceware dot org
- Date: Fri, 12 Feb 2016 13:53:47 -0800
- Subject: Re: How do i debug --no-inline or --full-tailcalls options?
- Authentication-results: sourceware.org; auth=none
- References: <CAG1-Us1p_d+WdW6JRXyXYjafrmUBO1+1+2xAW4FSQjmepzMjGQ at mail dot gmail dot com> <56BC9451 dot 30002 at bothner dot com> <CAG1-Us2AMj5s_TwMmeh5-9y8RA9P+iPYVUmM88y7yroPAH0T2w at mail dot gmail dot com>
On 02/11/2016 10:26 AM, OKUMURA Yuki wrote:
I don't fully understand what is happening on that issue yet;
with --full-tailcalls and without --no-inline,
Kawa seems to skip some procedures when its result is not
consumed at all. (ie. every skipped procedures were wrapper around SET!)
This was a bug in the code generation. When you compile with --full-tailcalls,
a function call is split into two parts:
(1) The first part pushes the arguments and a reference to the function
into the per-thread CallContext.
(2) The actual body of the function is a separate method that is executed by the
"trampoline loop" in CallContext.
If the call is a tail-call, then the caller returns after doing (1), and the trampoline
loop is done by caller's caller (and so on if the caller's call is also a tail-call).
The problem when the call is *not* a tail-call. In that case, the
caller must make sure the trampoline loop is called so we get the
function's result (or in this case side effects). This was not happening
in your test-case.
I suspect this behaviour is backend's problem since when I merged
explicit libraries into a module, problem would just disappear.
The define-library affects the code generation because it affects
what functions are exported and how things are inlined.
I checked in a fix, along with a simplified version of your testcase. Thanks!
--
--Per Bothner
per@bothner.com http://per.bothner.com/