98 Commits (4891eb9d5f1201ed833ec4d3dbf7fcac0f6e3cc6)

Author SHA1 Message Date
David Chisnall 11637010ad Rename method_list.h to method.h
Work around the fact that LaTeX really doesn't like file names with
underscores...
8 years ago
David Chisnall c0f56a75a0 Modify ivar flags.
Add a flag to indicate that instance variables have an extended type
encoding.

Remove the alignment field and replace it with 6 bits from the flags
field.  We only support power of two alignments, so we may as well store
them in log form, which means we can save a field.  Note that this
doesn't actually save us any space except on 32-bit platforms, because
alignment means that we end up with extra padding at the end of the
struct.
8 years ago
David Chisnall 4036a88936 Remove separate flags for class and metaclass.
Every class is either a class or a metaclass, it doesn't make sense to
use two flags to store one bit of data.

Also remove the newabi flag from classes in the v2 ABI, where it's
redundant.
8 years ago
David Chisnall c4ff744620 Audit the runtime for direct access to variable-sized arrays.
Several of the structures now end with an array of structures that may
have other fields added to them that the runtime doesn't know about yet
by a compiler.  Rather than indexing into them directly, we must call an
accessor to find the correct address.

A few of the places where accesses were replaced were in functions where
it is safe because they only deal with versions of the structures that
are dynamically allocated (and will therefore have the correct size).
This was done to simplify future auditing: these fields should be
accessed directly only from the accessor functions in the header and
from the upgraders (currently in legacy.c).

Also fix a few bugs where the sizes weren't being filled in.
8 years ago
David Chisnall ee1c6ad661 Fix inefficient ivar offset allocation. 8 years ago
David Chisnall 65b34a196f Add support for improved property structure.
As a side effect, we need to upgrade properties in class and protocols
(but not categories because we didn't have class properties in earlier
ABIs).
8 years ago
David Chisnall a8752cd842 Clean up method / slot lookup interfaces. 8 years ago
David Chisnall a9a2ed6b10 Refactor to use `objc_method` as the slot.
This change set incorporates a number of changes that all needed to
happen together:

 * The imp is now the first field of the `objc_method` structure.  This
   makes it possible to extend the structure without breaking anything
   that relies on being able to access the IMP.
 * There is no owner in the slot, so we must use other mechanisms for
   determining the owner of a method (e.g. whether the same method appears
   in the superclass)
 * Again, because there is no owner in the slot, we can't use this as a
   fast path for finding the C++ construct / destruct methods.  These are
   now cached in the class structure when they are found.
 * The version field is gone from the slot and now we provide a global
   version.  This is based on the observation that method replacements
   are relatively infrequent and the overhead of invalidating all method
   caches is cheaper than adding extra state for every (class, method)
   pair.
 * A number of the runtime functions are simplified because replacing
   the IMP in a `Method` now implicitly updates the dtable.
8 years ago
David Chisnall 0964d63ba9 Update for the compiler / linker setting up superclass pointers.
In the legact ABI, superclass pointers are initially set to strings
containing the superclass name and the runtime fixes them up.  In the
new ABI, the compiler sets up the linkage directly.
8 years ago
David Chisnall f91fb2e745 Checkpoint more work on new ABI.
We're now using a new class and category structure and auto-upgrading the old ones.  Other changes:

- The Ivar structure now points to the ivar offset variable, so we can more easily find it.
- Categories can now add properties.
8 years ago
David Chisnall a54272c1ab Merge origin/master into newabi (using imerge) 8 years ago
David Chisnall 21efe9e259 Update dtables for metaclasses when exchanging methods.
Fixes #32
9 years ago
David Chisnall f9421d02a8 Add a size field to the ivar list struct, for forward compatibility. 10 years ago
David Chisnall c3c81796ca Rework slot handling so that the fields that are used for dispatch are
at the start of the structure, making it easier to change the layout in
the future.

Also clean up the growth of various fields and consolidate some of the
metadata into a pointer to the `struct objc_method`.
10 years ago
David Chisnall 3dc096eb17 Add new ABI ivar metadata structures.
The new structure has extra fields for alignment and flags (e.g.
ownership).
Old structures are auto-upgraded at load time, so the rest of the code
can assume the presence of the new structure type.
10 years ago
David Chisnall d44bf5655b Ensure that objects that support ARC will use ARC, even if they are
created without sending a message to the class.

Also ensure that protocols are always valid objects so that ARC doesn't
become confused.
10 years ago
David Chisnall 53bc9f3892 Fix the size of run-time generated root classes.
The size of the new class with should be sizeof(Class), not sizeof(struct objc_class).
10 years ago
rfm 7f007e354e fix bug in small object test on 64bit systems 12 years ago
theraven 1a76a2a021 Handle the case where the alignment of a new ivar is 0.
Reported by: Lubos Dolezel
13 years ago
theraven aad22cb092 Fix method_setImplementation bug. 13 years ago
theraven ffa7dbad8d Cleaner version of the last fix. 13 years ago
theraven fb2e6756f6 Fix (and add test case for) a bug where objc_allocateClassPair() failed if the
superclass had not yet been loaded.
13 years ago
theraven 7a232c68d6 Fix typo in .cxx_construct.
Reported by Luboš Doležel!
13 years ago
thebeing 8cf9b6058b Attempt to fix objcAllocateClassPair() for root classes.
@David: Could you check whether I got this right?
14 years ago
theraven 9fae0d1f48 Silence a warning on SPARC64. 14 years ago
theraven 5d3c047fa2 Finished implementing JavaScript-style prototypes. 15 years ago
theraven b54719abf1 Basic support for prototype-style object orientation (you can now add methods to an individual object). 15 years ago
theraven 6a27408e9e Fix malloc() / free() imbalance. 15 years ago
theraven 8af52846b7 Small object (hidden in a pointer) support. 15 years ago
theraven 83db079968 Fix bug in fast path for class_getInstanceMethod() 15 years ago
theraven 65d6a8dfb5 When changing the size of structures, it's a good idea to make sure that you change everything that depends on those sizes too... 15 years ago
theraven 219f921bc3 Fix some bugs in class_getInstanceMethod() 15 years ago
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.
15 years ago
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. 15 years ago
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. 15 years ago
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.
15 years ago
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.
15 years ago
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.
15 years ago
theraven 535ba87a8e Store the selector, not the type encoding, in slots. 15 years ago
theraven 7b49755964 Dtable cleanup cleanups. 15 years ago
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. 15 years ago
theraven 4ee1b1f4ac Test first, then commit... 15 years ago
theraven faa741b133 Added some header documentation for runtime functions. 15 years ago
theraven 7336df75bc Added some more comments, C++ include guards around runtime.h. 15 years ago
theraven 28e6960441 Make object_getIndexedIvars() more robust against compiler bugs. 15 years ago
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. 15 years ago
theraven 4a3326f2fd Fix class_getMethodImplementation() semantics for Apple compatibility (returns forwarding selector IMP, doesn't actually do the forwarding). 15 years ago
theraven 91e9758fda Add lots of checks for NULL-pointer arguments to runtime functions. 15 years ago
ericwa a7ea477400 libobjc2: put libobjc compatibility functions in runtime.h marked __attribute__((deprecated)) 15 years ago
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.
15 years ago