Bug 179389 - Introduce a default RegisterSet constructor so that we can use { } notation.
Summary: Introduce a default RegisterSet constructor so that we can use { } notation.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-07 13:09 PST by Mark Lam
Modified: 2017-11-15 12:09 PST (History)
8 users (show)

See Also:


Attachments
proposed patch. (29.74 KB, patch)
2017-11-07 13:23 PST, Mark Lam
fpizlo: review-
Details | Formatted Diff | Diff
proposed patch. (8.85 KB, patch)
2017-11-07 14:02 PST, Mark Lam
sbarati: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2017-11-07 13:09:59 PST
Refactor code that are obviously able to pass RegisterSet by value to do so instead of passing a reference.
Comment 1 Mark Lam 2017-11-07 13:23:40 PST
Created attachment 326251 [details]
proposed patch.
Comment 2 Filip Pizlo 2017-11-07 13:30:31 PST
Comment on attachment 326251 [details]
proposed patch.

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

> Source/JavaScriptCore/ChangeLog:9
> +        Refactored code that are obviously able to pass RegisterSet by value to do so
> +        instead of passing a reference.

It turns out that even for primitive values that can/should be passed by value, doing const T& is essentially doing just that.  For example,

const int& foo() const { return m_foo; }

means that the actual load of the int will happen if the caller to foo() actually needs the value, and then it happens at the moment that the value is really needed.

So, I don't think that your patch's change is consistent with what you're saying you're doing - RegisterSet is already being "passed by value" under the loose C++ definition of that.
Comment 3 Mark Lam 2017-11-07 13:33:49 PST
(In reply to Filip Pizlo from comment #2)
> It turns out that even for primitive values that can/should be passed by
> value, doing const T& is essentially doing just that.

OK.  I should have known compilers are smart enough for that.
Comment 4 Mark Lam 2017-11-07 14:02:53 PST
Created attachment 326257 [details]
proposed patch.
Comment 5 Mark Lam 2017-11-07 14:53:25 PST
Thanks for the review.  Landed in r224550: <http://trac.webkit.org/r224550>.
Comment 6 Radar WebKit Bug Importer 2017-11-15 12:09:45 PST
<rdar://problem/35567060>