[cfe-commits] [libcxxabi] r137118 - /libcxxabi/trunk/src/cxa_exception.cpp
Howard Hinnant
hhinnant at apple.com
Tue Aug 9 17:11:52 PDT 2011
On Aug 9, 2011, at 1:52 PM, John McCall wrote:
> On Aug 9, 2011, at 8:09 AM, Marshall Clow wrote:
>> +static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1
>
> Ugh. I would prefer to avoid Sebastian's dependent exception stuff.
It is coming. I'll get it in.
> Is it
> really unreasonable to say that std::rethrow_exception can only rethrow
> a non-foreign exception?
I don't know the answer to this one. I think we should try to keep the functionality of Apple's current abi, but deciphering exactly what that is is a non-trivial task.
Howard
>
>> // Utility routines
>> -static __cxa_exception *exception_from_object ( void *p ) {
>> +static __cxa_exception *exception_from_thrown_object ( void *p ) throw () {
>> return ((__cxa_exception *) p ) - 1;
>> }
>
> I know some of this code is not new in this patch, but please follow
> the LLVM coding style. In particular, something like this should be
> formatted:
>
> static __cxa_exception *exception_from_thrown_object(void *p) throw () {
> return ((__cxa_exception *) p) - 1;
> }
>
>> +void * __cxa_begin_catch(void * exceptionObject) throw() {
>> + __cxa_eh_globals *globals = __cxa_get_globals ();
>> + __cxa_exception *exception = exception_from_exception_object ( exceptionObject );
>> +
>> +// TODO add stuff for dependent exceptions.
>> +
>> +// TODO - should this be atomic?
>> +// Increment the handler count, removing the flag about being rethrown
>> +// assert ( exception->handlerCount != 0 );
>> + exception->handlerCount = exception->handlerCount < 0 ?
>> + -exception->handlerCount + 1 : exception->handlerCount + 1;
>
> The answer is that yes, this does need to be atomic; in '0x, exceptions can be
> rethrown on multiple threads.
>
> I don't understand why this interaction is so complicated. Why doesn't this work:
> _cxa_throw_exception initializes the reference count to 1
> _cxa_begin_catch does not change the reference count
> _cxa_rethrow increments the reference count
> _cxa_end_catch decrements the reference count and deletes the exception
> if the count reached 0.
>
> The std::exception_ptr routines will also need to modify this reference count
> somehow, but I'm not sure what those routines look like.
>
> John.
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list