Bug 240056

Summary: SharedMemory::IPCHandle is a redundant class
Product: WebKit Reporter: Kimmo Kinnunen <kkinnunen>
Component: WebKit2Assignee: Kimmo Kinnunen <kkinnunen>
Status: RESOLVED FIXED    
Severity: Normal CC: eric.carlson, ews-watchlist, glenn, Hironori.Fujii, jer.noble, kkinnunen, philipj, sergio, webkit-bug-importer, youssefdevelops, y_soliman
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 244118    
Bug Blocks: 244255    
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch Hironori.Fujii: review+

Description Kimmo Kinnunen 2022-05-04 01:22:44 PDT
SharedMemory::IPCHandle is a redundant class
Comment 1 Kimmo Kinnunen 2022-05-04 01:33:17 PDT
Created attachment 458776 [details]
Patch
Comment 2 Kimmo Kinnunen 2022-05-04 04:02:18 PDT
Created attachment 458787 [details]
Patch
Comment 3 Kimmo Kinnunen 2022-05-04 10:56:25 PDT
Created attachment 458810 [details]
Patch
Comment 4 Kimmo Kinnunen 2022-05-04 11:54:12 PDT
Created attachment 458816 [details]
Patch
Comment 5 Kimmo Kinnunen 2022-05-05 05:07:23 PDT
Created attachment 458866 [details]
Patch
Comment 6 Radar WebKit Bug Importer 2022-05-11 01:23:13 PDT
<rdar://problem/93083601>
Comment 7 Fujii Hironori 2022-05-12 14:33:48 PDT
Comment on attachment 458866 [details]
Patch

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

Very nice!

> Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp:263
> +    if (!roundedSize) {

How this condition can fail?
Handle::decode already checks the size.
Do you want to use UNLIKELY here?

> Source/WebKit/Platform/unix/SharedMemoryUnix.cpp:84
> +    encoder << const_cast<Handle*>(this)->releaseAttachment();

Why do you need const_cast here? releaseAttachment is a const method.
Comment 8 Fujii Hironori 2022-05-12 14:49:04 PDT
Comment on attachment 458866 [details]
Patch

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

> Source/WebKit/Shared/ShareableBitmap.cpp:51
> +    encoder << WTFMove(m_handle);

IUUC, WTFMove has no effect here. "encoder << m_handle;" works same here.

> Source/WebKit/Shared/ShareableResource.cpp:41
> +    encoder << WTFMove(m_handle);

Ditto.
Comment 9 Kimmo Kinnunen 2022-05-13 00:07:43 PDT
Created attachment 459281 [details]
Patch
Comment 10 Kimmo Kinnunen 2022-05-13 00:12:25 PDT
(In reply to Fujii Hironori from comment #8)
> Comment on attachment 458866 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=458866&action=review
> 
> > Source/WebKit/Shared/ShareableBitmap.cpp:51
> > +    encoder << WTFMove(m_handle);
> 
> IUUC, WTFMove has no effect here. "encoder << m_handle;" works same here.
> 


Thanks for looking!
Yeah, you are right. I was needlessly thinking ahead.
Added your suggestions.

For the slightly redundant safeRoundPage, it is just to preserve the existing logic. I'll change this and other similar cases after this refactor.
Comment 11 Fujii Hironori 2022-05-13 00:28:39 PDT
Comment on attachment 459281 [details]
Patch

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

> Source/WebKit/Shared/WebCompiledContentRuleListData.cpp:47
> +    encoder << WTFMove(handle);

encoder << handle;

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:193
> +    encoder << WTFMove(handle);

encoder << handle;

> Source/WebKit/Shared/WebHitTestResultData.cpp:130
> +    encoder << WTFMove(imageHandle);

encoder << imageHandle;

> Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:700
>      });

WTFMove isn't needed for simple return statements.
return handle;
Comment 12 Kimmo Kinnunen 2022-05-13 04:51:53 PDT
Created attachment 459291 [details]
Patch
Comment 13 Kimmo Kinnunen 2022-05-13 09:16:29 PDT
Created attachment 459305 [details]
Patch
Comment 14 Fujii Hironori 2022-05-16 14:17:06 PDT
Comment on attachment 459305 [details]
Patch

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

> Source/WebKit/Shared/WebCompiledContentRuleListData.cpp:37
> +    return topURLFiltersBytecodeOffset + topURLFiltersBytecodeSize;

Do you think this addition needs overflow checking?

> Source/WebKit/Shared/WebCompiledContentRuleListData.cpp:112
> +    if (data->size() < ruleListDataSize(*topURLFiltersBytecodeOffset, *topURLFiltersBytecodeSize))

data->size() is a data size, not buffer size. I think it should (data->size() == ruleListDataSize(...)). If the condition fails, something wrong happens.

> Tools/MiniBrowser/mac/WK2BrowserWindowController.m:556
> +        title = @"";

Do you want to change MiniBrowser in this patch?
Comment 15 Kimmo Kinnunen 2022-08-15 05:55:48 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3304
Comment 16 EWS 2022-08-17 00:32:10 PDT
Committed 253508@main (29dff38a6ecb): <https://commits.webkit.org/253508@main>

Reviewed commits have been landed. Closing PR #3304 and removing active labels.
Comment 17 Kimmo Kinnunen 2022-08-22 04:39:30 PDT
Re-opening for pull request https://github.com/WebKit/WebKit/pull/3531
Comment 18 EWS 2022-08-23 03:21:12 PDT
Committed 253680@main (5d61da99e4fe): <https://commits.webkit.org/253680@main>

Reviewed commits have been landed. Closing PR #3531 and removing active labels.