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

BBQJIT's ScratchScope should always lock preseverved registers #14941

Conversation

kmiller68
Copy link
Contributor

@kmiller68 kmiller68 commented Jun 14, 2023

3465968

BBQJIT's ScratchScope should always lock preseverved registers
https://bugs.webkit.org/show_bug.cgi?id=258044

Reviewed by Yusuke Suzuki.

Right now if a preserved location/register is already bound to a Location then we don't lock its slot. By not locking however, when we go to allocate any requested scratches we could choose one of the preserved registers to evict. This patch fixes this by always locking the preserved locations.

Additionally, some places where we were using ScratchScope to lock nonArgumentNonPreservedGPR1 can now use ScratchScope to get a non-argument non-preserved register. This is done by preserving all argument GPRs then immediately releasing them via a new unbindPreserved method.

* Source/JavaScriptCore/wasm/WasmBBQJIT.cpp:
(JSC::Wasm::BBQJIT::addIf):
(JSC::Wasm::BBQJIT::emitIndirectCall):
(JSC::Wasm::BBQJIT::addCallIndirect):
(JSC::Wasm::BBQJIT::addCallRef):
(JSC::Wasm::BBQJIT::ScratchScope::ScratchScope):
(JSC::Wasm::BBQJIT::ScratchScope::~ScratchScope):
(JSC::Wasm::BBQJIT::ScratchScope::unbindEarly):
(JSC::Wasm::BBQJIT::ScratchScope::unbindScratches):
(JSC::Wasm::BBQJIT::ScratchScope::unbindPreserved):
(JSC::Wasm::BBQJIT::ScratchScope::gpr const):
(JSC::Wasm::BBQJIT::ScratchScope::fpr const):
(JSC::Wasm::BBQJIT::ScratchScope::unbind): Deleted.

Canonical link: https://commits.webkit.org/265159@main

2364132

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1   πŸ§ͺ gtk-wk2
  πŸ›  πŸ§ͺ jsc   πŸ§ͺ api-ios   πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ jsc-arm64   πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ›  jsc-armv7
  πŸ›  tv-sim   πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch βœ… πŸ›  jsc-mips
βœ… πŸ›  watch-sim βœ… πŸ§ͺ jsc-mips-tests

@kmiller68 kmiller68 requested a review from a team as a code owner June 14, 2023 00:40
@kmiller68 kmiller68 self-assigned this Jun 14, 2023
@kmiller68 kmiller68 added the WebAssembly For bugs in JavaScript WebAssembly label Jun 14, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 14, 2023
@kmiller68 kmiller68 removed the merging-blocked Applied to prevent a change from being merged label Jun 14, 2023
@kmiller68 kmiller68 force-pushed the eng/BBQJITs-ScratchScope-should-always-lock-preseverved-registers branch from 252f393 to 7cbccc1 Compare June 14, 2023 16:27
Comment on lines 10065 to 10083
m_generator.m_fprLRU.lock(reg);
binding = RegisterBinding::scratch();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll keep the old order before committing.

Copy link
Contributor

@ddegazio ddegazio left a comment

Choose a reason for hiding this comment

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

LGTM!

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

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 14, 2023
@kmiller68 kmiller68 removed the merging-blocked Applied to prevent a change from being merged label Jun 14, 2023
@kmiller68 kmiller68 force-pushed the eng/BBQJITs-ScratchScope-should-always-lock-preseverved-registers branch from 7cbccc1 to 2364132 Compare June 14, 2023 18:38
@kmiller68 kmiller68 added the merge-queue Applied to send a pull request to merge-queue label Jun 14, 2023
https://bugs.webkit.org/show_bug.cgi?id=258044

Reviewed by Yusuke Suzuki.

Right now if a preserved location/register is already bound to a Location then we don't lock its slot. By not locking however, when we go to allocate any requested scratches we could choose one of the preserved registers to evict. This patch fixes this by always locking the preserved locations.

Additionally, some places where we were using ScratchScope to lock nonArgumentNonPreservedGPR1 can now use ScratchScope to get a non-argument non-preserved register. This is done by preserving all argument GPRs then immediately releasing them via a new unbindPreserved method.

* Source/JavaScriptCore/wasm/WasmBBQJIT.cpp:
(JSC::Wasm::BBQJIT::addIf):
(JSC::Wasm::BBQJIT::emitIndirectCall):
(JSC::Wasm::BBQJIT::addCallIndirect):
(JSC::Wasm::BBQJIT::addCallRef):
(JSC::Wasm::BBQJIT::ScratchScope::ScratchScope):
(JSC::Wasm::BBQJIT::ScratchScope::~ScratchScope):
(JSC::Wasm::BBQJIT::ScratchScope::unbindEarly):
(JSC::Wasm::BBQJIT::ScratchScope::unbindScratches):
(JSC::Wasm::BBQJIT::ScratchScope::unbindPreserved):
(JSC::Wasm::BBQJIT::ScratchScope::gpr const):
(JSC::Wasm::BBQJIT::ScratchScope::fpr const):
(JSC::Wasm::BBQJIT::ScratchScope::unbind): Deleted.

Canonical link: https://commits.webkit.org/265159@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/BBQJITs-ScratchScope-should-always-lock-preseverved-registers branch from 2364132 to 3465968 Compare June 14, 2023 19:16
@webkit-commit-queue
Copy link
Collaborator

Committed 265159@main (3465968): https://commits.webkit.org/265159@main

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

@webkit-commit-queue webkit-commit-queue merged commit 3465968 into WebKit:main Jun 14, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAssembly For bugs in JavaScript WebAssembly
Projects
None yet
6 participants