[Mono-devel-list] RAPGO Proposal

Willibald Krenn Willibald.Krenn at gmx.at
Tue Nov 30 08:45:07 EST 2004


Jonathan Pryor schrieb:
> In theory, you're possibly correct.  In practice, you're not. :-)

Ok, seems it was a bad idea after all :-)


> The only platforms where C++ and Mono exceptions could possibly work
> portably is on platforms where the C++ ABI is standardized.  The only
> such platform I'm aware of is IA64 (Itanic, er, Itanium), and Mono
> doesn't have a JIT for that platform AFAIK.

AMD64 also has a standardized interface for stack-unwinding (=exception 
handling; I guess it was inspired by IA64.)

> Furthermore, if the platform *does* have a C++ ABI standard, then Mono
> could just re-use the C++ exception structures, allowing C++ exceptions
> to be properly handled by the Mono runtime.  A C++ compiler wouldn't be
> necessary.

I can only speak for AMD64: Yes, you can throw exceptions in C-only code:

_Unwind_Exception *newException = 
(_Unwind_Exception*)malloc(sizeof(_Unwind_Exception));
newException->exception_class = 0xaabbcc00aabbcc00;
newException->exception_cleanup = &FreeNewException;
_Unwind_RaiseException(newException);


But you can not catch exceptions with C-only code. This is because the 
C++ compiler generates special unwind-information (AFAIK in dwarf2 
format) and exception handling is dependand on this information.

BTW: On Linux-AMD64 it's possible (as  probably in IA64) that different 
compilers can catch exceptions thrown in modules compiled with 'foreign' 
C++/whatever compilers.

Note that a try/catch block does not incur runtime overhead on AMD64 - 
just throwing an exception is very costly..

Willi




More information about the Mono-devel-list mailing list