66 Commits

Author SHA1 Message Date
theraven
7b6ba21ce5 Small bug fixes:
- Don't call C++ constructors if they don't exist.
- Don't check the owner of retain / release methods if they are not implemented.
- Add arc.m as a file to ignore when checking for GC compatibility.
2011-07-04 11:28:33 +00:00
theraven
34f7baf8d7 Added a fast path for ARC. Now, if a class implements ARC-compatible retain / release / autorelease methods, we don't call them at all. Instead, we inline them in the ARC accessors. This avoids all of the overhead of the message send (lookup and call) and should make ARC quite a bit faster than manual reference counting. 2011-07-03 11:14:29 +00:00
theraven
9b70b22eee Use __unsafe_unretained instead of const for returning protocol arrays. Let's not break everyone's code, even if we really want to. 2011-06-29 10:12:29 +00:00
theraven
b5380d50d3 Added support for ARC.
Weak references are still not supported, but code that doesn't use them (i.e. any code that wants to be compatible with OS X 10.6) will work fine.

The current implementation is VERY inefficient and has a large number of missed optimisation opportunities: this is the 'make it right' phase, and should be almost equivalent to explicit retain / release code.
2011-06-28 16:29:42 +00:00
theraven
ad16172625 First pass at implementing Apple-compatible GC using Boehm. Still needs some tidying, but the following work:
- __strong pointers, preventing objects from being freed

_ __weak pointers are automatically freed when the last remaining __strong pointer goes away

