⏩ A fast, portable Objective-C runtime written 100% in C11
A portable Objective-C runtime written in C11. No Assembler required. It follows the Apple "Objective-C 1 Runtime" and adds many features from "Objective-C 2.0", but the runtime function calls are completely different. It is designed to be suitable for massive multi-threading.
What's so different ?
Runtime objects (like classes and selectors) are not referenced by name, but by a unique ID. No special linker action required.
Parameters outside of
_cmdare passed via
_param, a single pointer to a struct. This simplifies a lot of code, especially forwarding code. Return values are also returned with the same struct. Optimizations are done for simple methods with only none or one parameter and none or one return value.
It uses inlineable method calls for superior performance. The user can specify "fast" classes and "fast" methods for extra speed in performance critical cases.
releasesemantics are built in. These are non-overridable, which makes them a lot faster.
isais not part of the instance, but instead prefixed to the instance.
Protocolas a type and an object does not exist anymore. Instead there is PROTOCOL which is basically the same as SEL and has compiler support.
No global lock, except when loading code. The runtime in normal operation only locks during
+initializeon a per class basis.
Protections against the fragile base class problem
Multiple runtimes can coexist in differently named "universes".
Required Libraries and Tools
How to use it
If you haven't used an Objective-C runtime before, it is useful to get to know the much better documented "Mac OS X Objective-C 1.0" runtime first. Intro to the Objective-C Runtime could be a good starting point.
It you use
.cfiles that include
<mulle-objc-runtime/mulle-objc-runtime.h>make sure that you compile with
__MULLE_OBJC_NO_FCS__as defined when compiling the runtime. Since C-only compilations do not emit runtime information, mismatches can not be checked by the runtime. Easy fix: rename
.mand use mulle-clang
||Deal with Classes|
||Install Classes, Categories, Methods, Strings into the runtime|
||Deal with Methods|
||Deal with Instances|
||Work with the runtime|
|Global Functions||Global functions and conveniences|
|Vararg extensions||Dealing with variable arguments|
These articles give you some background about the mulle-objc runtime:
- mulle-objc: a new Objective-C runtime
- mulle-objc: a meta calling convention
- mulle-objc: removing superflous ifs
- mulle-objc: inlined messaging
- mulle-objc: some research about selectors
- mulle-objc: hashes for classes, selectors and protocols
- mulle_objc: object layout, retain counting, finalize
- mulle_objc: inheriting methods from protocols
- mulle_objc: present and absent language features
- mulle_objc: the trouble with @property
- mulle_objc: ivar layout with @property
- mulle_objc: technically speaking
- mulle-clang, technically speaking
- mulle-objc-runtime, technically speaking
- MulleFoundation, technically speaking
If something is unclear, feel free to contact the author.
Platforms and Compilers
Use mulle-sde to add mulle-objc-runtime to your project:
mulle-sde dependency add --c --github mulle-objc mulle-objc-runtime
Executables will need to link with mulle-objc-runtime-startup as well.
See mulle-objc-developer for the preferred way to installation mulle-objc-runtime.
Use mulle-sde to build and install mulle-objc-runtime and all dependencies:
mulle-sde install --prefix /usr/local \ https://github.com/mulle-objc/mulle-objc-runtime/archive/latest.tar.gz
Install the requirements:
|mulle-atinit||Cross-platform atinit support|
|mulle-concurrent||Concurrent hashmap and array|
|mulle-dlfcn||Cross-platform dlfcn support|
|mulle-stacktrace||Cross-platform stacktrace support|
|mulle-vararg||Cross-platform atexit support|
mkdir build 2> /dev/null ( cd build ; cmake -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_PREFIX_PATH=/usr/local \ -DCMAKE_BUILD_TYPE=Release .. ; make install )