Bug 182320 - Canonicalize aquiring the JSCell lock.
Summary: Canonicalize aquiring the JSCell lock.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-01-30 21:23 PST by Keith Miller
Modified: 2018-01-31 12:06 PST (History)
6 users (show)

See Also:


Attachments
Patch (14.80 KB, patch)
2018-01-30 21:26 PST, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (15.06 KB, patch)
2018-01-31 08:15 PST, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (10.21 KB, patch)
2018-01-31 08:16 PST, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (17.43 KB, patch)
2018-01-31 10:06 PST, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (17.51 KB, patch)
2018-01-31 10:15 PST, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2018-01-30 21:23:36 PST
Canonicalize aquiring the JSCell lock.
Comment 1 Keith Miller 2018-01-30 21:26:55 PST
Created attachment 332741 [details]
Patch
Comment 2 Keith Miller 2018-01-31 08:15:46 PST
Created attachment 332762 [details]
Patch
Comment 3 Keith Miller 2018-01-31 08:16:36 PST
Created attachment 332763 [details]
Patch
Comment 4 Saam Barati 2018-01-31 09:15:50 PST
Comment on attachment 332763 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSCell.h:124
> +    // It's also recommended that cells are locked with the holdJSCellLock() method to help keep

Why not make those private and friend lockholder then? Or you could do what I suggest below and make these private and people can call lock/unlock on the wrapper type

> Source/JavaScriptCore/runtime/JSCell.h:126
> +    Locker<JSCell> holdJSCellLock() { return holdLock(*this); }

Not in love with the name here. What if you had some method named “cellLock” and it returned to you some wrapper that exposes lock/unlock methods. You could do:
auto locker = holdLock(cell->cellLock())
But I’m not sure if that’s much better
Comment 5 Keith Miller 2018-01-31 09:19:31 PST
Comment on attachment 332763 [details]
Patch

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

>> Source/JavaScriptCore/runtime/JSCell.h:124
>> +    // It's also recommended that cells are locked with the holdJSCellLock() method to help keep
> 
> Why not make those private and friend lockholder then? Or you could do what I suggest below and make these private and people can call lock/unlock on the wrapper type

You can't really do that. If you friend Locker then anyone can make a Locker that can lock a JSCell so we're in the same boat. You also can't make a subclass of Locker that you friend because the base class needs access to lock/unlock.

>> Source/JavaScriptCore/runtime/JSCell.h:126
>> +    Locker<JSCell> holdJSCellLock() { return holdLock(*this); }
> 
> Not in love with the name here. What if you had some method named “cellLock” and it returned to you some wrapper that exposes lock/unlock methods. You could do:
> auto locker = holdLock(cell->cellLock())
> But I’m not sure if that’s much better

Yeah, I guess that's a bit better in that you can't just holdLock(cell).
Comment 6 Keith Miller 2018-01-31 10:06:20 PST
Created attachment 332773 [details]
Patch
Comment 7 Keith Miller 2018-01-31 10:15:37 PST
Created attachment 332775 [details]
Patch
Comment 8 Michael Saboff 2018-01-31 10:31:38 PST
Comment on attachment 332775 [details]
Patch

r=me after build failures.
Comment 9 Keith Miller 2018-01-31 10:32:36 PST
(In reply to Michael Saboff from comment #8)
> Comment on attachment 332775 [details]
> Patch
> 
> r=me after build failures.

Looks like ToT is broken...
Comment 10 WebKit Commit Bot 2018-01-31 10:57:18 PST
Comment on attachment 332775 [details]
Patch

Clearing flags on attachment: 332775

Committed r227906: <https://trac.webkit.org/changeset/227906>
Comment 11 WebKit Commit Bot 2018-01-31 10:57:20 PST
All reviewed patches have been landed.  Closing bug.
Comment 12 Radar WebKit Bug Importer 2018-01-31 11:00:32 PST
<rdar://problem/37077485>
Comment 13 Saam Barati 2018-01-31 12:06:13 PST
Comment on attachment 332775 [details]
Patch

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

> Source/JavaScriptCore/runtime/JSCell.h:288
> +class JSCellLock : public JSCell {

nice. This patch LGTM too. I think this API works out nicely.