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] Add operationIteratorNextTryFast operation #26232

Conversation

Constellation
Copy link
Member

@Constellation Constellation commented Mar 21, 2024

a50b786

[JSC] Add operationIteratorNextTryFast operation
https://bugs.webkit.org/show_bug.cgi?id=271367
rdar://125151326

Reviewed by Keith Miller.

This function is very hot since it is invoked for each iteration run for fast arrays.
Let's make it extremely optimized: use JITOperations instead of slow path calls.

* Source/JavaScriptCore/jit/JITCall.cpp:
(JSC::JIT::emit_op_iterator_next):
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/jit/JITOperations.h:

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

433b634

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-skia
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 tv ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 tv-sim ✅ 🧪 api-gtk
✅ 🛠 watch ✅ 🛠 jsc-armv7
✅ 🛠 🧪 unsafe-merge ✅ 🛠 watch-sim ✅ 🧪 jsc-armv7-tests

@Constellation Constellation self-assigned this Mar 21, 2024
@Constellation Constellation added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Mar 21, 2024
@Constellation Constellation force-pushed the eng/JSC-Add-operationIteratorNextTryFast-operation branch from 60717cf to 433b634 Compare March 21, 2024 09:14
@Constellation Constellation marked this pull request as ready for review March 21, 2024 09:14
@Constellation Constellation requested a review from a team as a code owner March 21, 2024 09:14
JITSlowPathCall slowPathCall(this, tryFastFunction);
slowPathCall.call();
Jump fastCase = branch32(NotEqual, GPRInfo::returnValueGPR2, TrustedImm32(static_cast<uint32_t>(IterationMode::Generic)));
#endif
doneCases.append(jump());
Copy link
Contributor

Choose a reason for hiding this comment

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

So, iteratorNextTryFastImpl always returns IterationMode::FastArray. That's why no need for additional iteration mode check like before for the slowPathCall.call() path.

callOperation(operationIteratorNextTryFast, argumentGPR0, argumentGPR1, argumentGPR2, argumentGPR3);
emitPutVirtualRegister(bytecode.m_done, returnValueGPR);
emitPutVirtualRegister(bytecode.m_value, returnValueGPR2);
doneCases.append(branchIfEmpty(JSValueRegs { returnValueGPR2 }));
Copy link
Contributor

@hyjorc1 hyjorc1 Mar 21, 2024

Choose a reason for hiding this comment

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

Should it be branchIfNotEmpty? Since returnValueGPR2 is the next value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, nvm we don't need to update the value profile if it's empty.

Copy link
Contributor

@kmiller68 kmiller68 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.

@Constellation Constellation added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Mar 22, 2024
https://bugs.webkit.org/show_bug.cgi?id=271367
rdar://125151326

Reviewed by Keith Miller.

This function is very hot since it is invoked for each iteration run for fast arrays.
Let's make it extremely optimized: use JITOperations instead of slow path calls.

* Source/JavaScriptCore/jit/JITCall.cpp:
(JSC::JIT::emit_op_iterator_next):
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/jit/JITOperations.h:

Canonical link: https://commits.webkit.org/276577@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/JSC-Add-operationIteratorNextTryFast-operation branch from 433b634 to a50b786 Compare March 22, 2024 23:08
@webkit-commit-queue
Copy link
Collaborator

Committed 276577@main (a50b786): https://commits.webkit.org/276577@main

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

@webkit-commit-queue webkit-commit-queue merged commit a50b786 into WebKit:main Mar 22, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Mar 22, 2024
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