Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JSC][ARMv7] Support callee save FPRs #777

Merged
merged 0 commits into from May 25, 2022

Conversation

gezalore
Copy link
Contributor

@gezalore gezalore commented May 19, 2022

60a5bb3

[JSC][ARMv7] Support callee save FPRs

Patch by Geza Lore <glore@igalia.com > on 2022-05-25
https://bugs.webkit.org/show_bug.cgi?id=240376

Reviewed by Yusuke Suzuki.

ARMv7 FPRs d8-d15 (also referenced as s16-s32 and q4-q7) are callee save
in the host ABI, but currently JSC is unaware of this. This does not
currently cause problems as they are not used, but will be used by the
Wasm JITs.

In preparation for the 32-bit ports of the Wasm JITs, this patch:
- Teaches JSC about callee save FPRs on ARMv7. d8-d15 are host ABI
  callee save, but only d8-d14 are VM callee save, i.e.: we treat d15
  as a volatile register in JIT code. This is so we can use d15 as a
  macro assembler scratch register.
- Changes offlineasm and MacroAssemblerARMv7 to use d15 as the FP
  scratch register. We do this so we can use the full range of d0-d7
  as temporary, and in particular as Wasm argument/return registers.
- To achieve the above, we need to modify RegisterAtOffsetList as GPRs
  and FPRs have different sizes on JSVALUE32_64 platforms
- Adds the ARMv7 specific registers to
  RegisterSet::macroScratchRegisters()

* assembler/ARMv7Registers.h:
* assembler/MacroAssemblerARMv7.h:
* b3/air/AirCode.cpp:
(JSC::B3::Air::Code::calleeSaveRegisterAtOffsetList const):
(JSC::B3::Air::Code::dump const):
* b3/testb3_7.cpp:
(testInfiniteLoopDoesntCauseBadHoisting):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters):
(JSC::CodeBlock::calleeSaveSpaceAsVirtualRegisters):
(JSC::roundCalleeSaveSpaceAsVirtualRegisters): Deleted.
* bytecode/ValueRecovery.h:
(JSC::ValueRecovery::calleeSaveGPRDisplacedInJSStack):
(JSC::ValueRecovery::calleeSaveRegDisplacedInJSStack): Deleted.
* dfg/DFGOSREntry.cpp:
(JSC::DFG::prepareOSREntry):
* dfg/DFGOSRExitCompilerCommon.cpp:
(JSC::DFG::calleeSaveSlot):
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::compileStub):
* interpreter/Interpreter.cpp:
(JSC::UnwindFunctor::copyCalleeSavesToEntryFrameCalleeSavesBuffer const):
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::restoreCalleeSavesFromEntryFrameCalleeSavesBuffer):
(JSC::AssemblyHelpers::restoreCalleeSavesFromVMEntryFrameCalleeSavesBufferImpl):
(JSC::AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBufferImpl):
(JSC::AssemblyHelpers::emitSave):
(JSC::AssemblyHelpers::emitRestore):
(JSC::AssemblyHelpers::emitSaveCalleeSavesFor):
(JSC::AssemblyHelpers::emitRestoreCalleeSavesFor):
(JSC::AssemblyHelpers::copyLLIntBaselineCalleeSavesFromFrameOrRegisterToEntryFrameCalleeSavesBuffer):
(JSC::AssemblyHelpers::emitSaveOrCopyLLIntBaselineCalleeSavesFor):
* jit/CallFrameShuffleData.cpp:
(JSC::CallFrameShuffleData::setupCalleeSaveRegisters):
* jit/CallFrameShuffler.h:
(JSC::CallFrameShuffler::snapshot const):
* jit/CallFrameShuffler32_64.cpp:
(JSC::CallFrameShuffler::emitDisplace):
* jit/FPRInfo.h:
* jit/GPRInfo.h:
* jit/RegisterAtOffsetList.cpp:
(JSC::RegisterAtOffsetList::RegisterAtOffsetList):
* jit/RegisterAtOffsetList.h:
(JSC::RegisterAtOffsetList::registerCount const):
(JSC::RegisterAtOffsetList::sizeOfAreaInBytes const):
(JSC::RegisterAtOffsetList::adjustOffsets):
(JSC::RegisterAtOffsetList::size const): Deleted.
(JSC::RegisterAtOffsetList::at): Deleted.
* jit/RegisterSet.cpp:
(JSC::RegisterSet::macroScratchRegisters):
(JSC::RegisterSet::vmCalleeSaveRegisters):
* llint/LowLevelInterpreter.asm:
* offlineasm/arm.rb:
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WasmToJS.cpp:
(JSC::Wasm::wasmToJS):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::jsCallEntrypointSlow):

