Mac Apps That Use Garbage Collection Must Move to ARC

via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 23 00:27:49 PST 2015


On Monday, 23 February 2015 at 01:41:17 UTC, Adam D. Ruppe wrote:
> On Monday, 23 February 2015 at 01:38:35 UTC, Manu wrote:
>> All my ref counting types fiddle with the ref in every 
>> assignment, or every function call and return.
>
> Hmm, the optimizer could potentially tell "inc X; dec X;" is 
> useless and remove it without knowing what it is for.

INPUT:

try{
nonsharedobj._rc++;
…
}
finally {
nonsharedobj._rc--;
if(nonsharedobj._rc==0) destroy…
}

OPTIMIZED:

try{
…
}
finally {
if(nonsharedobj._rc==0) destroy…
}

----
Thanks to the messed up modular arithmetics that D has chosen you 
cannot assume the a non-shared live object does not have a rc==0 
due to wrapping integers, in the general case.


More information about the Digitalmars-d mailing list