108 Commits (455a4758f17061682599f12cd342e27251c8a281)

Author SHA1 Message Date
David Chisnall 22abbd2ca2 Fix a bug in hidden class deletion.
We were leaving the isa pointer pointing to the deleted class and were
then following its super_class pointer, both of which are potentially
serious.  This didn't show up on FreeBSD, because the relevant memory
was always returned to a thread-local pool and the accesses were
immediately afterwards, so it always worked.  It broke with malloc
implementations that were more aggressive about checking for
use-after-free.
8 years ago
David Chisnall 4e9fd2ec8a Rename objc_slot and objc_slot_v1.
The objc_slot type was exposed via public interfaces and the renaming
broke things (including the GNUstep build).
8 years ago
David Chisnall c865b519b0 Unregister classes when deleting them.
Coverage checking of the test suite showed that objc_disposeClassPair
wasn't tested at all, which then led to discovering that it didn't
unregister the class.
8 years ago
David Chisnall b81df02b91 Merge branch 'master' into newabi
Simplify the setSubclass dtable updating mechanism.
8 years ago
David Chisnall 8021533d4c Don't allocate objects of size 0.
There's nowhere for the class pointer, so there's nothing that you can
do with them.
8 years ago
David Chisnall a4f97f7563 Refactor locking in setSuperclass.
Now all lock ownership is tied to scopes, so will be released correctly
in all return paths.
8 years ago
Dustin Howett d32bafc6e1 Let go of the runtime lock properly in class_setSuperclass 8 years ago
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
Dustin Howett d66d6e5a14 Fix a warning in runtime.c 8 years ago
Dustin Howett 82d4d3fbfd merge dtables inplace, don't hold rt lock while initializing 8 years ago
Dustin L. Howett a421d62821 teach class_setSuperclass about metaclasses, subclass lists, and dtables 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