Canonical link: https://commits.webkit.org/250952@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294794 268f45cc-cd09-0410-ab3c-d52691b4dbfc

@gezalore gezalore added JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. WebKit Nightly Build labels May 19, 2022
@webkit-early-warning-system webkit-early-warning-system added the merging-blocked Applied to prevent a change from being merged label May 19, 2022
Copy link
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://bugs.webkit.org/show_bug.cgi?id=240376

Reviewed by NOBODY (OOPS!).

ARMv7 FPRs d8-d15 (also referenced as s16-s32 and q4-q7) are callee
save, but currently JSC is unaware of this. This does not currently
cause problems as they are not used, but will be used by the Wasm
JITs.

In preparation for the 32-bit ports of the Wasm JITs, this patch:

  • Teaches JSC about callee save FPRs on ARMv7
  • To achieve the above, we need to modify RegisterAtOffsetList as GPRs
    and FPRs have different sizes on JSVALUE32_64 platforms
  • Changes offlineasm and MacroAssemblerARMv7 to use d15 as the FP
    scratch register

Can you describe why d15 is picked for FP scratch register?
It is callee-save register, and usually we pick caller-save register for scratch.

  • Adds the ARMv7 specific registers to
    RegisterSet::macroScratchRegisters()
  • assembler/ARMv7Registers.h:
  • assembler/MacroAssemblerARMv7.h:
  • b3/air/AirCode.cpp:
    (JSC::B3::Air::Code::calleeSaveRegisterAtOffsetList const):
    (JSC::B3::Air::Code::dump const):
  • b3/testb3_7.cpp:
    (testInfiniteLoopDoesntCauseBadHoisting):
  • bytecode/CodeBlock.cpp:
    (JSC::CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters):
    (JSC::CodeBlock::calleeSaveSpaceAsVirtualRegisters):
    (JSC::roundCalleeSaveSpaceAsVirtualRegisters): Deleted.
  • bytecode/ValueRecovery.h:
    (JSC::ValueRecovery::calleeSaveGPRDisplacedInJSStack):
    (JSC::ValueRecovery::calleeSaveRegDisplacedInJSStack): Deleted.
  • dfg/DFGOSREntry.cpp:
    (JSC::DFG::prepareOSREntry):
  • dfg/DFGOSRExitCompilerCommon.cpp:
    (JSC::DFG::calleeSaveSlot):
  • ftl/FTLOSRExitCompiler.cpp:
    (JSC::FTL::compileStub):
  • interpreter/Interpreter.cpp:
    (JSC::UnwindFunctor::copyCalleeSavesToEntryFrameCalleeSavesBuffer const):
  • jit/AssemblyHelpers.cpp:
    (JSC::AssemblyHelpers::restoreCalleeSavesFromEntryFrameCalleeSavesBuffer):
    (JSC::AssemblyHelpers::restoreCalleeSavesFromVMEntryFrameCalleeSavesBufferImpl):
    (JSC::AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBufferImpl):
    (JSC::AssemblyHelpers::emitSave):
    (JSC::AssemblyHelpers::emitRestore):
    (JSC::AssemblyHelpers::emitSaveCalleeSavesFor):
    (JSC::AssemblyHelpers::emitRestoreCalleeSavesFor):
    (JSC::AssemblyHelpers::copyLLIntBaselineCalleeSavesFromFrameOrRegisterToEntryFrameCalleeSavesBuffer):
    (JSC::AssemblyHelpers::emitSaveOrCopyLLIntBaselineCalleeSavesFor):
  • jit/CallFrameShuffleData.cpp:
    (JSC::CallFrameShuffleData::setupCalleeSaveRegisters):
  • jit/CallFrameShuffler.h:
    (JSC::CallFrameShuffler::snapshot const):
  • jit/CallFrameShuffler32_64.cpp:
    (JSC::CallFrameShuffler::emitDisplace):
  • jit/FPRInfo.h:
  • jit/GPRInfo.h:
  • jit/RegisterAtOffsetList.cpp:
    (JSC::RegisterAtOffsetList::RegisterAtOffsetList):
  • jit/RegisterAtOffsetList.h:
    (JSC::RegisterAtOffsetList::registerCount const):
    (JSC::RegisterAtOffsetList::sizeOfAreaInBytes const):
    (JSC::RegisterAtOffsetList::adjustOffsets):
    (JSC::RegisterAtOffsetList::size const): Deleted.
    (JSC::RegisterAtOffsetList::at): Deleted.
  • jit/RegisterSet.cpp:
    (JSC::RegisterSet::macroScratchRegisters):
    (JSC::RegisterSet::vmCalleeSaveRegisters):
  • llint/LowLevelInterpreter.asm:
  • offlineasm/arm.rb:
  • wasm/js/JSToWasm.cpp:
    (JSC::Wasm::createJSToWasmWrapper):
  • wasm/js/WasmToJS.cpp:
    (JSC::Wasm::wasmToJS):
  • wasm/js/WebAssemblyFunction.cpp:
    (JSC::WebAssemblyFunction::jsCallEntrypointSlow):

