[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Switching to libobjc2
From: |
David Chisnall |
Subject: |
Re: Switching to libobjc2 |
Date: |
Thu, 28 Jun 2012 08:52:13 +0100 |
Hi Konstantin,
As the author of the GNUstep runtime, I think that's great. On x86[-64] and
ARM it now implements the objc_msgSend() dispatch mechanism. This is enabled
by default if you compile with clang on *BSD, and optionally on Linux. When
using this mechanism, message sending is very fast. When using the traditional
two-stage lookup, it's slightly slower than the GCC runtime because it also
supports a few other cases (specifically, small objects hidden inside pointers)
which the GCC runtime does not support. You may want to make use of this
support in your code. There are also some LLVM optimisations shipped with the
runtime that can do things like cache method lookups in loops, which can make
the cost of message sending even cheaper.
If you want to catch C++ exceptions, then you have two choices. The simplest
is to compile your code as Objective-C++. This will then use the Objective-C++
personality function and everything should work by magic. Alternatively, you
must provide and register a class that is used to pass C++ exceptions to
Objective-C handlers. This is required because the GCC ABI did not provide a
callback into the runtime for disposing of exceptions. The CXXException class
in GNUstep does this (you can also explicitly catch this class if you want to
catch C++ exceptions from Objective-C code).
David
On 28 Jun 2012, at 08:20, Konstantin Osipov wrote:
> Hello,
>
> Tarantool/Box is a NoSQL in-memory database written in Objective
> C. The code is licensed under simplified BSD license.
>
> The code was initially written in pure C, and slightly more than a
> year ago we made a switch to Objective C for its support of
> exceptions and @finally clause.
>
> Unfortunately, the Objective C runtime shipped with GCC has a number
> of defects, which we suffer from:
>
> - the runtime API has changed significantly between gcc 4.4, 4.6
> and 4.7, so we effectively limit our users, who often build the
> software from source, to a certain version of gcc.
> - catch (...) doesn't catch C++ exceptions, and LuaJIT library, which we
> use, throws C++ exceptions
> - Objective C method dispatch is expensive enough to slow down our
> benchmarks in double percent digits (>10%), whenever we try to
> make our C code more object-oriented and use methods instead of
> function pointers.
>
> For these and a number of other reasons we decided to try the
> GNUSTEP Objective C runtime.
>
> Unfortunately, GNUSTEP runtime is still not popular among Linux
> distributions, needless to say some of our users still use
> CentOS 5.2, which doesn't even have a modern GCC.
>
> For this reason we plan to include the sources of the runtime into
> Tarantool/Box code base (http://github.com/mailru/tarantool), as we
> already do with LuaJIT, and link statically with it. This way,
> our users can download and compile Tarantool with minimal external
> dependencies.
>
> I'd love to hear your feedback on our decision to switch and the
> chosen approach.
>
> --
> http://tarantool.org - an efficient, extensible in-memory data store
>
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep
--
This email complies with ISO 3103