Bug 152557

Summary: Stop moving local objects in return statements
Product: WebKit Reporter: Andy Estes <aestes>
Component: New BugsAssignee: Andy Estes <aestes>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, andersca, ap, beidson, darin, dbates, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=152601
Attachments:
Description Flags
Patch
none
Patch beidson: review+, beidson: commit-queue-

Description Andy Estes 2015-12-25 01:19:58 PST
Stop moving local objects in return statements
Comment 1 Andy Estes 2015-12-25 01:42:59 PST
Created attachment 267915 [details]
Patch
Comment 2 Andy Estes 2015-12-25 04:37:19 PST
Created attachment 267920 [details]
Patch
Comment 3 Brady Eidson 2015-12-25 08:09:04 PST
Comment on attachment 267920 [details]
Patch

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

Can you resubmit for the commit queue to see if mac-debug clears up?

> Source/JavaScriptCore/ChangeLog:11
> +        I found these issues by temporarily replacing WTF::move with WTF::move and recompiling.

"WTF::move" and "WTF::move" are the same string, so I suspect there's a typo in your ChangeLog.
Comment 4 Andy Estes 2015-12-25 09:13:42 PST
(In reply to comment #3)
> Comment on attachment 267920 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=267920&action=review
> 
> Can you resubmit for the commit queue to see if mac-debug clears up?

Sure, I'll try.

> 
> > Source/JavaScriptCore/ChangeLog:11
> > +        I found these issues by temporarily replacing WTF::move with WTF::move and recompiling.
> 
> "WTF::move" and "WTF::move" are the same string, so I suspect there's a typo
> in your ChangeLog.

Hah, this ChangeLog is in the JSC Xcode project for some reason, so this got swept up in my global replace of std::move back to WTF::move.
Comment 5 Alexey Proskuryakov 2015-12-25 09:27:50 PST
There is no need to re-submit for EWS, it keeps trying. You can learn what's going on by hovering the bubble, or by clicking on it.

Someone probably landed a bad patch while no one was watching.
Comment 6 Alexey Proskuryakov 2015-12-25 09:56:27 PST
Hmm, in fact it's because bot ews113 went crazy, and somehow, each attempt ran on the same bot. Something is wrong here, but for now, I just rebooted it.
Comment 7 Brady Eidson 2015-12-25 15:18:01 PST
OH OH OH!

This hasn't landed yet, good!

Because I thought of a super obvious improvement: Make check-webkit-style warn for "return WTF::move("
Comment 8 Andy Estes 2015-12-25 16:35:22 PST
(In reply to comment #7)
> OH OH OH!
> 
> This hasn't landed yet, good!
> 
> Because I thought of a super obvious improvement: Make check-webkit-style
> warn for "return WTF::move("

There's at least one case where (I believe) we have to move a return value:

class Base {
};

class Derived : public Base {
};

std::unique_ptr<Base> create()
{
    auto derived { std::make_unique<Derived>() };
    return WTF::move(derived);
}

Since the type of create()'s return value differs from the type of the local, this function is not eligible for the RVO, and since std::unique_ptr<> is a move-only type, it can't be copied into the return value.

There's also one more case where it's acceptable (although not mandatory) to move a return value, and that's a member function that releases a member variable to the caller (although I'd prefer we use std::exchange() for those cases).
Comment 9 Andy Estes 2015-12-28 08:26:45 PST
Committed r194428: <http://trac.webkit.org/changeset/194428>