Source/JavaScriptCore/llint/LowLevelInterpreter.asm Outdated Show resolved Hide resolved
@gezalore gezalore removed merging-blocked Applied to prevent a change from being merged JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. WebKit Nightly Build labels May 20, 2022
@gezalore gezalore added JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. WebKit Nightly Build labels May 20, 2022
@gezalore
Copy link
Contributor Author

Can you describe why d15 is picked for FP scratch register? It is callee-save register, and usually we pick caller-save register for scratch.

I expanded the commit message to explain this. r? please.

@gezalore
Copy link
Contributor Author

Fixed the other comments.

@webkit-early-warning-system webkit-early-warning-system added the merging-blocked Applied to prevent a change from being merged label May 21, 2022
Copy link
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

Source/JavaScriptCore/jit/RegisterAtOffsetList.cpp Outdated Show resolved Hide resolved
Source/JavaScriptCore/jit/RegisterAtOffsetList.cpp Outdated Show resolved Hide resolved
@gezalore gezalore force-pushed the fprs branch 2 times, most recently from f6e563b to 49a1ecc Compare May 23, 2022 12:13
@mikhailramalho mikhailramalho added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 23, 2022
@webkit-early-warning-system webkit-early-warning-system added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels May 23, 2022
@gezalore gezalore force-pushed the fprs branch 2 times, most recently from 7b96a1b to ed693bd Compare May 24, 2022 10:21
@mikhailramalho mikhailramalho added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 24, 2022
@webkit-early-warning-system
Copy link
Collaborator

No reviewer information in commit message, blocking PR #777

@webkit-early-warning-system webkit-early-warning-system added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels May 24, 2022
@gezalore gezalore removed the merging-blocked Applied to prevent a change from being merged label May 24, 2022
@gezalore gezalore removed JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. WebKit Nightly Build labels May 24, 2022
@gezalore gezalore added JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. WebKit Nightly Build labels May 24, 2022
@webkit-early-warning-system webkit-early-warning-system added the merging-blocked Applied to prevent a change from being merged label May 25, 2022
@Constellation Constellation added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 25, 2022
@webkit-early-warning-system
Copy link
Collaborator

No reviewer information in commit message, blocking PR #777

@webkit-early-warning-system webkit-early-warning-system added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels May 25, 2022
@Constellation Constellation added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels May 25, 2022
@webkit-early-warning-system webkit-early-warning-system merged commit 60a5bb3 into WebKit:main May 25, 2022
@webkit-early-warning-system
Copy link
Collaborator

Committed r294794 (250952@main): https://commits.webkit.org/250952@main

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

@webkit-early-warning-system webkit-early-warning-system removed the merge-queue Applied to send a pull request to merge-queue label May 25, 2022
@gezalore gezalore deleted the fprs branch May 25, 2022 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.
Projects
None yet
4 participants