Bug 205905 - Reduce binary size by purging C++ type information in Objective-C fields and parameters
Summary: Reduce binary size by purging C++ type information in Objective-C fields and ...
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: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-07 21:16 PST by Yusuke Suzuki
Modified: 2020-01-09 19:54 PST (History)
21 users (show)

See Also:


Attachments
Patch (110.84 KB, patch)
2020-01-07 21:23 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (114.11 KB, patch)
2020-01-07 21:31 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (117.53 KB, patch)
2020-01-07 21:38 PST, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff
Patch (122.33 KB, patch)
2020-01-07 21:50 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (124.91 KB, patch)
2020-01-07 23:27 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (124.91 KB, patch)
2020-01-08 15:14 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2020-01-07 21:16:40 PST
Reduce binary size by purging C++ type information in Objective-C fields and parameters
Comment 1 Yusuke Suzuki 2020-01-07 21:23:53 PST
Created attachment 387068 [details]
Patch
Comment 2 Yusuke Suzuki 2020-01-07 21:31:27 PST
Created attachment 387070 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2020-01-07 21:31:59 PST
<rdar://problem/58398934>
Comment 4 Yusuke Suzuki 2020-01-07 21:38:57 PST
Created attachment 387071 [details]
Patch
Comment 5 Yusuke Suzuki 2020-01-07 21:43:01 PST
Comment on attachment 387071 [details]
Patch

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

> Source/WTF/ChangeLog:19
> +        This patch introduces NativeRef<T>. This is similar to Ref while it does not have any ownership. So it

Native => Naked.
Comment 6 Saam Barati 2020-01-07 21:44:34 PST
Comment on attachment 387071 [details]
Patch

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

Nice!!

r=me

> Source/WTF/ChangeLog:8
> +        Objective-C has reflection mechanism. This means that fields, methods, and their types

"has reflection" => "has a reflection"

> Source/WTF/ChangeLog:24
> +            2. T* / T& is in Objective-C fields or paramter types (including a return type).

paramter => parameter
Comment 7 Saam Barati 2020-01-07 21:47:07 PST
Comment on attachment 387071 [details]
Patch

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

>> Source/WTF/ChangeLog:8
>> +        Objective-C has reflection mechanism. This means that fields, methods, and their types
> 
> "has reflection" => "has a reflection"

actually, probably this should just be:
"mechanism" => "mechanisms"

since ObjC has more than one kind of reflection
Comment 8 Yusuke Suzuki 2020-01-07 21:50:33 PST
Created attachment 387073 [details]
Patch

iOS build fix
Comment 9 Mark Lam 2020-01-07 22:06:25 PST
Comment on attachment 387073 [details]
Patch

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

> Source/WTF/ChangeLog:36
> +           becomes available in our platforms, we can consider it. But using NakedRef / NakedPtr is not harmless.

Do you mean "is harmless" instead of "is not harmless", as in there is effectively no cost to using NakedRef / NakedPtr?
Comment 10 Yusuke Suzuki 2020-01-07 22:32:34 PST
I'm now looking WebKitLegacy crash.
Comment 11 Yusuke Suzuki 2020-01-07 22:39:44 PST
(In reply to Yusuke Suzuki from comment #10)
> I'm now looking WebKitLegacy crash.

OK, found the thing. Signature in WebViewInternal.h and WebView.mm were different.
I really think this must be compile error even in Objective-C!
Comment 12 Yusuke Suzuki 2020-01-07 22:40:13 PST
(In reply to Yusuke Suzuki from comment #11)
> (In reply to Yusuke Suzuki from comment #10)
> > I'm now looking WebKitLegacy crash.
> 
> OK, found the thing. Signature in WebViewInternal.h and WebView.mm were
> different.
> I really think this must be compile error even in Objective-C!

I'll double-check and upload the patch for EWS before landing.
Comment 13 Yusuke Suzuki 2020-01-07 23:27:56 PST
Created attachment 387081 [details]
Patch

WebKitLegacy fix
Comment 14 Simon Fraser (smfr) 2020-01-08 11:28:11 PST
How do we ensure that people correctly use Naked<> in future? It's going to be very easy for new code to regress this again, right?
Comment 15 Yusuke Suzuki 2020-01-08 12:08:49 PST
(In reply to Simon Fraser (smfr) from comment #14)
> How do we ensure that people correctly use Naked<> in future? It's going to
> be very easy for new code to regress this again, right?

I think we should track binary size as we are doing in performance testing.
Comment 16 Yusuke Suzuki 2020-01-08 15:14:31 PST
Created attachment 387147 [details]
Patch

Fix
Comment 17 Yusuke Suzuki 2020-01-08 17:40:41 PST
I've ensured that iOS simulator API tests pass locally.
Comment 18 Yusuke Suzuki 2020-01-08 17:42:46 PST
Committed r254241: <https://trac.webkit.org/changeset/254241>
Comment 19 Sam Weinig 2020-01-09 17:56:45 PST
(In reply to Yusuke Suzuki from comment #15)
> (In reply to Simon Fraser (smfr) from comment #14)
> > How do we ensure that people correctly use Naked<> in future? It's going to
> > be very easy for new code to regress this again, right?
> 
> I think we should track binary size as we are doing in performance testing.

Is this something we could automate at build time? e.g. could we add a script phase (similar to check-for-weak-vtables-and-externals) that checks for this specific issue,  C++ type information in Objective-C fields and parameters?
Comment 20 Yusuke Suzuki 2020-01-09 17:59:54 PST
(In reply to Sam Weinig from comment #19)
> (In reply to Yusuke Suzuki from comment #15)
> > (In reply to Simon Fraser (smfr) from comment #14)
> > > How do we ensure that people correctly use Naked<> in future? It's going to
> > > be very easy for new code to regress this again, right?
> > 
> > I think we should track binary size as we are doing in performance testing.
> 
> Is this something we could automate at build time? e.g. could we add a
> script phase (similar to check-for-weak-vtables-and-externals) that checks
> for this specific issue,  C++ type information in Objective-C fields and
> parameters?

PoC of this exists here :) https://bugs.webkit.org/show_bug.cgi?id=205968
Discussed with Simon and we can put this type of script as the same way to Scripts/check-for-exit-time-destructors etc.
Comment 21 Sam Weinig 2020-01-09 19:54:22 PST
(In reply to Yusuke Suzuki from comment #20)
> (In reply to Sam Weinig from comment #19)
> > (In reply to Yusuke Suzuki from comment #15)
> > > (In reply to Simon Fraser (smfr) from comment #14)
> > > > How do we ensure that people correctly use Naked<> in future? It's going to
> > > > be very easy for new code to regress this again, right?
> > > 
> > > I think we should track binary size as we are doing in performance testing.
> > 
> > Is this something we could automate at build time? e.g. could we add a
> > script phase (similar to check-for-weak-vtables-and-externals) that checks
> > for this specific issue,  C++ type information in Objective-C fields and
> > parameters?
> 
> PoC of this exists here :) https://bugs.webkit.org/show_bug.cgi?id=205968
> Discussed with Simon and we can put this type of script as the same way to
> Scripts/check-for-exit-time-destructors etc.

Very nice.