libobjc2 with build changes and Darling additions
Go to file
theraven 0d78186238 Some bug fixes and tidies.
I now have an out-of-tree replacement for the dtable stuff, so sarray.{h,c} will be going away soon.  The replacement offers similar (slightly worse currently) performance in microbenchmarks, but uses half as much memory (Gorm goes from 95MB to 48MB on my machine).  This will be committed once it's been tweaked a little bit.
2010-05-14 21:47:35 +00:00
GCKit Added out-of-tree GCKit stuff. Still (very) work-in-progress. 2010-04-26 21:33:59 +00:00
objc Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
opts Rename the library with the lib prefix so it can actually be linked sensibly. 2010-05-09 12:28:36 +00:00
toydispatch Allowed hash tables to dynamically resize. This uses toydispatch to free the old version of the table after copying all of the data into the new one, after waiting enough time to allow all potential readers to finish. There are theoretical cases when this can fail, but hopefully no practical ones. The theoretical cases can be removed by making the garbage thread run at a lower priority than all of the other threads in the system. 2010-01-25 22:56:54 +00:00
blocks_runtime.m Added types support to blocks runtime, tidied up UNIX98 stuff. 2009-09-11 10:28:49 +00:00
class_table.c Fixed use of uninitialized variable. 2010-03-28 19:09:57 +00:00
class.c Rewrote class resolving code. Now it only resolves classes that actually need resolving, rather than iterating over the entire class table. 2010-03-12 22:47:10 +00:00
class.h Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
COPYING More refactoring. 2010-05-13 23:27:17 +00:00
COPYING3 Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
COPYING.MIT Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
COPYING.RUNTIME Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
dtable_legacy.c Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
encoding.c Revert change ... leave objc_skip_offset() buggy for code which depends on that behavior. It's better just to avoid using it anywhere else. 2010-04-14 11:57:15 +00:00
exception.c Initial commit of GCKit (moved from Étoilé and the missing 90% mostly implemented). GCKit implements cycle detection on the heap and tracing on the stack and designated heap regions, with support for weak references. It is designed for implementing OS X 10.5-compatible GC semantics. 2010-02-02 23:36:38 +00:00
gc.c Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
GNUmakefile Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
hash_table.c Added missing file. 2010-02-01 14:48:40 +00:00
hash_table.h Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
hash.c Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
init.c More refactoring. 2010-05-13 23:27:17 +00:00
ivar.c More refactoring. 2010-05-13 23:27:17 +00:00
ivar.h More refactoring. 2010-05-13 23:27:17 +00:00
libobjc_entry.c Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
linking.m Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
lock.h Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
magic_objects.h Made magic object header use #define instead of const (gets rid of unused variable warnings). 2010-03-06 13:46:48 +00:00
method_list.h Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
misc.c Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
mutation.m Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
nil_method.c Bug fixes in libobjc2: 2009-11-14 18:09:51 +00:00
NSBlocks.m Revert last commit. Was fixing the wrong thing. 2010-05-01 13:53:51 +00:00
NXConstStr.m Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
Object.m Restored stub version of objc_get_stream_class_version to prevent linking with -base failing. 2010-01-25 15:49:15 +00:00
objects.c Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
pool.h Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
properties.m Changed ptrdiff_t to int in property accessors. This is for compatibility with some changes in clang that are required to prevent things from breaking on LP64 platforms. 2010-03-23 16:11:57 +00:00
protocol.c Fix crash with gcc-compiled protocols. 2010-01-25 23:34:00 +00:00
Protocol.m Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
README Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
runtime.c Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
sarray2.c Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
sarray2.h Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
sarray.c Removed assertion. I'm not entirely sure why it was there, but it was preventing Gorm running (along with anything else that provided categories on subclassed classes). I need some more testing to make sure that this didn't break anything else, but Gorm now runs correctly with the new runtime, so it seems like an improvement... 2009-10-25 15:47:57 +00:00
selector_table.c Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
selector.c Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
selector.h Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
sendmsg2.c Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
sendmsg.c Some bug fixes and tidies. 2010-05-14 21:47:35 +00:00
sendmsg.d Tidied up some bits by creating private headers for private data structures. 2010-05-13 22:29:56 +00:00
slot_pool.h Factored out dtable stuff into dtable_legacy.c so that it can be replaced and so that we can do some profiling of the replacement to make sure it doesn't introduce performance regressions. 2010-05-14 17:53:35 +00:00
string_hash.h Mark string functions unused, in case the header is included in files that only use one of them. 2010-05-14 11:19:04 +00:00
sync.m Fixed LOCK() -> UNLOCK(). 2010-02-27 19:38:24 +00:00
thr.c Added new runtime library, based on GCC 4.4 libobjc, libobjc_tr and Objective2.framework. 2009-09-08 16:18:59 +00:00
unwind-pe.h Added missing declarations of exception-handling functions (from ABI spec). 2009-11-15 02:25:28 +00:00

GNUstep Objective-C Runtime
===========================

The GNUstep Objective-C runtime is based on the GCC runtime.  It supports both
a legacy and a modern ABI, allowing code compiled with old versions of GCC to
be supported without requiring recompilation.  The modern ABI adds the
following features:

- Non-fragile instance variables.
- Protocol uniquing.
- Object planes support.
- Declared property introspection.

Both ABIs support the following feature above and beyond the GNU runtime:

- The modern Objective-C runtime APIs, introduced with OS X 10.5.
- Blocks (closures).

