Bug 233985 - [JSC] Introduce BaselineCallLinkInfo and OptimizingCallLinkInfo to shrink sizeof(BaselineCallLinkInfo)
Summary: [JSC] Introduce BaselineCallLinkInfo and OptimizingCallLinkInfo to shrink siz...
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: 2021-12-07 23:02 PST by Yusuke Suzuki
Modified: 2021-12-09 00:48 PST (History)
7 users (show)

See Also:


Attachments
Patch (63.24 KB, patch)
2021-12-07 23:04 PST, Yusuke Suzuki
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (63.89 KB, patch)
2021-12-07 23:14 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (64.27 KB, patch)
2021-12-08 00:24 PST, Yusuke Suzuki
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2021-12-07 23:02:17 PST
[JSC] Introduce BaselineCallLinkInfo and OptimizingCallLinkInfo to shrink sizeof(BaselineCallLinkInfo)
Comment 1 Yusuke Suzuki 2021-12-07 23:04:12 PST
Created attachment 446311 [details]
Patch
Comment 2 Yusuke Suzuki 2021-12-07 23:14:24 PST
Created attachment 446314 [details]
Patch
Comment 3 Yusuke Suzuki 2021-12-08 00:24:22 PST
Created attachment 446326 [details]
Patch
Comment 4 Mark Lam 2021-12-08 17:12:18 PST
Comment on attachment 446326 [details]
Patch

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

Nice.  I like that the BaselineCallLinkInfo is now distinct from the OptimizingCallLinkInfo.  It makes the code so much easier to parse.

r=me with suggestions and questions.

> Source/JavaScriptCore/bytecode/CallLinkInfo.cpp:335
> +CCallHelpers::JumpList OptimizingCallLinkInfo::emitFastPath(CCallHelpers& jit, GPRReg calleeGPR, GPRReg callLinkInfoGPR, UseDataIC useDataIC)

Should put these OptimizingCallLinkInfo functions under a #if ENABLE(DFG_JIT) (or #if ENABLE(JIT) depending on what you decided to guard it under).  Otherwise, non-JIT or non-optimizing JIT builds will not be happy.

It's great for review to keep these functions in place like this with only minimal edits, but perhaps before you land, you should just group them together at the bottom of the file and just guard them with #if ENABLE(DFG_JIT) and do the same for the whole OptimizingCallLinkInfo class declaration in the header file.

> Source/JavaScriptCore/bytecode/CallLinkInfo.cpp:349
> +MacroAssembler::JumpList OptimizingCallLinkInfo::emitTailCallFastPath(CCallHelpers& jit, GPRReg calleeGPR, ScopedLambda<void()>&& prepareForTailCall)

Ditto.

> Source/JavaScriptCore/bytecode/CallLinkInfo.h:446
>  #if ENABLE(JIT)
>      GPRReg m_calleeGPR { InvalidGPRReg };
> +    GPRReg m_callLinkInfoGPR { InvalidGPRReg };
>  #endif

I think these can be moved to the OptimizingCallLinkInfo now.

Out of curiosity, why is m_callLinkInfoGPR (and its accessor method) needed?  I only see it being set (in existing code, and in your patch), but I don't see anyone using the value, except for a RELEASE_ASSERT in setCallLinkInfoGPR().  Is this really needed?  If not, then its getter & setter can. be removed as well.

> Source/JavaScriptCore/bytecode/CallLinkInfo.h:466
> +    GPRReg calleeGPR() const { return BaselineCallRegisters::calleeGPR; }
> +    GPRReg callLinkInfoGPR() const { return BaselineCallRegisters::callLinkInfoGPR; }

Can these be made constexpr static instead?

> Source/JavaScriptCore/bytecode/CallLinkInfo.h:467
> +    void setCallLinkInfoGPR(GPRReg callLinkInfoGPR) { RELEASE_ASSERT(callLinkInfoGPR == this->callLinkInfoGPR()); }

Can use `BaselineCallRegisters::callLinkInfoGPR` instead of `this->callLinkInfoGPR()`.

