public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: OKUMURA Yuki <mjt@cltn.org>, kawa@sourceware.org
Subject: Re: How do i debug --no-inline or --full-tailcalls options?
Date: Fri, 12 Feb 2016 21:53:00 -0000	[thread overview]
Message-ID: <56BE546B.7050207@bothner.com> (raw)
In-Reply-To: <CAG1-Us2AMj5s_TwMmeh5-9y8RA9P+iPYVUmM88y7yroPAH0T2w@mail.gmail.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/

  reply	other threads:[~2016-02-12 21:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11  8:51 OKUMURA Yuki
2016-02-11 14:02 ` Per Bothner
2016-02-11 18:26   ` OKUMURA Yuki
2016-02-12 21:53     ` Per Bothner [this message]
2016-02-12  1:26 ` Per Bothner
2016-02-12  7:25   ` Per Bothner
2016-02-12 17:33     ` OKUMURA Yuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56BE546B.7050207@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    --cc=mjt@cltn.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).