51 Commits (d015f0160cfeb3097c8d2321c0bfc648c0885047)

Author SHA1 Message Date
David Chisnall d015f0160c Rename PUBLIC to OBJC_PUBLIC to avoid some namespace pollution. 7 years ago
David Chisnall abf629b1f7 Make some private symbols private. 7 years ago
David Chisnall d4278a009c Fix an integer underflow bug.
We weren't correctly sign-extending the value being compared, which was
resulting in objects not being deallocated.  For some reason, this only
appeared on Windows, even though the code looked wrong on all platforms.
8 years ago
David Chisnall 934cd13a7a Initial pass at Windows support.
All tests now pass with the new ABI on x86-64, with the new ABI.  Some
of the code is ugly and other platforms are probably broken.
8 years ago
David Chisnall 8eb06a3b15 Improve ARC test and fix bugs it uncovered.
This cleans up handling of objects that are not reference counted and
makes their interactions with ARC more consistent.  We should probably
generalise this somewhat - it currently special cases NSConstantString
and NSGlobalBlock, but it would be nice to have an API for constant
objects.
8 years ago
David Chisnall c6aaf560c1 Fix dangling reference in weak ref code.
Another test added as a result of coverage analysis.
8 years ago
Dustin L. Howett 430ab75014 win32: use native threading APIs instead of pthreads
* use fiber local storage if NO_PTHREADS is defined
* use critical sections instead of mutexes

Contributing-author: Ben Viglietta <benvi@microsoft.com>
8 years ago
David Chisnall 24f3713a4b Fix a bug in weak ref handling.
Weak refs were being left as dangling pointers after being deleted.  The
load that caused the deallocation would return nil, but then the next
one would dereference a dangling pointer.
8 years ago
David Chisnall 12b820cb99 Add refcount accessor function. 8 years ago
David Chisnall e5b4468867 Improve copying and moving weak refs.
Fixes a bug introduced (replacing a similar bug) in the last rewrite of
objc_moveWeak.  This version should now be correct.

objc_copyWeak was implemented in a naive way, which had a lot more
overhead than required.
8 years ago
David Chisnall 458bd3c7a2 Add interfaces for better integration with Foundation. 8 years ago
David Chisnall fe579e3f1a Simplify the weak code.
Rather than tracking all of the locations of weak pointers, keep a weak
refcount.  This should also make it easier to add finer-grained locking to weak
references.
8 years ago
David Chisnall af4e0719ff Checkpoint work on improving weak reference efficiency. 8 years ago
David Chisnall 6de70135e8 Don't abort if NSAutoreleasePool is not found.
Fixes #17
10 years ago
David Chisnall 3135e30d71 Fix ARC assignment of blocks.
We were not correctly checking that the object being assigned had a
reference count in the object header.  We're also now avoiding assigning
small objects to the weak reference table, which is quite important as
they have no destructor.

Fixes #12
10 years ago
theraven bd0728f393 Fix a bug in weak reference handling, where weak refers were being removed from
the table incorrectly, causing objects inserted at offsets due to hash
collisions to fail to be moved up and then fail to be found later.

Test by Eric Wasylishen!
12 years ago
theraven 2c81ee0428 Allow ARC to correctly handle references to self from blocks within -dealloc. 12 years ago
theraven 76a88312dd Work around GNUstep's inability to initialise NSAutoreleasePool without
performing recursive autoreleases (introduced in r37479).
Fixes crashing of C++ static constructors.
12 years ago
theraven 8979f19f1d Fix some bugs in protocol property introspection and remove a redundant #define.
Reported by Krystof Vasa!
13 years ago
theraven 193629d8a2 Fix a bug with blocks in ARC mode being incorrectly released. 13 years ago
theraven 95aef24803 Fix crash in ARC assignment.
Reported by Banlu Name-of-the-week!
13 years ago
theraven 3649fe37ec Fix while -> if bug introduced when refactoring ARC code which caused infinite
loop.

