Bug 237485 - Modernize OriginLock
Summary: Modernize OriginLock
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-04 13:53 PST by Chris Dumez
Modified: 2022-03-04 16:50 PST (History)
5 users (show)

See Also:


Attachments
Patch (6.93 KB, patch)
2022-03-04 13:55 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (7.00 KB, patch)
2022-03-04 14:00 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2022-03-04 13:53:27 PST
Modernize OriginLock.
Comment 1 Chris Dumez 2022-03-04 13:55:38 PST
Created attachment 453870 [details]
Patch
Comment 2 Chris Dumez 2022-03-04 14:00:29 PST
Created attachment 453871 [details]
Patch
Comment 3 Darin Adler 2022-03-04 14:34:38 PST
Comment on attachment 453871 [details]
Patch

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

> Source/WebCore/Modules/webdatabase/OriginLock.h:-36
> -    WTF_MAKE_NONCOPYABLE(OriginLock); WTF_MAKE_FAST_ALLOCATED;

Why aren’t these helpful? I don’t understand this change.

> Source/WebCore/Modules/webdatabase/OriginLock.h:40
> +    static Ref<OriginLock> create(const String& originPath)
> +    {
> +        return adoptRef(*new OriginLock(originPath));
> +    }

I don’t think we want to inline this. It would be better to have it in the .cpp file, since we’d rather inline the constructor in the create function rather than inlining the create function in the create call site.
Comment 4 Chris Dumez 2022-03-04 14:38:08 PST
(In reply to Darin Adler from comment #3)
> Comment on attachment 453871 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=453871&action=review
> 
> > Source/WebCore/Modules/webdatabase/OriginLock.h:-36
> > -    WTF_MAKE_NONCOPYABLE(OriginLock); WTF_MAKE_FAST_ALLOCATED;
> 
> Why aren’t these helpful? I don’t understand this change.

We get them from the base class already.

> 
> > Source/WebCore/Modules/webdatabase/OriginLock.h:40
> > +    static Ref<OriginLock> create(const String& originPath)
> > +    {
> > +        return adoptRef(*new OriginLock(originPath));
> > +    }
> 
> I don’t think we want to inline this. It would be better to have it in the
> .cpp file, since we’d rather inline the constructor in the create function
> rather than inlining the create function in the create call site.

OK.
Comment 5 Darin Adler 2022-03-04 14:40:31 PST
Comment on attachment 453871 [details]
Patch

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

>>> Source/WebCore/Modules/webdatabase/OriginLock.h:-36
>>> -    WTF_MAKE_NONCOPYABLE(OriginLock); WTF_MAKE_FAST_ALLOCATED;
>> 
>> Why aren’t these helpful? I don’t understand this change.
> 
> We get them from the base class already.

Not being copyable or movable is effectively inherited. Is fast allocation inherited? I didn’t realize it was.
Comment 6 Chris Dumez 2022-03-04 14:53:06 PST
(In reply to Darin Adler from comment #5)
> Comment on attachment 453871 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=453871&action=review
> 
> >>> Source/WebCore/Modules/webdatabase/OriginLock.h:-36
> >>> -    WTF_MAKE_NONCOPYABLE(OriginLock); WTF_MAKE_FAST_ALLOCATED;
> >> 
> >> Why aren’t these helpful? I don’t understand this change.
> > 
> > We get them from the base class already.
> 
> Not being copyable or movable is effectively inherited. Is fast allocation
> inherited? I didn’t realize it was.

I am pretty sure it is. As a matter of fact, we almost never explicit mark our classes as FACT_ALLOCATED when they subclass RefCounted.

To be certain, I ran the following code:
```
#include <iostream>

class A {
public:
    void* operator new(size_t size)
    {
        std::cout << "Uses custom allocator" << std::endl;
        return malloc(size);
    }
};

class B : public A {
};

int main() {
    auto b = new B;
    return 0;
}
```

It definitely printed my log line so the `operator new` gets inherited just fine and this is essentially what WTF_MAKE_FAST_ALLOCATED defines.
Comment 7 EWS 2022-03-04 16:49:24 PST
Committed r290854 (248086@main): <https://commits.webkit.org/248086@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453871 [details].
Comment 8 Radar WebKit Bug Importer 2022-03-04 16:50:19 PST
<rdar://problem/89841503>