Bug 238777

Summary: [JSC] Reduce sizeof(BaselineCallLinkInfo) to make bug 238535 good
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch mark.lam: review+

Description Yusuke Suzuki 2022-04-04 16:27:02 PDT
[JSC] Reduce sizeof(BaselineCallLinkInfo) to make bug 238535 good
Comment 1 Yusuke Suzuki 2022-04-04 16:28:08 PDT
Created attachment 456647 [details]
Patch
Comment 2 Yusuke Suzuki 2022-04-04 16:29:35 PDT
Created attachment 456648 [details]
Patch
Comment 3 Mark Lam 2022-04-04 17:03:50 PDT
Comment on attachment 456648 [details]
Patch

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

> Source/JavaScriptCore/bytecode/Repatch.cpp:1735
> +            CallFrameShuffleData shuffleData = CallFrameShuffleData::createForBaselineOrLLIntTailCall(bytecode, callerCodeBlock->numParameters());

According to my local dump-class-layout of CallFrameShuffleData, it is 616 bytes in size (not including the backing store for the Vector in it).  Here, we're returning by value, which may not be as big an issue due to forwarding.  However, see below ...

> Source/JavaScriptCore/bytecode/Repatch.cpp:1744
> +            frameShuffler.emplace(stubJit, *optimizingCallLinkInfo.frameShuffleData());

Here, we're copying the CallFrameShuffleData, right?  Can we change the idiom such that we use:

    CallFrameShuffler localFrameShuffler;
    std::optional<CallFrameShuffler*> frameShuffler;

... and in the baseline case, pass the &localFrameShuffler to an init function (factored out of createForBaselineOrLLIntTailCall()) instead of calling createForBaselineOrLLIntTailCall() directly?
Comment 4 Yusuke Suzuki 2022-04-04 17:18:06 PDT
Comment on attachment 456648 [details]
Patch

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

>> Source/JavaScriptCore/bytecode/Repatch.cpp:1744
>> +            frameShuffler.emplace(stubJit, *optimizingCallLinkInfo.frameShuffleData());
> 
> Here, we're copying the CallFrameShuffleData, right?  Can we change the idiom such that we use:
> 
>     CallFrameShuffler localFrameShuffler;
>     std::optional<CallFrameShuffler*> frameShuffler;
> 
> ... and in the baseline case, pass the &localFrameShuffler to an init function (factored out of createForBaselineOrLLIntTailCall()) instead of calling createForBaselineOrLLIntTailCall() directly?

Ah, no. CallFrameShuffler just constructs itself via `const CallFrameShuffleData&`, and does not copy it. So it is just referencing the value.
Comment 5 Mark Lam 2022-04-04 17:44:34 PDT
Comment on attachment 456648 [details]
Patch

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

r=me

>>> Source/JavaScriptCore/bytecode/Repatch.cpp:1744
>>> +            frameShuffler.emplace(stubJit, *optimizingCallLinkInfo.frameShuffleData());
>> 
>> Here, we're copying the CallFrameShuffleData, right?  Can we change the idiom such that we use:
>> 
>>     CallFrameShuffler localFrameShuffler;
>>     std::optional<CallFrameShuffler*> frameShuffler;
>> 
>> ... and in the baseline case, pass the &localFrameShuffler to an init function (factored out of createForBaselineOrLLIntTailCall()) instead of calling createForBaselineOrLLIntTailCall() directly?
> 
> Ah, no. CallFrameShuffler just constructs itself via `const CallFrameShuffleData&`, and does not copy it. So it is just referencing the value.

Sorry.  I conflated CallFrameShuffleData with CallFrameShuffler.  You are correct that there's no unnecessary copying here.
Comment 6 Yusuke Suzuki 2022-04-04 21:18:26 PDT
Committed r292373 (249238@trunk): <https://commits.webkit.org/249238@trunk>
Comment 7 Radar WebKit Bug Importer 2022-04-04 21:19:17 PDT
<rdar://problem/91276232>