[PATCH][cxxabi] ARM EHABI zero-cost exception handling for libc++abi
Nick Kledzik
kledzik at apple.com
Mon Apr 14 13:51:28 PDT 2014
On Apr 13, 2014, at 3:16 AM, Logan Chien <tzuhsiang.chien at gmail.com> wrote:
> Hi,
>
> I have worked on ARM EHABI zero-cost exception handling for libc++abi.
>
> With the attached patch, I can compile and run all libc++abi unittests on ARM Linux.
>
> Is it OK to commit? Thanks.
>
> diff --git a/include/unwind.h b/include/unwind.h
> index c5acd93..e57d756 100644
> --- a/include/unwind.h
> +++ b/include/unwind.h
> @@ -23,8 +23,24 @@
> #define LIBUNWIND_UNAVAIL
> #endif
>
> +#if !defined(LIBCXXABI_SJLJ)
> +# if defined(__arm__)
> +# if defined(__APPLE__)
> +# define LIBCXXABI_ARM_EHABI 0
> +# define LIBCXXABI_SJLJ 1
> +# else
> +# define LIBCXXABI_ARM_EHABI 1
> +# define LIBCXXABI_SJLJ 0
> +# endif
> +# else
> +# define LIBCXXABI_ARM_EHABI 0
> +# define LIBCXXABI_SJLJ 0
> +# endif
> +#endif
I recently found that the compiler has a built-in define __USING_SJLJ_EXCEPTIONS__ that is set when compiling for setjump/longjump based exceptions. Is there are similar built-in for ARM EHABI? If so, we can set these up without testing for __arm__ or __APPLE__. In fact, LIBCXXABI_SJLJ can be replaced with __USING_SJLJ_EXCEPTIONS__. And perhaps LIBCXXABI_ARM_EHABI can be replaced with some built-in?
> diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
> index 744dddd..27a55c5 100644
> --- a/src/cxa_exception.cpp
> +++ b/src/cxa_exception.cpp
> @@ -232,7 +232,7 @@ __cxa_throw(void* thrown_object, std::type_info* tinfo, void (*dest)(void*))
> globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local
>
> exception_header->unwindHeader.exception_cleanup = exception_cleanup_func;
> -#if __arm__
> +#if LIBCXXABI_SJLJ
> _Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
> #else
I like the conditional test for SJLJ instead of the processor, but as I recently discovered, most of the existing __arm__ tests can be changed to __USING_SJLJ_EXCEPTIONS__ tests.
-Nick
More information about the cfe-commits
mailing list