Bug 186470

Summary: SubresourceLoader::willSendRequestInternal() creates some WTF::Functions which are over 700 bytes big
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: achristensen, beidson, cdumez, simon.fraser
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Simon Fraser (smfr) 2018-06-09 22:41:33 PDT
In this call stack:

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 8.1
  * frame #0: 0x0000000114d8cc5c JavaScriptCore`WTF::fastMalloc(size=728) at FastMalloc.cpp:272
    frame #1: 0x0000000106323845 WebCore`WTF::Function<void (WebCore::ResourceRequest&&)>::CallableWrapperBase::operator new(size=728) at Function.h:83
    frame #2: 0x0000000107cc14b6 WebCore`WTF::Function<void (WebCore::ResourceRequest&&)>::Function<WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&), void>(WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)&&) [inlined] std::__1::__unique_if<WTF::Function<void (WebCore::ResourceRequest&&)>::CallableWrapper<WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)> >::__unique_single std::__1::make_unique<WTF::Function<void (__args=0x00007ffeefbf5e18)>::CallableWrapper<WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)>, WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)>(WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)&&) at memory:3032
    frame #3: 0x0000000107cc14b1 WebCore`WTF::Function<void (WebCore::ResourceRequest&&)>::Function<WebCore::SubresourceLoader::willSendRequestInternal(this=0x00007ffeefbf5df8, callable=0x00007ffeefbf5e18)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&), void>(WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)&&) at Function.h:43
    frame #4: 0x0000000107cc145d WebCore`WTF::Function<void (WebCore::ResourceRequest&&)>::Function<WebCore::SubresourceLoader::willSendRequestInternal(this=0x00007ffeefbf5df8, callable=0x00007ffeefbf5e18)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&), void>(WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)&&) at Function.h:44
    frame #5: 0x0000000107cc1410 WebCore`WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>::CompletionHandler<WebCore::SubresourceLoader::willSendRequestInternal(this=0x00007ffeefbf5df8, callable=0x00007ffeefbf5e18)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&), void>(WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)&&) at CompletionHandler.h:42
    frame #6: 0x0000000107cc13ad WebCore`WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>::CompletionHandler<WebCore::SubresourceLoader::willSendRequestInternal(this=0x00007ffeefbf5df8, callable=0x00007ffeefbf5e18)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&), void>(WebCore::SubresourceLoader::willSendRequestInternal(WebCore::ResourceRequest&&, WebCore::ResourceResponse const&, WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&)::'lambda'(WebCore::ResourceRequest&&)&&) at CompletionHandler.h:43
    frame #7: 0x0000000107cb84f0 WebCore`WebCore::SubresourceLoader::willSendRequestInternal(this=0x00007ffeefbf6b40, completionHandler=0x00007ffeefbf6e88, newRequest=0x00007ffeefbf7580)>&&)::$_0::operator()(WTF::CompletionHandler<void (WebCore::ResourceRequest&&)>&&, WebCore::ResourceRequest&&) at SubresourceLoader.cpp:193
    frame #8: 0x0000000107cb7a2b WebCore`WebCore::SubresourceLoader::willSendRequestInternal(this=0x0000000161001000, newRequest=0x00007ffeefbf7580, redirectResponse=0x00007ffeefbf6eb0, completionHandler=0x00007ffeefbf6e88)>&&) at SubresourceLoader.cpp:272


the WTF::Function<void (WebCore::ResourceRequest&&)>::CallableWrapperBase is 728 bytes big. This seems really large for a WTF::Function.

I think it's because it's capturing a ResourceResponse (696 bytes) by value. Is this intentional, or can it pass it by reference?