From: Richard Earnshaw <rearnsha@arm.com>
To: Daniel Jacobowitz <drow@mvista.com>
Cc: Richard.Earnshaw@arm.com, Jim Wilson <wilson@specifixinc.com>,
gcc-patches@gcc.gnu.org
Subject: Re: avoid unnecessary register saves for setjmp
Date: Fri, 28 Nov 2003 14:02:00 -0000 [thread overview]
Message-ID: <200311281235.hASCZM927688@pc960.cambridge.arm.com> (raw)
In-Reply-To: Your message of "Sat, 22 Nov 2003 11:26:54 EST." <20031122162654.GA6032@nevyn.them.org>
> > In the EABI we've been developing for the ARM we've been very careful to
> > say that only the setjmp and longjmp functions can know the contents and
> > layout of a jmp_buf. This allows a function to use co-processor registers
> > that are call saved and to be used in the middle of a call sequence
> > without upsetting any other conforming code. Hence only the C library
> > needs to know the list of co-processors that are in use (and it is
> > entitled to enter into other private conspiracies to determine the
> > registers that need to be saved. We've even designed the EH
> > implementation in a way that will allow this to work as well (the unwinder
> > will only try to execute instructions to access a particular co-processor
> > once it has found a description of that co-processor in the unwind list).
>
> How do you intend to implement this in practice? I'm not concerned
> with the contents or layout of a jmp_buf; conforming programs can't get
> at them. But user programs declare jmp_buf, which implies that they
> know its size. And there's no way I can think of to dynamically
> allocate additional space if the jmp_buf is insufficiently large.
> Are you simply defining a very large jmp_buf for expansion?
>
> This is the problem I encountered on both PowerPC and ARM. I'm very
> curious to hear any solutions to it.
There's never a perfect solution to a situation like this. The failure of
history (and more recently of language standards bodies) to recognize that
portable binaries have as much importance as portable source means that in
the dark corners you are always doomed to failure.
The way we've approached the issue for the "ABI for the ARM Architecture"
is to define a compliance model. The model is fairly simple and basically
divides into 2 categories.
In the "portable object" category, the trade-off is in the direction of
portability over outright compliance to the language standards and
performance. Sometimes it's necessary to write your source code using a
particular idiom in order to achieve maximum portability. In other cases
constants that the C standard says are compile-time literals may only be
available as link-time constants. You are also restricted as to the
library functions you may call. In general, for example, you can't
include stdio.h in a portable object and have it do anything useful. We
believe that developers targeting the portable-objects market will be
prepared to live with the restrictions because it's better than anything
they could have otherwise.
In the "platform object" category, the trade-off is in the direction of
compliance to the relevant standards. You can use the full features of
the language, but your object is tied to a particular platform.
setjmp is one of those functions that lies on the boundary between the two
models. If you are compiling for a particular platform, which has a
strict ABI, then you can use a jmp_buf that is exactly right for that
platform. But if you are building a portable object, you have to be
prepared to handle platforms with a lot of registers that need saving and
restoring; it is however, possible to err on the side of caution and just
say that any static jmp_buf must be at least as large as the jmp_buf used
by any supported target system. For a dynamic jmp_buf, if you are
prepared to use dynamic allocation, and to use source-code modifications,
then we've added a link-time constant that will tell you the exact size
needed for the platform the code ends up running on.
As for the portable static size of a jmp_buf, we looked at the likely
register needs given the current co-processor blocks in existence today,
and concluded that we currently should allow for 32 double-words of memory
(256 bytes, 8-byte aligned) for the buffer. We've no proof that we will
never need more, but sometimes you just have to make a judgement call.
We'd recommend that developers defining new open-platform ABIs use the
portable size, since it then gives them maximum defence against future
processor trends.
R.
Disclaimer: the ABI for the ARM Architecture" is still in draft form, so
any specifics cited above may still be subject to change. I don't expect
them to, but the possibility does exist.
next prev parent reply other threads:[~2003-11-28 12:35 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-21 5:54 Jim Wilson
2003-11-21 18:39 ` Daniel Jacobowitz
2003-11-22 0:22 ` Jim Wilson
2003-11-22 3:57 ` Daniel Jacobowitz
2003-11-22 9:06 ` Jim Wilson
2003-11-22 14:37 ` Richard Earnshaw
2003-11-22 16:33 ` Daniel Jacobowitz
2003-11-27 9:11 ` Zack Weinberg
2003-11-27 17:11 ` Andrew Pinski
2003-11-27 18:23 ` Zack Weinberg
2003-11-28 5:15 ` Geert Bosch
2003-11-28 11:14 ` Richard Earnshaw
2003-11-28 14:02 ` Richard Earnshaw [this message]
2003-11-21 20:14 ` Geoff Keating
2003-11-22 0:20 ` Jim Wilson
2003-11-30 9:23 ` Jim Wilson
2003-11-22 4:13 Richard Kenner
2003-12-01 3:29 ` Jim Wilson
2003-11-27 9:19 Chris Lattner
2003-11-27 9:21 ` Andrew Haley
2003-11-27 9:22 ` Chris Lattner
2003-11-27 9:39 ` Andrew Haley
2003-11-27 9:43 ` Chris Lattner
2003-11-27 10:14 ` Zack Weinberg
2003-11-27 10:15 ` Chris Lattner
2003-11-27 11:01 ` Zack Weinberg
2003-11-27 20:28 ` Chris Lattner
2003-11-27 20:51 ` Gabriel Dos Reis
2003-11-27 15:41 ` Jan Vroonhof
2003-11-27 16:23 ` Jan Vroonhof
2003-11-27 10:31 ` Andrew Haley
2003-11-27 10:53 ` Zack Weinberg
[not found] <5cad8ef043da68f2a3332f00bd6a186a3fc6195b@mail.esmertec.com>
2003-11-27 20:44 ` Chris Lattner
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=200311281235.hASCZM927688@pc960.cambridge.arm.com \
--to=rearnsha@arm.com \
--cc=Richard.Earnshaw@arm.com \
--cc=drow@mvista.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=wilson@specifixinc.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).