🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3052

Re: Throwing an exception from within a si

#3052
From: Steve Clamage
Date: Sat, 20 Jan 1996 04:15
56 lines
3742 bytes
In article k04@wcap.centerline.com, chase@centerline.com (David Chase) writes:
>In article mca@engnews1.Eng.Sun.COM, clamage@Eng.Sun.COM (Steve Clamage)
>writes:
>> Suppose that function entry and exit are not atomic operations, which is
>> the case on all systems supporting C++ that I am aware of. The "critical
>> structure" is the stack frame. If asynchronous interrupts can occur, and
>> if you are going to require well-defined exception behavior from signal
>> handlers, then you must lock the entirety of every function preamble and
>> postamble. (You cannot know that an external signal won't occur.) That
>> requirement not only slows down function calls, it adds to interrupt
>> latency.
>
>As near as I can tell, the best way to do this is to slightly enhance a
>PC-range-based exception-handling specification.  I was pushing for
>this for the Sparc V9 ABI when I worked at Sun, but it was tough
>slogging.  [ explanation of how to do it deleted ]

>> What we put in the language standard is binding on all implementations. We
>> try to specify things that can be implemented efficiently on any likely
>> system. In addition, we try to specify features so that they have no cost
>> (or nearly no cost) if you don't use them. IMHO, guarantees about what you
>> can do in an asynchronous signal handler don't meet those criteria for
>> inclusion in the C++ standard.
>
>I think I've just described a way to do this that is efficient on any
>likely system, and that has no runtime cost if you don't use it. ...

>An additional stunt is simply to have your exception-handler recognize
>standard function pre and post-ambles, or standard phases of activation
>record construction, and avoid the need for additional code. ...

I'm more than willing to assume your implementation technique has merit.
Yet didn't you say you were not able to get it approved? So what
is a C++ implementor to do if the only reasonable implementation
technique violates the platform ABI?

I have longer experience with non-RISC implementations than with RISC
implementations. It is common for non-RISC implemenations not to have
a recognizable function preamble or postamble. There are not just two or
three possible instruction sequences making up function entry and exit --
there are dozens or even hundreds of possible sequences. If you standardize
on recognizeable entry and exit sequences you take a noticeable performance
hit, particularly on popular benchmark programs.

I want to say again that a criterion for a feature in the standard is not
whether you can somehow implement it on some systems. The criterion is more
like whether you can implement it with appropriate efficiency on all
systems and not adversely affect programs that don't use the feature.
If a feature does not meet this criterion, it has to be widely beneficial
to justify its inclusion.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4dos4l$ra9@engnews1.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <4doh5o$k04@wcap.centerline.com>

Show Full Headers
Complete Article Headers
From: clamage@Eng.Sun.COM (Steve Clamage)
Message-ID: <4dos4l$ra9@engnews1.Eng.Sun.COM>
X-Original-Date: 19 Jan 1996 19:41:09 GMT
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 20 Jan 96 04:15:57 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: Throwing an exception from within a si
Organization: Sun Microsystems Inc.
References: <4doh5o$k04@wcap.centerline.com>
Reply-To: clamage@Eng.Sun.COM
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMQBsjOEDnX0m9pzZAQE2qAF/bYO3eJq5aa2wT4yPBOIlRbKSp7Gh8FWr
 CdqLWzm1QDspyVlNu6yhE6J+8CP5GgyF
 =s+0/