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] Clean up wasm AirIRGenerator FP truncation #4539

Conversation

jjgriego
Copy link
Contributor

@jjgriego jjgriego commented Sep 20, 2022

b07e2d5

[JSC] Clean up wasm AirIRGenerator FP truncation
https://bugs.webkit.org/show_bug.cgi?id=245436

Reviewed by Justin Michaud.

The implementation for all of the (checked and saturated) floating point to
integer truncations ends up being really duplicative--we have code for the
patchpoints to generate the appropriate instructions twice for each flavor of
this operation and code for the bounds checking needed is duplicated many times.

This patch adds a new method for generating only the code for an unchecked
truncation; a table of the output ranges for each flavor, and uses both to have
a single implementation for both the checked and saturating versions of each
truncation instruction.

Also avoids clobbering the macro scratch registers on ARM64 for some variants of
the truncation (the ones resulting in U64s) since the macro assembler doesn't
seem to actually need them on that architecture.

Relying on the existing test suite; this shouldn't really change the generated
code, except for the change to the macro scratch register clobbers on ARM64.

* Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::lookupTruncationRange):
(JSC::Wasm::AirIRGenerator::addUncheckedFloatingPointTruncation):
(JSC::Wasm::AirIRGenerator::truncSaturated):
(JSC::Wasm::AirIRGenerator::addCheckedFloatingPointTruncation):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>):

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

01380fd

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

@jjgriego jjgriego self-assigned this Sep 20, 2022
@jjgriego jjgriego added JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. WebKit Nightly Build labels Sep 20, 2022
@jjgriego jjgriego force-pushed the eng/JSC-Clean-up-wasm-AirIRGenerator-FP-truncation branch from 0e64991 to 4e5598d Compare September 20, 2022 17:33
@jjgriego jjgriego marked this pull request as ready for review September 20, 2022 17:38
@jjgriego jjgriego requested a review from a team as a code owner September 20, 2022 17:38
Copy link
Contributor

@justinmichaud justinmichaud 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

@jjgriego jjgriego force-pushed the eng/JSC-Clean-up-wasm-AirIRGenerator-FP-truncation branch from 4e5598d to 2195b79 Compare September 23, 2022 20:43
@jjgriego
Copy link
Contributor Author

jjgriego commented Sep 23, 2022

(^ rebase and fix typo in comment)

@jjgriego jjgriego force-pushed the eng/JSC-Clean-up-wasm-AirIRGenerator-FP-truncation branch from 2195b79 to 01380fd Compare September 26, 2022 14:54
@aperezdc aperezdc added the merge-queue Applied to send a pull request to merge-queue label Sep 26, 2022
https://bugs.webkit.org/show_bug.cgi?id=245436

Reviewed by Justin Michaud.

The implementation for all of the (checked and saturated) floating point to
integer truncations ends up being really duplicative--we have code for the
patchpoints to generate the appropriate instructions twice for each flavor of
this operation and code for the bounds checking needed is duplicated many times.

This patch adds a new method for generating only the code for an unchecked
truncation; a table of the output ranges for each flavor, and uses both to have
a single implementation for both the checked and saturating versions of each
truncation instruction.

Also avoids clobbering the macro scratch registers on ARM64 for some variants of
the truncation (the ones resulting in U64s) since the macro assembler doesn't
seem to actually need them on that architecture.

Relying on the existing test suite; this shouldn't really change the generated
code, except for the change to the macro scratch register clobbers on ARM64.

* Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::lookupTruncationRange):
(JSC::Wasm::AirIRGenerator::addUncheckedFloatingPointTruncation):
(JSC::Wasm::AirIRGenerator::truncSaturated):
(JSC::Wasm::AirIRGenerator::addCheckedFloatingPointTruncation):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>):

Canonical link: https://commits.webkit.org/254875@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/JSC-Clean-up-wasm-AirIRGenerator-FP-truncation branch from 01380fd to b07e2d5 Compare September 26, 2022 20:17
@webkit-commit-queue
Copy link
Collaborator

Committed 254875@main (b07e2d5): https://commits.webkit.org/254875@main

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

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Sep 26, 2022
@webkit-early-warning-system webkit-early-warning-system merged commit b07e2d5 into WebKit:main Sep 26, 2022
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
5 participants