> Source/JavaScriptCore/bytecode/CallLinkInfo.h:480
> +#if ENABLE(JIT)

Why not put the whole OptimizingCallLinkInfo class under #if ENABLE(DFG_JIT)?

> Source/JavaScriptCore/dfg/DFGOperations.h:40
>  class JSPropertyNameEnumerator;

Not due to your change, but would you mind moving this up above to keep the list alphabetically sorted?
Comment 5 Yusuke Suzuki 2021-12-09 00:42:51 PST
Comment on attachment 446326 [details]
Patch

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

Thanks!

>> Source/JavaScriptCore/bytecode/CallLinkInfo.cpp:335
>> +CCallHelpers::JumpList OptimizingCallLinkInfo::emitFastPath(CCallHelpers& jit, GPRReg calleeGPR, GPRReg callLinkInfoGPR, UseDataIC useDataIC)
> 
> Should put these OptimizingCallLinkInfo functions under a #if ENABLE(DFG_JIT) (or #if ENABLE(JIT) depending on what you decided to guard it under).  Otherwise, non-JIT or non-optimizing JIT builds will not be happy.
> 
> It's great for review to keep these functions in place like this with only minimal edits, but perhaps before you land, you should just group them together at the bottom of the file and just guard them with #if ENABLE(DFG_JIT) and do the same for the whole OptimizingCallLinkInfo class declaration in the header file.

Non Baseline CallLinkInfos are now OptimizingCallLinkInfo. So, for example, IC is using that.
SO, we cannot use `ENABLE(DFG_JIT)`. But probably, we can use ENABLE(JIT).

>> Source/JavaScriptCore/bytecode/CallLinkInfo.h:446
>>  #endif
> 
> I think these can be moved to the OptimizingCallLinkInfo now.
> 
> Out of curiosity, why is m_callLinkInfoGPR (and its accessor method) needed?  I only see it being set (in existing code, and in your patch), but I don't see anyone using the value, except for a RELEASE_ASSERT in setCallLinkInfoGPR().  Is this really needed?  If not, then its getter & setter can. be removed as well.

It is right, but due to alignment / padding issue, if we move them to OptimizingCallLinkInfo, then rather it increases sizeof(OptimizingCallLinkInfo).
Since putting them in CallLinkInfo does not increase the size of CallLinkInfo (due to padding / alignment), I think putting them here is better due to memory saving.

I think callLinkInfoGPR() is not used right now, but probably, it is possible that we will use it in Repatch's linkPolymorphicCall in near future.

>> Source/JavaScriptCore/bytecode/CallLinkInfo.h:466
>> +    GPRReg callLinkInfoGPR() const { return BaselineCallRegisters::callLinkInfoGPR; }
> 
> Can these be made constexpr static instead?

Changed.

>> Source/JavaScriptCore/bytecode/CallLinkInfo.h:467
>> +    void setCallLinkInfoGPR(GPRReg callLinkInfoGPR) { RELEASE_ASSERT(callLinkInfoGPR == this->callLinkInfoGPR()); }
> 
> Can use `BaselineCallRegisters::callLinkInfoGPR` instead of `this->callLinkInfoGPR()`.

Changed.

>> Source/JavaScriptCore/bytecode/CallLinkInfo.h:480
>> +#if ENABLE(JIT)
> 
> Why not put the whole OptimizingCallLinkInfo class under #if ENABLE(DFG_JIT)?

It is because it is also used by IC, wasm etc.

>> Source/JavaScriptCore/dfg/DFGOperations.h:40
>>  class JSPropertyNameEnumerator;
> 
> Not due to your change, but would you mind moving this up above to keep the list alphabetically sorted?

Changed :)
Comment 6 Yusuke Suzuki 2021-12-09 00:47:38 PST
Committed r286769 (?): <https://commits.webkit.org/r286769>
Comment 7 Radar WebKit Bug Importer 2021-12-09 00:48:21 PST
<rdar://problem/86258681>