Bug 237485

Summary: Modernize OriginLock
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, darin, ggaren, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

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>