Bug 146556

Summary: Drop RefPtr::clear() method
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web Template FrameworkAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, beidson, commit-queue, darin, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP Patch
none
WIP Patch
none
WIP Patch
none
Patch
none
WIP Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2015-07-02 12:39:43 PDT
Drop RefPtr::clear() method as we are instructing people to use "= nullptr" pattern instead.
Comment 1 Chris Dumez 2015-07-02 12:41:03 PDT
Created attachment 256024 [details]
WIP Patch
Comment 2 Chris Dumez 2015-07-02 13:02:54 PDT
Created attachment 256026 [details]
WIP Patch
Comment 3 Chris Dumez 2015-07-02 13:14:49 PDT
Created attachment 256027 [details]
WIP Patch
Comment 4 Chris Dumez 2015-07-02 13:54:17 PDT
Created attachment 256031 [details]
Patch
Comment 5 Brady Eidson 2015-07-02 14:20:38 PDT
I think this is a super great thing to do, and even started poking around it myself.

I did notice that the mechanics behind operator=(T*) and .clear() are subtly different, and I wasn't able to immediately convince myself there was 0-risk of a change in performance characteristics.

I brought this up to Chris on IRC, and I believe he's digging in more detail.
Comment 6 Darin Adler 2015-07-02 14:27:34 PDT
If there is any performance cost to using operator= we can overload it for std::nullptr_t.
Comment 7 Chris Dumez 2015-07-02 14:28:55 PDT
(In reply to comment #6)
> If there is any performance cost to using operator= we can overload it for
> std::nullptr_t.

Right. I'll benchmark locally to confirm if there is a noticeable performance difference between clear() and our current operator=(T*).
Comment 8 Chris Dumez 2015-07-03 19:09:38 PDT
Created attachment 256126 [details]
WIP Patch
Comment 9 WebKit Commit Bot 2015-07-03 19:12:40 PDT
Attachment 256126 [details] did not pass style-queue:


ERROR: Source/WebKit/Storage/StorageAreaSync.cpp:91:  One space before end of line comments  [whitespace/comments] [5]
Total errors found: 1 in 187 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Chris Dumez 2015-07-03 19:36:37 PDT
Created attachment 256127 [details]
Patch
Comment 11 Chris Dumez 2015-07-03 20:13:58 PDT
Created attachment 256129 [details]
Patch
Comment 12 Chris Dumez 2015-07-03 20:36:29 PDT
Created attachment 256130 [details]
Patch
Comment 13 Chris Dumez 2015-07-03 20:40:43 PDT
Created attachment 256131 [details]
Patch
Comment 14 Chris Dumez 2015-07-03 20:52:39 PDT
Created attachment 256132 [details]
Patch
Comment 15 Chris Dumez 2015-07-03 21:05:06 PDT
Created attachment 256133 [details]
Patch
Comment 16 Chris Dumez 2015-07-03 21:22:45 PDT
Created attachment 256134 [details]
Patch
Comment 17 Chris Dumez 2015-07-03 21:28:15 PDT
Created attachment 256135 [details]
Patch
Comment 18 Chris Dumez 2015-07-03 21:36:34 PDT
Created attachment 256136 [details]
Patch
Comment 19 Brady Eidson 2015-07-03 22:19:37 PDT
GETTING SO CLOSE!

Damned Windows build!
Comment 20 Chris Dumez 2015-07-03 22:21:33 PDT
(In reply to comment #19)
> GETTING SO CLOSE!
> 
> Damned Windows build!

No no, the Windows EWS issue is unrelated :) The patch is ready.
Comment 21 Brady Eidson 2015-07-03 23:11:03 PDT
Really?

https://webkit-queues.appspot.com/results/5659624707457024

c:\cygwin\home\buildbot\webkit\source\webcore\dom\Position.h(95): error C2039: 'clear' : is not a member of 'WTF::RefPtr<WebCore::Node>' (..\page\win\EventHandlerWin.cpp) [C:\cygwin\home\buildbot\WebKit\Source\WebCore\WebCore.vcxproj\WebCore.vcxproj]
c:\cygwin\home\buildbot\webkit\source\webcore\dom\RangeBoundaryPoint.h(115): error C2039: 'clear' : is not a member of 'WTF::RefPtr<WebCore::Node>' (..\page\win\EventHandlerWin.cpp) [C:\cygwin\home\buildbot\WebKit\Source\WebCore\WebCore.vcxproj\WebCore.vcxproj]
c:\cygwin\home\buildbot\webkit\source\webcore\dom\RangeBoundaryPoint.h(117): error C2593: 'operator =' is ambiguous (..\page\win\EventHandlerWin.cpp) [C:\cygwin\home\buildbot\WebKit\Source\WebCore\WebCore.vcxproj\WebCore.vcxproj]

etc etc.
Comment 22 Chris Dumez 2015-07-03 23:17:30 PDT
(In reply to comment #21)
> Really?
> 
> https://webkit-queues.appspot.com/results/5659624707457024
> 
> c:\cygwin\home\buildbot\webkit\source\webcore\dom\Position.h(95): error
> C2039: 'clear' : is not a member of 'WTF::RefPtr<WebCore::Node>'
> (..\page\win\EventHandlerWin.cpp)
> [C:\cygwin\home\buildbot\WebKit\Source\WebCore\WebCore.vcxproj\WebCore.
> vcxproj]
> c:\cygwin\home\buildbot\webkit\source\webcore\dom\RangeBoundaryPoint.h(115):
> error C2039: 'clear' : is not a member of 'WTF::RefPtr<WebCore::Node>'
> (..\page\win\EventHandlerWin.cpp)
> [C:\cygwin\home\buildbot\WebKit\Source\WebCore\WebCore.vcxproj\WebCore.
> vcxproj]
> c:\cygwin\home\buildbot\webkit\source\webcore\dom\RangeBoundaryPoint.h(117):
> error C2593: 'operator =' is ambiguous (..\page\win\EventHandlerWin.cpp)
> [C:\cygwin\home\buildbot\WebKit\Source\WebCore\WebCore.vcxproj\WebCore.
> vcxproj]
> 
> etc etc.

Weird, I missed those when I looked. I'll fix them, thanks.
Comment 23 Chris Dumez 2015-07-03 23:34:17 PDT
Created attachment 256139 [details]
Patch
Comment 24 Brady Eidson 2015-07-04 08:08:29 PDT
Comment on attachment 256139 [details]
Patch

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

> Source/JavaScriptCore/parser/Parser.cpp:494
> +        lastPattern = TreeDestructuringPattern(0);

Is this one necessary?

> Source/JavaScriptCore/parser/Parser.cpp:897
> +            pattern = TreeDestructuringPattern(0);

Or this one?
Comment 25 Brady Eidson 2015-07-04 08:09:19 PDT
Comment on attachment 256139 [details]
Patch

r+ but please make sure it won't break anything else.
Comment 26 Chris Dumez 2015-07-04 09:17:50 PDT
(In reply to comment #24)
> Comment on attachment 256139 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256139&action=review
> 
> > Source/JavaScriptCore/parser/Parser.cpp:494
> > +        lastPattern = TreeDestructuringPattern(0);
> 
> Is this one necessary?
> 
> > Source/JavaScriptCore/parser/Parser.cpp:897
> > +            pattern = TreeDestructuringPattern(0);
> 
> Or this one?

The reason I did this is because the functions are templated and depending on the template parameter, lastPattern / pattern can be either an int or a RefPtr. Therefore, using eight "= 0;" or "= nullptr;" wouldn't build. Calling the TreeDestructuringPattern constructor explicitly is the simplest workaround I found.
Comment 27 Chris Dumez 2015-07-04 12:43:21 PDT
Comment on attachment 256139 [details]
Patch

Clearing flags on attachment: 256139

Committed r186279: <http://trac.webkit.org/changeset/186279>
Comment 28 Chris Dumez 2015-07-04 12:43:29 PDT
All reviewed patches have been landed.  Closing bug.