- objc_gc_{retain,release}_np() functions, which can be used to implement CFRetain() and CFRelease() (adds an reference count - the object will not be collected until after its last retain is gone.
2011-05-22 23:02:04 +00:00
theraven
d12de81cd6 Remove opts from default build - they must now be explicitly built.
Don't crash if objc_disposeClassPair() is called on a class that is not get
registered with the runtime.
2011-05-04 12:53:04 +00:00
theraven
535ba87a8e Store the selector, not the type encoding, in slots. 2011-04-22 12:13:28 +00:00
theraven
7b49755964 Dtable cleanup cleanups. 2011-04-19 10:55:10 +00:00
theraven
d51500184c More cleanups. Stop using __ identifiers for internal stuff now that it's properly marked private and we don't have to worry about conflicts. 2011-04-14 16:44:34 +00:00
theraven
4ee1b1f4ac Test first, then commit... 2011-03-22 12:36:47 +00:00
theraven
faa741b133 Added some header documentation for runtime functions. 2011-03-21 23:54:42 +00:00
theraven
7336df75bc Added some more comments, C++ include guards around runtime.h. 2011-03-21 18:31:25 +00:00
theraven
28e6960441 Make object_getIndexedIvars() more robust against compiler bugs. 2011-02-22 00:31:43 +00:00
theraven
94e5f7b344 Return "nil" instead of nil from class_getName with a nil argument. This is stupid (what happens if you have a class called nil?) but it is what OS X does. 2011-02-21 13:47:12 +00:00
theraven
4a3326f2fd Fix class_getMethodImplementation() semantics for Apple compatibility (returns forwarding selector IMP, doesn't actually do the forwarding). 2011-02-20 00:00:12 +00:00
theraven
91e9758fda Add lots of checks for NULL-pointer arguments to runtime functions. 2011-02-13 11:06:25 +00:00
ericwa
a7ea477400 libobjc2: put libobjc compatibility functions in runtime.h marked __attribute__((deprecated)) 2010-11-23 20:03:57 +00:00
qmathe
9dbf872f33 Fixed crash when resolving user-allocated classes (e.g. KVO) revealed by r31482.
objc_resolve_class() does ((Class)objc_getClass((char*)cls->isa->isa))->isa;
but cls->isa->isa was a metaclass object and not a C string if the class was 
user-created. objc_allocateClassPair() has been changed to set the 
meta-metaclass as a C string and not an object, so that objc_getClass() does 
not return Nil.
2010-10-05 14:57:07 +00:00
theraven
76bb7762ff Properly resolve the metaclass's isa pointer. 2010-10-04 22:33:30 +00:00
theraven
7be9f34619 Fixed @synchronize() with a class that has had an instance used for @synchronize(). 2010-10-04 17:44:17 +00:00
ericwa
d56930241e Stylistic fixes 2010-09-26 19:39:39 +00:00
ericwa
ed1c9d41eb libobjc2: Add a pile of NULL checks. In general, any public function should be able to handle NULL for any object/class/selector/pointer to opaque structure without blowing up. 2010-09-25 20:56:19 +00:00
theraven
84fd691944 Make adding more than one ivar with class_addIvar() work... 2010-09-18 18:23:49 +00:00
theraven
e1562b28d4 Correctly calculate the offset when adding ivars. 2010-09-18 16:33:34 +00:00
theraven
108247eb5d Fix dead store (the only bug found by the clang static analyser). 2010-09-09 10:19:09 +00:00
theraven
fe566cbc2f Fix introspection with type-dependent dispatch enabled. Looking up a method with an untyped selector was failing because the UID for the selector was no longer the same for all type variants.
As a side-effect of this change, method lookups for introspection are now much faster.  They use the slot lookup mechanism to find which class has the method declared and then only need to do the linear search on that class, rather than doing the linear search on the entire hierarchy (slow!).  If the method is not present, then they can give up after two memory accesses, rather than after searching a few hundred list entries, but that's a less important case.

I also noticed while tracking down this bug that the implementation of methodSignatureForSelector in GNUstep is very inefficient.  I'll tweak that next.
2010-09-02 14:52:35 +00:00
theraven
779b28abeb Lots of tidying, removing legacy stuff. 2010-06-06 21:11:25 +00:00
theraven
4ee07676cc Added rewritten encoding parser. The functions that function pointers as arguments and parse compound types should be exposed via the public interfaces, or possibly moved to a separate library - they are generally useful. 2010-06-04 23:40:07 +00:00
theraven
b1b9baf382 Finished rewrite of message sending. Deleted lots of legacy stuff. 2010-06-03 15:17:12 +00:00
theraven
de71ebb6b1 Rewritten class loading. 2010-06-01 19:41:07 +00:00
theraven
7f6f798074 Rewrote some of the class table code to be slightly cleaner. 2010-06-01 12:59:57 +00:00
theraven
a692cbd4dd Fix some GCC warnings. Patch by TOM. 2010-05-20 11:44:58 +00:00
theraven
b04cccf46b Fixed some issues in runtime.c when looking up methods. This fixes some issues with DO.
Removed GNU dtable and sparse array implementations, replaced entirely now with versions based on the Étoilé runtime.  Performance is roughly equivalent in microbenchmarks, memory usage is significantly lower (Gorm goes from 95MB to 50MB on my machine - this will be even more pronounced on 64-bit systems), which should improve cache usage considerably.  Still room for some performance tuning, however.
2010-05-16 20:39:54 +00:00
theraven
2d84b96a72 Tidied up some bits by creating private headers for private data structures.
Imported selector table code frm the Étoilé runtime.  We can now make dispatch type dependent with a -D switch.  Not enabled yet, but it will be enabled in a warning mode soon - I consider preferable to the existing GNU and Apple solution of corrupting the stack.
2010-05-13 22:29:56 +00:00
theraven
d9ead92cb3 Fixed bug in allocating metaclasses for lock classes. 2010-03-26 16:12:21 +00:00
theraven
023184f4b5 Removed unused static function. 2010-03-13 18:48:24 +00:00
theraven
ff7af18060 Correctly handle getting the name of nil. For some given value of correct, where 'correct' means 'compatible with the Apple behaviour' and not 'actually sensible'. 2010-03-13 13:01:53 +00:00
theraven
a35ece500f Rewrote objc_getClassList() to use class table directly.
Fixed missing UNLOCK() from last commit.
2010-03-13 01:45:24 +00:00
theraven
0abdc2a574 Small cleanups from last commit. 2010-03-12 22:59:36 +00:00
rfm
5eb97d0e38 fix missing line 2010-03-04 10:31:41 +00:00
rfm
76845ff81c fix wrong commit 2010-03-04 09:21:54 +00:00
rfm
b7963e23a6 backport class data copying fixes from ObjectiveC2 2010-03-04 08:15:43 +00:00
rfm
e2f4f38e45 backport bugfixes from ObjectiveC2 code 2010-03-03 09:34:45 +00:00
rfm
bf92e25952 match ivar lookup with osx and compatibility library 2010-02-28 17:26:41 +00:00
rfm
607bc433c9 Fix instance variable lookup to match OSX 2010-02-28 17:23:02 +00:00
theraven
719b540317 Set resolve / initialize flags for new metaclasses. 2010-02-27 23:12:50 +00:00
theraven
ae11414b4d Handle case where @synchronized is used with a class. 2010-02-27 18:24:03 +00:00
theraven
d4fe4f522e Fixed typo in comment in runtime.c.
Fixed unsafe dtable access in message lookup.
2010-02-25 16:32:31 +00:00
rfm
0e7441570b fixup bad function prototype 2010-02-25 09:23:28 +00:00
rfm
fb97e23e50 fix class_respondsToSelector() 2010-02-24 10:21:25 +00:00