Bug 264513

Summary: Reduce padding in MacroAssembler::Jump on ARM64
Product: WebKit Reporter: David Degazio <d_degazio>
Component: JavaScriptCoreAssignee: David Degazio <d_degazio>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description David Degazio 2023-11-09 12:48:51 PST
rdar://118195458

MacroAssembler::Jump on ARM64 has additional fields not present on other platforms. It turns out these fields are really space-inefficient. First, 10 out of 32 bytes are padding alone:

    +0 < 32> JSC::AbstractMacroAssembler<JSC::ARM64Assembler>::Jump
    +0 <  8>     JSC::AssemblerLabel m_label 
    +0 <  8>       uint64_t m_offset
    +8 <  4>   JSC::ARM64Assembler::JumpType m_type 
   +12 <  4>   JSC::ARM64Assembler::Condition m_condition
   +16 <  1>   bool m_is64Bit
   +17 <  3>   <PADDING: 3 bytes>
   +20 <  4>   unsigned int m_bitNumber
   +24 <  1>   JSC::ARM64Assembler::RegisterID m_compareRegister
   +25 <  7>   <PADDING: 7 bytes>
  Total byte size: 32
  Total pad bytes: 10
  Padding percentage: 31.25 %

Second, ARM64Assembler::JumpType and ARM64Assembler::Condition have only a few enumerations, with the largest value between the two being JumpType::JumpTestBitFixedSize which is equivalent to the decimal 136. So, we should be able to encode these enumerations in a byte each, instead of four bytes each as it is now.

Altogether, we should be able to shrink this type from 32 bytes (10 bytes padding) to 16 bytes (0 bytes padding).
Comment 1 David Degazio 2023-11-09 12:55:37 PST
Pull request: https://github.com/WebKit/WebKit/pull/20254
Comment 2 EWS 2023-11-14 10:31:59 PST
Committed 270716@main (c9f96b41388b): <https://commits.webkit.org/270716@main>

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