Ignore:
Timestamp:
Apr 7, 2022, 10:03:19 AM (3 years ago)
Author:
[email protected]
Message:

[JSC][ARMv7] Support proper near calls and JUMP_ISLANDS
https://bugs.webkit.org/show_bug.cgi?id=238143

Patch by Geza Lore <Geza Lore> on 2022-04-07
Reviewed by Yusuke Suzuki.

JSTests:

  • microbenchmarks/let-const-tdz-environment-parsing-and-hash-consing-speed.js:

Source/JavaScriptCore:

Implement nearCall and nearTailCall as single instruction direct
branches on ARMv7/Thumb-2. (Will need to support these for Wasm JITs,
to implement threadSafePatchableNearcall.) To make this possible while
also having an executable pool size larger than the branch range, I
also ported JUMP_ISLANDS.

To port JUMP_ISLANDS, a reformulation of the region allocations was
necessary, which is now done in terms of the range of the
nearCall/nearTailCall macroassembler macros. For ARM64, the behaviour
should be identical.

The jump islad reservation on ARMv7 is set to 5% of executable memory
size, which is approximately the same as the baseline JIT code size
saving provided by using short branches for near calls, so the change
should be neutral overall with respect to executable memory
consumption.

Also made it possible for the --jitMemoryReservationSize option to
request JIT memory that is larger than the default hardcoded size
while using JUMP_ISLANDS (we need this for testing on ARMv7, which has
a smaller default executable pool size). To do this the region
allocators are no longer statically allocated but are held in a
FixedVector.

Also removed the unused repatchCompact methods from assemblers.

  • assembler/ARM64Assembler.h:
  • assembler/ARMv7Assembler.h:

(JSC::ARMv7Assembler::isEven):
(JSC::ARMv7Assembler::makeEven):
(JSC::ARMv7Assembler::bl):
(JSC::ARMv7Assembler::link):
(JSC::ARMv7Assembler::linkTailCall):
(JSC::ARMv7Assembler::linkCall):
(JSC::ARMv7Assembler::relinkCall):
(JSC::ARMv7Assembler::relinkTailCall):
(JSC::ARMv7Assembler::prepareForAtomicRelinkJumpConcurrently):
(JSC::ARMv7Assembler::prepareForAtomicRelinkCallConcurrently):
(JSC::ARMv7Assembler::replaceWithJump):
(JSC::ARMv7Assembler::canEmitJump):
(JSC::ARMv7Assembler::isBL):
(JSC::ARMv7Assembler::linkJumpT4):
(JSC::ARMv7Assembler::linkConditionalJumpT4):
(JSC::ARMv7Assembler::linkJumpAbsolute):
(JSC::ARMv7Assembler::linkBranch):

  • assembler/AbstractMacroAssembler.h:

(JSC::AbstractMacroAssembler::repatchNearCall):

  • assembler/AssemblerCommon.h:

(JSC::isInt):

  • assembler/MIPSAssembler.h:
  • assembler/MacroAssemblerARM64.h:
  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::nearCall):
(JSC::MacroAssemblerARMv7::nearTailCall):
(JSC::MacroAssemblerARMv7::linkCall):

  • assembler/MacroAssemblerMIPS.h:
  • assembler/MacroAssemblerRISCV64.h:
  • assembler/MacroAssemblerX86Common.h:
  • assembler/X86Assembler.h:
  • bytecode/Repatch.cpp:

(JSC::linkPolymorphicCall):

  • jit/ExecutableAllocator.cpp:

(JSC::initializeJITPageReservation):

Source/WTF:

Support constructor arguments for FixedVector element initialization.

  • wtf/EmbeddedFixedVector.h:
  • wtf/FixedVector.h:

(WTF::FixedVector::FixedVector):

  • wtf/PlatformEnable.h:
  • wtf/TrailingArray.h:

(WTF::TrailingArray::TrailingArray):

  • wtf/Vector.h:

(WTF::VectorTypeOperations::initializeWithArgs):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r291339 r292540  
    3939
    4040class MacroAssemblerARMv7 : public AbstractMacroAssembler<Assembler> {
     41public:
     42    static constexpr size_t nearJumpRange = 16 * MB;
     43
     44private:
    4145    static constexpr RegisterID dataTempRegister = ARMRegisters::ip;
    4246    static constexpr RegisterID addressTempRegister = ARMRegisters::r6;
     
    22382242    ALWAYS_INLINE Call nearCall()
    22392243    {
    2240         moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    22412244        invalidateAllTempRegisters();
    2242         return Call(m_assembler.blx(dataTempRegister), Call::LinkableNear);
     2245        return Call(m_assembler.bl(), Call::LinkableNear);
    22432246    }
    22442247
    22452248    ALWAYS_INLINE Call nearTailCall()
    22462249    {
    2247         moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    22482250        invalidateAllTempRegisters();
    2249         return Call(m_assembler.bx(dataTempRegister), Call::LinkableNearTail);
     2251        return Call(m_assembler.b(), Call::LinkableNearTail);
    22502252    }
    22512253
     
    26552657    static void linkCall(void* code, Call call, FunctionPtr<tag> function)
    26562658    {
    2657         if (call.isFlagSet(Call::Tail))
    2658             ARMv7Assembler::linkJump(code, call.m_label, function.executableAddress());
     2659        if (!call.isFlagSet(Call::Near))
     2660            Assembler::linkPointer(code, call.m_label.labelAtOffset(-2), function.executableAddress());
     2661        else if (call.isFlagSet(Call::Tail))
     2662            Assembler::linkTailCall(code, call.m_label, function.executableAddress());
    26592663        else
    2660             ARMv7Assembler::linkCall(code, call.m_label, function.executableAddress());
     2664            Assembler::linkCall(code, call.m_label, function.executableAddress());
    26612665    }
    26622666
Note: See TracChangeset for help on using the changeset viewer.