Bug 120569 - [Mac] No need for HardAutorelease, which is same as CFBridgingRelease
Summary: [Mac] No need for HardAutorelease, which is same as CFBridgingRelease
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-31 21:46 PDT by Darin Adler
Modified: 2013-09-02 11:54 PDT (History)
12 users (show)

See Also:


Attachments
Patch (23.45 KB, patch)
2013-08-31 22:01 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (22.29 KB, patch)
2013-09-01 14:14 PDT, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2013-08-31 21:46:35 PDT
[Mac] Refine the HardAutorelease function and rename it BridgingAutorelease
Comment 1 Darin Adler 2013-08-31 22:01:03 PDT
Created attachment 210225 [details]
Patch
Comment 2 Darin Adler 2013-08-31 22:03:24 PDT
I wonder if we always have CFBridgingRelease on all Mac and iOS platforms and build environments we support. If so, then maybe we should just replacing HardRelease/BridgingRelease with CFBridgingRelease, adding null checks as needed and not worrying too much about the extra overhead for non-GC.
Comment 3 WebKit Commit Bot 2013-08-31 22:03:38 PDT
Attachment 210225 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/API/JSValue.mm', u'Source/JavaScriptCore/ChangeLog', u'Source/WTF/ChangeLog', u'Source/WTF/wtf/ObjcRuntimeExtras.h', u'Source/WebCore/ChangeLog', u'Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm', u'Source/WebCore/platform/mac/KURLMac.mm', u'Source/WebCore/platform/mac/WebCoreNSURLExtras.mm', u'Source/WebCore/platform/text/mac/StringImplMac.mm', u'Source/WebKit/mac/ChangeLog', u'Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm', u'Source/WebKit/mac/Misc/WebNSURLExtras.mm', u'Source/WebKit/mac/Plugins/WebBasePluginPackage.mm', u'Source/WebKit/mac/WebView/WebPDFRepresentation.mm', u'Source/WebKit/mac/WebView/WebView.mm', u'Source/WebKit2/ChangeLog', u'Source/WebKit2/Platform/mac/StringUtilities.mm', u'Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm', u'Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm', u'Tools/ChangeLog', u'Tools/DumpRenderTree/mac/DumpRenderTree.mm']" exit_code: 1
Source/WTF/wtf/ObjcRuntimeExtras.h:68:  Extra space before [  [whitespace/braces] [5]
Total errors found: 1 in 21 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Darin Adler 2013-08-31 23:18:36 PDT
I think I’ll need Anders’ help to decide whether to keep BridgingAutorelease or just start using CFBridgingRelease.
Comment 5 Anders Carlsson 2013-09-01 12:10:47 PDT
(In reply to comment #2)
> I wonder if we always have CFBridgingRelease on all Mac and iOS platforms and build environments we support. If so, then maybe we should just replacing HardRelease/BridgingRelease with CFBridgingRelease, adding null checks as needed and not worrying too much about the extra overhead for non-GC.

Where would we have to add null checks?

(In reply to comment #4)
> I think I’ll need Anders’ help to decide whether to keep BridgingAutorelease or just start using CFBridgingRelease.

I think we should just use CFBridgingRelease.
Comment 6 Darin Adler 2013-09-01 12:17:31 PDT
(In reply to comment #5)
> (In reply to comment #2)
> > I wonder if we always have CFBridgingRelease on all Mac and iOS platforms and build environments we support. If so, then maybe we should just replacing HardRelease/BridgingRelease with CFBridgingRelease, adding null checks as needed and not worrying too much about the extra overhead for non-GC.
> 
> Where would we have to add null checks?

I don’t know. That’s the problem. It requires studying each call site.

If any of the call sites are passing in something that can be null we’d need a null check. I don’t know, for example, which create functions can fail and return null and which ones can’t.

> (In reply to comment #4)
> > I think I’ll need Anders’ help to decide whether to keep BridgingAutorelease or just start using CFBridgingRelease.
> 
> I think we should just use CFBridgingRelease.

The three issues are:

1) Annoying to pay for CFMakeCollectable on non-GC platforms like iOS.
2) Not sure CFBridgingRelease is present on all Mac and iOS platforms we compile WebKit for.
3) Not sure where to add null checks.

I’ll start putting up patches that use CFBridgingRelease and I won’t rename HardAutorelease -- I’ll delete it instead.
Comment 7 Anders Carlsson 2013-09-01 12:23:58 PDT
(In reply to comment #6)
> The three issues are:
> 
> 1) Annoying to pay for CFMakeCollectable on non-GC platforms like iOS.

> 2) Not sure CFBridgingRelease is present on all Mac and iOS platforms we compile WebKit for.

It is present on Lion and newer AFIK.

> 3) Not sure where to add null checks.

I still don't understand where we'd need null checks now where we wouldn't before. It seems like both CFBridgingRetain and CFBridgingRelease handle null just fine.
Comment 8 Darin Adler 2013-09-01 12:27:47 PDT
(In reply to comment #7)
> It seems like both CFBridgingRetain and CFBridgingRelease handle null just fine.

The non-ARC version of CFBridgingRelease calls CFMakeCollectable unconditionally. I believe that won’t work on a null pointer. Am I wrong?
Comment 9 Andy Estes 2013-09-01 12:48:58 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > It seems like both CFBridgingRetain and CFBridgingRelease handle null just fine.
> 
> The non-ARC version of CFBridgingRelease calls CFMakeCollectable unconditionally. I believe that won’t work on a null pointer. Am I wrong?

Despite what our documentation says about CFMakeCollectable(), the current implementation of that function handles NULL correctly. I don't know if that's true on all the platforms we need to support, though.
Comment 10 Darin Adler 2013-09-01 12:50:03 PDT
Party time!
Comment 11 Darin Adler 2013-09-01 14:09:03 PDT
New title, new approach.
Comment 12 Darin Adler 2013-09-01 14:14:25 PDT
Created attachment 210256 [details]
Patch
Comment 13 Andy Estes 2013-09-01 16:18:35 PDT
Comment on attachment 210256 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=210256&action=review

> Source/JavaScriptCore/ChangeLog:3
> +        [Mac] No need for HardAutorelease, which is same as CFBridgingRelease

which is *the* same?
Comment 14 WebKit Commit Bot 2013-09-02 11:54:05 PDT
Comment on attachment 210256 [details]
Patch

Clearing flags on attachment: 210256

Committed r154963: <http://trac.webkit.org/changeset/154963>
Comment 15 WebKit Commit Bot 2013-09-02 11:54:09 PDT
All reviewed patches have been landed.  Closing bug.