Looks like this should go into the O-C DIP.

On 6/29/2013 5:38 AM, Michel Fortin wrote:
>
> Implementing ARC for Objective-C is going to require some more compiler support anyway (for autoreleased objects notably). Tweaking the compiler it so accepts Objective-C interfaces should just be a matter of tweaking the boolean expression that makes this check. "if (classdelc->objc && interfacedecl->objc) return true;" or something like that.
>
> As for which function the compiler should call, it'll probably need to be special-cased for Objective-C in the compiler too. Here's the list of changes that'd be needed for Objective-C ARC:
>
> == Retain ==
> COM:  if (obj) obj->AddRef();
> ObjC: obj = objc_retain(obj);
> ObjC blocks: obj = objc_retainBlock(obj); // objc_retainBlock might do a copy
>
> == Release ==
> COM:  if (obj) obj->Release();
> ObjC: objc_release(obj);
>
> == Assignment ==
> COM:  if (obj) obj->AddRef(); if (var) var->Release(); var = obj;
> ObjC: objc_storeStrong(&var, obj);
> ObjC blocks: obj = objc_retainBlock(obj); objc_release(var); var = obj;
>
> As long as Walter implements D ARC in a way we can make the above substitutions it shouldn't be too hard.
>
> Then, support for autorelease is a matter of calling objc_autorelease on returned objects from autoreleasing functions, followed by objc_retain after the function call in the caller. We'll also have to check what ObjC ARC does for pointer write-backs to autoreleased variables and mimick that.
>
> There's an optimized path for autoreleased return values that we should use, but I'd defer that to later. It involves a special no-op instruction to insert at the right place as a flag. Also, autoreleased returns should be eliminated when inlining.
>

Reply via email to