April 10, 2014 Re: Use C++ exception model in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Wednesday, 9 April 2014 at 17:27:56 UTC, David Nadlinger wrote:
> On Wednesday, 9 April 2014 at 16:48:54 UTC, Jacob Carlborg wrote:
>> x86_64 yes, not necessarily only for DMD. I thought if DMD, LDC and GDC all used the same exception handling model and the same as C++ it would be easier. Especially for implementing support for Objective-C exceptions, which is why initially started this thread.
>
> They don't. GDC and LDC use libunwind, whereas DMD uses its own custom EH implementation.
>
> With GDC and LDC, you'd just need to add your code to handle Objective-C exceptions to the personality functions. libunwind exceptions have a "type"/"source language" field, and by default most implementations either ignore unknown exception types or abort on encountering them.
>
> David
The C++ personality function from GCC does not catch, but do the cleanup on foreign exceptions. That sound like the right behavior to me.
|
April 10, 2014 Re: Use C++ exception model in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 2014-04-10 08:53, deadalnix wrote: > The C++ personality function from GCC does not catch, but do the cleanup > on foreign exceptions. That sound like the right behavior to me. As far as I understand the cleaning is only a part of what personality function does. The first thing it does is check if the thrown exception can be handled. Like determine if it's a C++ exception or some other exception. If I recall correctly, it also determines if and where to resume unwinding, where to find catch blocks and so on. This [1] series of blog posts gives a pretty good understanding of how C++ exceptions work under the hood, for those that don't want to read the ABI documentation. [1] http://monoinfinito.wordpress.com/series/exception-handling-in-c/ -- /Jacob Carlborg |
April 10, 2014 Re: Use C++ exception model in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Thursday, 10 April 2014 at 19:23:12 UTC, Jacob Carlborg wrote: > On 2014-04-10 08:53, deadalnix wrote: > >> The C++ personality function from GCC does not catch, but do the cleanup >> on foreign exceptions. That sound like the right behavior to me. > > As far as I understand the cleaning is only a part of what personality function does. The first thing it does is check if the thrown exception can be handled. Like determine if it's a C++ exception or some other exception. If I recall correctly, it also determines if and where to resume unwinding, where to find catch blocks and so on. > > This [1] series of blog posts gives a pretty good understanding of how C++ exceptions work under the hood, for those that don't want to read the ABI documentation. > > [1] http://monoinfinito.wordpress.com/series/exception-handling-in-c/ You want to look at libstdc++-v3/libsupc++/eh_personality.cc in gcc's source code. The personality function test if the exception is a C++ exception, in which case the regular flow apply. If not, the foreign_exception flag is set, and some behavior are altered. Basically, for what we are concerned with D, only cleanup will be executed (the filter part is irrelevant to D). |
April 11, 2014 Re: Use C++ exception model in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 11/04/14 00:05, deadalnix wrote: > You want to look at libstdc++-v3/libsupc++/eh_personality.cc in gcc's > source code. If I'm to look at some source code I rather look at libc++abi from LLVM. > The personality function test if the exception is a C++ exception, in > which case the regular flow apply. If not, the foreign_exception flag is > set, and some behavior are altered. Basically, for what we are concerned > with D, only cleanup will be executed (the filter part is irrelevant to D). Why is the filter part irrelevant? -- /Jacob Carlborg |
April 12, 2014 Re: Use C++ exception model in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 11 April 2014 at 06:29:37 UTC, Jacob Carlborg wrote:
> Why is the filter part irrelevant?
filter is "catch everything but.." kind of clause. The semantic do not exists in D, so we don't really care.
|
Copyright © 1999-2021 by the D Language Foundation