[LLVMdev] An alternate implementation of exceptions

Richard Osborne richard at xmos.com
Fri Sep 4 09:14:35 PDT 2009


Sebastian Redl wrote:
> Mikael Lyngvig wrote:
>   
>> Hi Duncan,
>>
>> I agree on the problem about linking with code - I actually do mention
>> this in the paper.  I propose adding a new calling convention called
>> "excall".
>>   
>>     
> The problem is that you can't automatically determine from a function
> declaration whether it comes from "inside" (is exception-aware) or not.
> This means that you'd have to make the user explicitly declare one of
> them. This is either a nightmare for using libraries (modify all
> headers, or introduce an extern "C"-block-like feature as C++ has it, to
> wrap the header includes), or a nightmare for writing new code (every
> new function needs to have it, explicitly).
>   
You could use some form name mangling on all symbols which are exception 
aware. When there is a mismatch between callee and caller you will get a 
undefined symbol. You would then add thunks for these symbols (by having 
a tool which parse error messages from the linker or by modifying the 
linker to add them).

When an exception aware function calls a non exception aware one the 
thunk should call the function, clear the flags and then return. When an 
non exception aware function calls a function which might throw the 
thunk should check for an exception. If there is a pending exception it 
should abort, otherwise it would just return.

-- 
Richard Osborne | XMOS
http://www.xmos.com




More information about the llvm-dev mailing list