public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Geoff Keating <geoffk@geoffk.org>
To: Mike Stump <mrs@apple.com>
Cc: Jason Merrill <jason@redhat.com>, gcc@gcc.gnu.org
Subject: Re: __attribute__((cleanup(function)) versus try/finally
Date: Tue, 13 May 2003 00:07:00 -0000	[thread overview]
Message-ID: <jm8ytb3e0n.fsf@desire.geoffk.org> (raw)
In-Reply-To: <82B7548E-81A4-11D7-BD07-003065A77310@apple.com>

Mike Stump <mrs@apple.com> writes:

> On Thursday, May 8, 2003, at 01:46 PM, Richard Henderson wrote:
> > On Thu, May 08, 2003 at 11:29:50AM -0700, Mike Stump wrote:
> >> If table size is a big issue, we can have C default to sjlj EH (lower
> >> cost in non-EH code), and integrate in handling for sjlj exceptions
> >> into the dwarf EH system.
> >
> > Lets not, please.  This is much harder than you realize, and
> > involves a siginificant performance impact to dwarf-only EH.
> 
> Ok.  I was imagining a scheme that elaborated a failure case (lookup
> the pc and not find any entries) and just checked the new sp value
> against sjlh_EH_stack->sp and did the sjlj stack processing if
> required.  Maybe there are other nits that complicate it.

If table size is an issue, how about we just reduce it?

For instance, much of the information in the tables is included in the
object code (nearly all of it in the case of routines that don't
actually have cleanups).  It wouldn't be that hard to write a routine
that, given a return address, can determine what registers need to be
restored and from where in 90% of the cases by looking at the object
code; those routines (in the 90%) can have an abbreviated EH entry
that just says "use the object code", and the remaining 10% could have
a real EH entry.

For powerpc-elf, this could be as simple as this algorithm:

1. Look back in the object code until you see a stack push
2. That stack push creates the initial frame, so you know the size of the frame
2. Look forward from here until you see a branch
   3a. For the first store of each callee-saved register at an offset from
       the stack (maybe with some special code for altivec), restore it
       from that offset.

Now, this doesn't work in every case; routines with a too-large stack
frame, or that use alloca, won't work, and you won't want to try this
with any routine that's larger than a certain size for efficiency
reasons, and there may be other cases.  But it does work for the vast
majority of routines, and it's easy to check (given some RTL) whether
it'll work, and that's enough.

For x86, you'll want something a bit more complicated, because you'll
want to track push/pop operations, but if you can find the start of
the routine, you can follow code flow and assume that the stack depth
is constant at any particular point to avoid needing to go around
loops (like the Java verifier).

-- 
- Geoffrey Keating <geoffk@geoffk.org>

  reply	other threads:[~2003-05-13  0:07 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-06 19:56 Jason Merrill
2003-05-08 11:59 ` Gabriel Dos Reis
2003-05-08 15:02   ` Jason Merrill
2003-05-08 18:30 ` Mike Stump
2003-05-08 20:49   ` Richard Henderson
2003-05-08 22:29     ` Mike Stump
2003-05-13  0:07       ` Geoff Keating [this message]
2003-05-13 21:27         ` Richard Henderson
2003-05-14  1:14           ` Geoff Keating
2003-05-14  7:41             ` Richard Henderson
2003-05-14 21:11               ` Geoff Keating
2003-05-14 22:20                 ` Richard Henderson
     [not found] <Pine.BSF.4.55.0305061457450.57349@acrux.dbai.tuwien.ac.at>
     [not found] ` <1052245742.2583.315.camel@doubledemon.codesourcery.com>
     [not found]   ` <wvlissnc2e3.fsf@prospero.boston.redhat.com>
     [not found]     ` <1052249890.31850.338.camel@doubledemon.codesourcery.com>
2003-05-06 21:04       ` Jason Merrill
2003-05-06 21:24         ` Mark Mitchell
2003-05-07 21:21           ` Jason Merrill
2003-05-07 22:18             ` Mark Mitchell
2003-05-07 23:01               ` Jason Merrill
2003-05-08 12:05               ` Gabriel Dos Reis
2003-05-09  5:46               ` Kai Henningsen
2003-05-06 21:52         ` Anthony Green
2003-05-08 17:44         ` Mike Stump
2003-05-08 17:45           ` Jason Merrill
2003-05-08 18:40             ` Mark Mitchell
2003-05-08 19:06               ` Alexandre Oliva
2003-05-08 19:47                 ` Mark Mitchell
2003-05-08 20:19                   ` Alexandre Oliva
2003-05-08 21:18                   ` Jason Merrill
2003-05-13 21:10                     ` Mark Mitchell
2003-05-13 21:25                       ` Richard Henderson
2003-05-13 21:41                         ` Mark Mitchell
2003-05-13 22:16                           ` Richard Henderson
2003-05-13 21:31                       ` Gabriel Dos Reis
2003-05-15 17:00                       ` Jason Merrill
2003-05-15 17:23                         ` Mark Mitchell
2003-05-09 19:41                   ` Kai Henningsen
2003-05-08 19:37               ` Jason Merrill
2003-05-07  0:14   ` Richard Henderson
2003-05-07  2:32     ` Mark Mitchell
2003-05-07 10:18 Ranjit Mathew
2003-05-07 13:54 ` Jason Merrill
2003-05-07 18:23 ` Richard Henderson
2003-05-08 18:02 ` Mike Stump
2003-05-08  7:49 Ranjit Mathew
2003-05-08 21:21 ` Richard Henderson
2003-05-09  9:23 Ranjit Mathew
2003-05-09  9:31 ` Andrew Haley
2003-05-09  9:54 Ranjit Mathew
2003-05-09 10:16 ` Andrew Haley
2003-05-09 12:08   ` Fergus Henderson
2003-05-09 12:49   ` Jamie Lokier
2003-05-13 21:33 Richard Kenner
2003-05-13 22:11 ` Richard Henderson

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=jm8ytb3e0n.fsf@desire.geoffk.org \
    --to=geoffk@geoffk.org \
    --cc=gcc@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=mrs@apple.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).