Title: [289740] trunk/Source/_javascript_Core
- Revision
- 289740
- Author
- [email protected]
- Date
- 2022-02-14 10:39:19 -0800 (Mon, 14 Feb 2022)
Log Message
CallLinkInfo::emitFastPathImpl() should avoid external scratch register use on RISCV64
https://bugs.webkit.org/show_bug.cgi?id=236064
Patch by Zan Dobersek <[email protected]> on 2022-02-14
Reviewed by Yusuke Suzuki.
Avoid external scratch register usage in CallLinkInfo::emitFastPathImpl()
for RISCV64 since the scratch register ends up having to be used in the
branchTestPtr implementation of RISCV64's MacroAssembler.
The RISCV64-specific alternative is to suffer resolving and loading from
the callee address for both branching operations. Other platforms
continue to operate with the external scratch register as they either
use a wider set of scratch registers or don't even have to use scratch
registers for the load and branching operations used here.
* assembler/CPU.h: Add isRISCV64(). Also impose a more sensible order.
(JSC::isMIPS):
(JSC::isRISCV64):
* bytecode/CallLinkInfo.cpp:
(JSC::CallLinkInfo::emitFastPathImpl):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (289739 => 289740)
--- trunk/Source/_javascript_Core/ChangeLog 2022-02-14 17:58:13 UTC (rev 289739)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-02-14 18:39:19 UTC (rev 289740)
@@ -1,3 +1,26 @@
+2022-02-14 Zan Dobersek <[email protected]>
+
+ CallLinkInfo::emitFastPathImpl() should avoid external scratch register use on RISCV64
+ https://bugs.webkit.org/show_bug.cgi?id=236064
+
+ Reviewed by Yusuke Suzuki.
+
+ Avoid external scratch register usage in CallLinkInfo::emitFastPathImpl()
+ for RISCV64 since the scratch register ends up having to be used in the
+ branchTestPtr implementation of RISCV64's MacroAssembler.
+
+ The RISCV64-specific alternative is to suffer resolving and loading from
+ the callee address for both branching operations. Other platforms
+ continue to operate with the external scratch register as they either
+ use a wider set of scratch registers or don't even have to use scratch
+ registers for the load and branching operations used here.
+
+ * assembler/CPU.h: Add isRISCV64(). Also impose a more sensible order.
+ (JSC::isMIPS):
+ (JSC::isRISCV64):
+ * bytecode/CallLinkInfo.cpp:
+ (JSC::CallLinkInfo::emitFastPathImpl):
+
2022-02-13 Lauro Moura <[email protected]>
Unreviewed, non-unified build fixes
Modified: trunk/Source/_javascript_Core/assembler/CPU.h (289739 => 289740)
--- trunk/Source/_javascript_Core/assembler/CPU.h 2022-02-14 17:58:13 UTC (rev 289739)
+++ trunk/Source/_javascript_Core/assembler/CPU.h 2022-02-14 18:39:19 UTC (rev 289740)
@@ -78,6 +78,24 @@
#endif
}
+constexpr bool isMIPS()
+{
+#if CPU(MIPS)
+ return true;
+#else
+ return false;
+#endif
+}
+
+constexpr bool isRISCV64()
+{
+#if CPU(RISCV64)
+ return true;
+#else
+ return false;
+#endif
+}
+
constexpr bool is64Bit()
{
#if USE(JSVALUE64)
@@ -102,15 +120,6 @@
return !isAddress64Bit();
}
-constexpr bool isMIPS()
-{
-#if CPU(MIPS)
- return true;
-#else
- return false;
-#endif
-}
-
inline bool optimizeForARMv7IDIVSupported()
{
return isARMv7IDIVSupported() && Options::useArchitectureSpecificOptimizations();
Modified: trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp (289739 => 289740)
--- trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp 2022-02-14 17:58:13 UTC (rev 289739)
+++ trunk/Source/_javascript_Core/bytecode/CallLinkInfo.cpp 2022-02-14 18:39:19 UTC (rev 289740)
@@ -342,17 +342,24 @@
CCallHelpers::JumpList slowPath;
if (useDataIC == UseDataIC::Yes) {
- // FIXME: This scratch register is not generally safe to use on ARMv7, as the macro
- // assembler always assumes it is available. At the moment, it does happen to work
- // with the code below.
- GPRReg scratchGPR = jit.scratchRegister();
- jit.loadPtr(CCallHelpers::Address(callLinkInfoGPR, offsetOfCallee()), scratchGPR);
CCallHelpers::Jump goPolymorphic;
- {
+
+ // For RISCV64, scratch register usage here collides with MacroAssembler's internal usage
+ // that's necessary for the test-and-branch operation but is avoidable by loading from the callee
+ // address for each branch operation. Other MacroAssembler implementations handle this better by
+ // using a wider range of scratch registers or more potent branching instructions.
+ if constexpr (isRISCV64()) {
+ CCallHelpers::Address calleeAddress(callLinkInfoGPR, offsetOfCallee());
+ goPolymorphic = jit.branchTestPtr(CCallHelpers::NonZero, calleeAddress, CCallHelpers::TrustedImm32(polymorphicCalleeMask));
+ slowPath.append(jit.branchPtr(CCallHelpers::NotEqual, calleeAddress, calleeGPR));
+ } else {
+ GPRReg scratchGPR = jit.scratchRegister();
DisallowMacroScratchRegisterUsage disallowScratch(jit);
+ jit.loadPtr(CCallHelpers::Address(callLinkInfoGPR, offsetOfCallee()), scratchGPR);
goPolymorphic = jit.branchTestPtr(CCallHelpers::NonZero, scratchGPR, CCallHelpers::TrustedImm32(polymorphicCalleeMask));
slowPath.append(jit.branchPtr(CCallHelpers::NotEqual, scratchGPR, calleeGPR));
}
+
if (isTailCall) {
prepareForTailCall();
goPolymorphic.link(&jit); // Polymorphic stub handles tail call stack prep.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes