Commit Graph

32 Commits

Author SHA1 Message Date
theraven
193629d8a2 Fix a bug with blocks in ARC mode being incorrectly released. 2013-03-12 08:51:59 +00:00
theraven
95aef24803 Fix crash in ARC assignment.
Reported by Banlu Name-of-the-week!
2013-01-05 16:13:23 +00:00
theraven
3649fe37ec Fix while -> if bug introduced when refactoring ARC code which caused infinite
loop.

Reported by Tom Davie.
2012-10-23 08:27:42 +00:00
theraven
e7ab10611f ARC fix for blocks. 2012-08-19 09:17:12 +00:00
theraven
8e023f0063 Fix case where more than 4 weak references to the same object would cause infinite loops.
Patch by Thomas Davie!
2012-06-18 16:01:40 +00:00
theraven
6f1589a841 Some bug fixes to ARC autorelease pools. Now provides all of the support required for implementing GNUstep autorelease pools. 2012-04-06 11:58:14 +00:00
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,
2012-04-05 16:37:48 +00:00
theraven
6be416ca32 Some cleanups to ARC autorelease pools. 2011-11-14 14:36:16 +00:00
theraven
55d86bba6c Blocks cleanups. 2011-08-07 15:41:46 +00:00
theraven
f3d2b7034c Small object + ARC tweaks. 2011-07-26 17:56:37 +00:00
theraven
8af52846b7 Small object (hidden in a pointer) support. 2011-07-26 17:39:13 +00:00
theraven
fceec26cb7 Fix bug assigning weak references. 2011-07-23 15:34:00 +00:00
theraven
dfbf18cc67 Fixed <= bug in weak references. We're storing the EXTRA retain count, not the refcount. 2011-07-16 17:00:23 +00:00
theraven
e69ed0696d Better recovery when things are done in the wrong order. 2011-07-11 13:55:16 +00:00
theraven
52fb301a45 Move return statement into the conditional, where it belongs. 2011-07-06 16:40:46 +00:00
theraven
0b9e0fd295 Added fast implementation of autorelease pools for ARC. 2011-07-06 11:00:00 +00:00
theraven
a255dcd2d1 ...and fix dereferencing of NULL pointer introduced with last commit. 2011-07-05 09:05:54 +00:00
theraven
e7a6be5584 Tighten up loading of __weak variables slightly. 2011-07-05 09:03:37 +00:00
theraven
d61e9b3209 Fix __weak references to blocks. 2011-07-04 23:27:29 +00:00
theraven
126aa409cb op_and_fetch, not fetch_and_op! 2011-07-04 21:26:11 +00:00
theraven
61bc10ad4c Remove debugging line accidentally committed. 2011-07-04 16:43:38 +00:00
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.
2011-07-04 15:04:56 +00:00
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.
2011-07-04 12:22:23 +00:00
theraven
f6923d7472 Improve objc_moveWeak() implementation. 2011-07-04 11:57:13 +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
6a37a8c3bc More ARC tweaks. 2011-06-30 14:16:52 +00:00
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. 2011-06-30 12:56:59 +00:00
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.
2011-06-30 09:24:14 +00:00
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
2011-06-29 13:12:02 +00:00
theraven
065531b12e Remove accidentally-committed WIP ARC code. 2011-06-29 12:04:47 +00:00
theraven
b633338a7a Remove indirection from alias table. 2011-06-29 12:03:41 +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