Non-Fragile Instance Variables
------------------------------

When a class is compiled to support non-fragile instance variables, the
instance_size field in the class is set to 0 - the size of the instance
variables declared on that class (excluding those inherited.  For example, an
NSObject subclass declaring an int ivar would have its instance_size set to 0 -
sizeof(int).  The offsets of each instance variable in the class's ivar_list
field are then set to the offset from the start of the superclass's ivars.

When the class is loaded, the runtime library uses the size of the superclass
to calculate the correct size for this new class and the correct offsets.  Each
instance variable should have two other variables exported as global symbols.
Consider the following class:

@interface NewClass : SuperClass {
	int anIvar;
}
@end

This would have its instance_size initialized to 0-sizeof(int), and anIvar's
offset initialized to 0.  It should also export the following two symbols:

int __objc_ivar_offset_value_NewClass.anIvar;
int *__objc_ivar_offset_NewClass.anIvar;

The latter should point to the former or to the ivar_offset field in the ivar
metadata.  The former should be pointed to by the only element in the
ivar_offsets array in the class structure.  

In other compilation units referring to this ivar, the latter symbol should be
exported as a weak symbol pointing to an internal symbol containing the
compiler's guess at the ivar offset.  The ivar will then work as a fragile ivar
when NewClass is compiled with the old ABI.  If NewClass is compiled with the
new ABI, then the linker will replace the weak symbol with the version in the
class's compilation unit and references which use this offset will function
correctly.

If the compiler can guarantee that NewClass is compiled with the new ABI, for
example if it is declared in the same compilation unit, by finding the symbol
during a link-time optimization phase, or as a result of a command-line
argument, then it may use the __objc_ivar_offset_value_NewClass.anIvar symbol
as the ivar offset.  This eliminates the need for one load for every ivar
access.

Protocols
---------

The runtime now provides a __ObjC_Protocol_Holder_Ugly_Hack class.  All
protocols that are referenced but not defined should be registered as
categories on this class.  This ensures that every protocol is registered with
the runtime.  

In the near future, the runtime will ensure that protocols can be looked up by
name at run time and that empty protocol definitions have their fields updated
to match the defined version.

Protocols have been extended to provide space for introspection on properties
and optional methods.  These fields only exist on protocols compiled with a
compiler that supports Objective-C 2.  To differentiate the two, the isa
pointer for new protocols will be set to the Protocol2 class.

Fast Proxies and Cacheable Lookups
----------------------------------

The new runtime provides two mechanisms for faster lookup.  The older
Vobjc_msg_lookup() function, which returns an IMP, is still supported, however
it is no longer recommended.  The new lookup functions is:

Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender)

The receiver is passed by pointer, and so may be modified during the lookup
process.  The runtime itself will never modify the receiver.  The following
hook is provided to allow fast proxy support:

id (*objc_proxy_lookup)(id receiver, SEL op);

This function takes an object and selector as arguments and returns a new
objects.  The lookup will then be re-run and the final message should be sent to
the new object.

The returned Slot_t from the new lookup function is a pointer to a structure
which contains both an IMP and a version (among other things).  The version is
incremented every time the method is overridden, allowing this to be cached by
the caller.  User code wishing to perform IMP caching may use the old mechanism
if it can guarantee that the IMP will not change between calls, or the newer
mechanism.  Note that a modern compiler should insert caching automatically,
ideally with the aid of run-time profiling results.  To support this, a new hook
has been added:

Slot_t objc_msg_forward3(id receiver, SEL op);

This is identical to objc_msg_forward2(), but returns a pointer to a slot,
instead of an IMP.  The slot should have its version set to 0, to prevent
caching.

Object Planes
-------------

Object planes provide interception points for messages between groups of
related objects.  They can be thought of as similar to processes, with mediated
inter-plane communication.  A typical use-case for an object plane is to
automatically queue messages sent to a thread, or to record every message sent
to model objects.  Planes can dramatically reduce the number of proxy objects
required for this kind of activity.

The GNUstep runtime adds a flag to class objects indicating that their
instances are present in the global plane.  All constant strings, protocols,
and classes are in the global plane, and may therefore be sent and may receive
messages bypassing the normal plane interception mechanism.  

The runtime library does not provide direct support for planes, it merely
provides the core components required to implement support for planes in
another framework.  Two objects are regarded as being in the same plane when
they words immediately before their isa pointers are the same.  In this case,
the runtime's usual dispatch mechanisms will be used.  In all other cases, the
runtime will delegate message lookup to another library via the following hook:

Slot_t (*objc_plane_lookup)(id *receiver, SEL op, id sender);

From the perspective of the runtime, the plane identifier is opaque.  In
GNUstep, it is a pointer to an NSZone structure.

Threading
---------

The old threading layer is gone.  It was buggy, badly supported, and
inadequately tested.  The library now always runs in thread-safe mode.  The
same functions for locking the runtime mutex are still supported, but their use
any mutex not exported by the runtime library is explicitly not supported.  The
(private) lock.h header is now used to abstract the details of different
threading systems sufficiently for the runtime.  This provides mechanisms for
locking, unlocking, creating, and destroying mutex objects.  

Objective-C 2 Features
----------------------

The runtime now provides implementations of the functions required for the
@synchronized directive, for property accessors, and for fast enumeration.  The
public runtime function interfaces now match those of OS X.