[LLVMdev] x86 unwind support[MESSAGE NOT SCANNED]

Mark Shannon marks at dcs.gla.ac.uk
Mon Jul 20 08:33:24 PDT 2009


Nick Johnson wrote:
> On Mon, Jul 20, 2009 at 10:09 AM, Mark Shannon<marks at dcs.gla.ac.uk> wrote:
>> Andrew Haley wrote:
>> If you can make your point without any references to any C/C++ specific
>> features it might be more convincing ;)
>>
> 
> I did.  Recall my mention of java/c#/ruby/python's finally/ensure
The finally block is just a bit of syntactic sugar on a try/catch block:

try:
    do something
    ex = NULL
    goto _final
catch:
    ex = caught exception
    do something else
_final:
    do something important
    if ex:
       rethrow ex

> blocks, or C#'s using blocks.  For proper implementation, these need
> multi-level unwinds, as they specify that some code must run, even if
> an exception would bail-out.

You are confusing stopping the unwinding at *some* levels or at *all* 
levels.
Eg.
invoke
  call
   call
    invoke
     call
      call
       unwind

Requires a two unwinding steps for Java/Python and six steps for C++.
Only languages with stack-allocated objects must stop unwinding for calls.

> 
>> I take it you have never used Python ;)
>> (Python uses exceptions to terminate loops, so it helps if they aren't
>> too slow)
> 
> I have used python, and it is slow (sorry).  In fact, python

Python: write program 1 day, run program 10mins = 1day + 10mins
C++: write program 1 month, run program 30 seconds = 1month + 30 secs
It depends on how you look at it, but we are getting off topic here :)

> Exceptions are implemented in python as a second return value, thus
Only in one particular Python implementation, there are several.
Its not in the language spec.

> EVERY function, even those which don't throw exceptions, must pay the
> price.  And just because the python community does it, doesn't mean
> it's good programming practice.
The same could be said of C++. Both languages have their place, and llvm 
should support compilers for both (and lots of other languages as well).
> 
>> Please try and get out of the C++ mindset, llvm may be implemented *in*
>> C++, but its not implemented just *for* C++ (at least I hope it isn't).
> 
> That is exactly my argument.  Multi-level unwinds are required by MANY
> languages.
> 
Not in the same way as C++, see above.





More information about the llvm-dev mailing list