From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: wip-rtl return location
Date: Thu, 02 Aug 2012 22:29:03 -0400 [thread overview]
Message-ID: <501B376F.3060505@netris.org> (raw)
In-Reply-To: <87mx2dv02q.fsf@pobox.com>
Hi Andy, thanks for the update! Exciting times for Guile :)
On 08/02/2012 10:29 AM, Andy Wingo wrote:
> Instead I'd rather just use Dybvig's suggestion: every call instruction
> is preceded by an MV return address. For e.g. (values (f)), calling `f'
> would be:
>
> ...
> goto CALL
> MVRA:
> truncate-and-jump RA
> CALL:
> call f
> RA:
> return
>
> So the overhead of multiple values in the normal single-value case is
> one jump per call. When we do native compilation, this cost will be
> negligible. OTOH for MV returns, we return to a different address than
> the one on the stack, which will cause a branch misprediction (google
> "return stack buffers" for more info).
I wonder if it might be better to avoid this branch misprediction by
always returning to the same address. Upon return, a special register
would contain N-1, where N is the number of return values. The first
few return values would also be stored in registers (hopefully at least
two), and if necessary the remaining values would be stored elsewhere,
perhaps on the stack or in a list or vector pointed to by another register.
In the common case where a given call site expects a small constant
number of return values, the compiler could emit a statically-predicted
conditional branch to verify that N-1 is the expected value (usually
zero), and then generate code that expects to find the return values in
the appropriate registers.
On some architectures, it might also make sense for the callee to set
the processor's "zero?" condition code as if N-1 had been tested, to
allow for a shorter check in the common single-value case.
Of course, the calling convention can be chosen independently for each
instruction set architecture / ABI.
What do you think?
Mark
next prev parent reply other threads:[~2012-08-03 2:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 14:29 wip-rtl return location Andy Wingo
2012-08-02 22:21 ` Noah Lavine
2012-08-03 8:06 ` Andy Wingo
2012-08-03 2:29 ` Mark H Weaver [this message]
2012-08-03 8:24 ` Andy Wingo
2012-08-03 11:54 ` Stefan Israelsson Tampe
2012-08-03 12:38 ` Andy Wingo
2012-08-03 13:13 ` Stefan Israelsson Tampe
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=501B376F.3060505@netris.org \
--to=mhw@netris.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/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).