Reported by Tom Davie.
13 years ago
theraven e7ab10611f ARC fix for blocks. 14 years ago
theraven 8e023f0063 Fix case where more than 4 weak references to the same object would cause infinite loops.
Patch by Thomas Davie!
14 years ago
theraven 6f1589a841 Some bug fixes to ARC autorelease pools. Now provides all of the support required for implementing GNUstep autorelease pools. 14 years ago
theraven 4f51f9cd05 When using the runtime's internal autorelease pool implementation, just pop the
top object off when attempting to retain an autoreleased return value,
14 years ago
theraven 6be416ca32 Some cleanups to ARC autorelease pools. 14 years ago
theraven 55d86bba6c Blocks cleanups. 15 years ago
theraven f3d2b7034c Small object + ARC tweaks. 15 years ago
theraven 8af52846b7 Small object (hidden in a pointer) support. 15 years ago
theraven fceec26cb7 Fix bug assigning weak references. 15 years ago
theraven dfbf18cc67 Fixed <= bug in weak references. We're storing the EXTRA retain count, not the refcount. 15 years ago
theraven e69ed0696d Better recovery when things are done in the wrong order. 15 years ago
theraven 52fb301a45 Move return statement into the conditional, where it belongs. 15 years ago
theraven 0b9e0fd295 Added fast implementation of autorelease pools for ARC. 15 years ago
theraven a255dcd2d1 ...and fix dereferencing of NULL pointer introduced with last commit. 15 years ago
theraven e7a6be5584 Tighten up loading of __weak variables slightly. 15 years ago
theraven d61e9b3209 Fix __weak references to blocks. 15 years ago
theraven 126aa409cb op_and_fetch, not fetch_and_op! 15 years ago
theraven 61bc10ad4c Remove debugging line accidentally committed. 15 years ago
theraven 73891aaecc Two small ARC fixes:
- Make objc_retain() check for stack blocks and implicitly copy them.  This fixes the case where a block pointer is stored in an object-typed variable and is assigned.
- Tweak objc_retainAutoreleaseReturnValue() so that the ARC optimiser doesn't detect that the body looks like a call to objc_retainAutoreleaseReturnValue() and replace it with an infinitely recursive call.

The second fix now means that arc.m will compile with clang without producing a function that calls itself.
15 years ago
theraven 9d6154041c Make sure that autoreleased returned objects are destroyed when the autorelease
pool is destroyed.  They were previously being destroyed on thread termination,
this ensures that their lifespan is predictable.
15 years ago
theraven f6923d7472 Improve objc_moveWeak() implementation. 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 6a37a8c3bc More ARC tweaks. 15 years ago
theraven 55191e34ae Fix the fast path. It should fall back to doing what the slow path does if the other half is not using it. 15 years ago
theraven e3c836b090 Added fast path for objc_autoreleaseReturnValue() and objc_retainAutoreleasedReturnValue().
In a simple example:

- foo { return self; }

void someFunction(void)
{
	id a = foo;
	...
}

In ARC mode, this expands to:

- foo { return objc_retainAutoreleaseReturnValue(self); }

void someFunction(void)
{
	id a = objc_retainAutoreleasedReturnValue(foo);
	...
}

In the slow path, this is equivalent to:

- foo { return [[self retain] autorelease]; }

void someFunction(void)
{
	id a = [foo retain];
	...
	[a release];
}

The fast path skips the autorelease / retain pair.  The return value is stored
in thread-local storage temporarily and then retrieved, the retain balancing
out the autorelease.

This gives a 50% speedup on a single thread.  It also avoids some atomic
operations.
15 years ago
theraven bc87ed22e1 Implemented support for __weak with ARC.
ARC functions are all now exposed in a header, but not yet documented.  See the ARC ABI spec for now:

http://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime
15 years ago
theraven 065531b12e Remove accidentally-committed WIP ARC code. 15 years ago
theraven b633338a7a Remove indirection from alias table. 15 years ago