Title: [293653] trunk/Source/_javascript_Core
- Revision
- 293653
- Author
- [email protected]
- Date
- 2022-05-01 08:05:52 -0700 (Sun, 01 May 2022)
Log Message
[RISCV64] Enable testmasm execution
https://bugs.webkit.org/show_bug.cgi?id=239937
Reviewed by Yusuke Suzuki.
In testmasm, enable some additional sets of tests for RISCV64 that cover
already-functioning behavior. In isSpecialGPR(), the function returns
true under CPU(RISCV64) for the appropriate registers.
In invoke(), when targeting RISCV64 and invoking JIT-produced code whose
return type is a 32-bit integer, the resulting value is manually
sign-extended to paper over the mismatch between zero-extended 32-bit
values that are used and produced in JSC JIT and the sign-extended
32-bit values that are expected in the RV64 calling convention.
* assembler/testmasm.cpp:
(JSC::isSpecialGPR):
(JSC::invoke):
(JSC::testProbePreservesGPRS):
(JSC::testLoadBaseIndex):
(JSC::testStoreBaseIndex):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (293652 => 293653)
--- trunk/Source/_javascript_Core/ChangeLog 2022-05-01 14:18:07 UTC (rev 293652)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-05-01 15:05:52 UTC (rev 293653)
@@ -1,3 +1,27 @@
+2022-05-01 Zan Dobersek <[email protected]>
+
+ [RISCV64] Enable testmasm execution
+ https://bugs.webkit.org/show_bug.cgi?id=239937
+
+ Reviewed by Yusuke Suzuki.
+
+ In testmasm, enable some additional sets of tests for RISCV64 that cover
+ already-functioning behavior. In isSpecialGPR(), the function returns
+ true under CPU(RISCV64) for the appropriate registers.
+
+ In invoke(), when targeting RISCV64 and invoking JIT-produced code whose
+ return type is a 32-bit integer, the resulting value is manually
+ sign-extended to paper over the mismatch between zero-extended 32-bit
+ values that are used and produced in JSC JIT and the sign-extended
+ 32-bit values that are expected in the RV64 calling convention.
+
+ * assembler/testmasm.cpp:
+ (JSC::isSpecialGPR):
+ (JSC::invoke):
+ (JSC::testProbePreservesGPRS):
+ (JSC::testLoadBaseIndex):
+ (JSC::testStoreBaseIndex):
+
2022-04-29 Chris Dumez <[email protected]>
Unreviewed, reverting r293621.
Modified: trunk/Source/_javascript_Core/assembler/testmasm.cpp (293652 => 293653)
--- trunk/Source/_javascript_Core/assembler/testmasm.cpp 2022-05-01 14:18:07 UTC (rev 293652)
+++ trunk/Source/_javascript_Core/assembler/testmasm.cpp 2022-05-01 15:05:52 UTC (rev 293653)
@@ -74,7 +74,7 @@
}
-#if CPU(X86) || CPU(X86_64) || CPU(ARM64)
+#if CPU(X86) || CPU(X86_64) || CPU(ARM64) || CPU(RISCV64)
static Vector<float> floatOperands()
{
return Vector<float> {
@@ -220,6 +220,9 @@
#elif CPU(MIPS)
if (id == MIPSRegisters::zero || id == MIPSRegisters::k0 || id == MIPSRegisters::k1)
return true;
+#elif CPU(RISCV64)
+ if (id == RISCV64Registers::zero || id == RISCV64Registers::ra || id == RISCV64Registers::gp || id == RISCV64Registers::tp)
+ return true;
#endif
return false;
}
@@ -237,6 +240,24 @@
{
void* executableAddress = untagCFunctionPtr<JSEntryPtrTag>(code.code().executableAddress());
T (*function)(Arguments...) = bitwise_cast<T(*)(Arguments...)>(executableAddress);
+
+#if CPU(RISCV64)
+ // RV64 calling convention requires all 32-bit values to be sign-extended into the whole register.
+ // JSC JIT is tailored for other ISAs that pass these values in 32-bit-wide registers, which RISC-V
+ // doesn't support, so any 32-bit value passed in return-value registers has to be manually sign-extended.
+ // This mirrors sign-extension of 32-bit values in argument registers on RV64 in CCallHelpers.h.
+ if constexpr (std::is_integral_v<T>) {
+ T returnValue = function(arguments...);
+ if constexpr (sizeof(T) == 4) {
+ asm volatile(
+ "sext.w %[out_value], %[in_value]\n\t"
+ : [out_value] "=r" (returnValue)
+ : [in_value] "r" (returnValue));
+ }
+ return returnValue;
+ }
+#endif
+
return function(arguments...);
}
@@ -2947,7 +2968,7 @@
}
#endif
-#if CPU(X86) || CPU(X86_64) || CPU(ARM64)
+#if CPU(X86) || CPU(X86_64) || CPU(ARM64) || CPU(RISCV64)
void testCompareFloat(MacroAssembler::DoubleCondition condition)
{
float arg1 = 0;
@@ -4684,11 +4705,12 @@
continue;
CHECK_EQ(cpu.gpr(id), testWord(id));
}
- for (auto id = CCallHelpers::firstFPRegister(); id <= CCallHelpers::lastFPRegister(); id = nextID(id))
+ for (auto id = CCallHelpers::firstFPRegister(); id <= CCallHelpers::lastFPRegister(); id = nextID(id)) {
#if CPU(MIPS)
if (!(id & 1))
#endif
CHECK_EQ(cpu.fpr<uint64_t>(id), testWord64(id));
+ }
});
// Restore the original state.
@@ -5226,7 +5248,7 @@
void testLoadBaseIndex()
{
-#if CPU(ARM64) || CPU(X86_64)
+#if CPU(ARM64) || CPU(X86_64) || CPU(RISCV64)
// load64
{
auto test = compile([=](CCallHelpers& jit) {
@@ -5407,7 +5429,7 @@
void testStoreBaseIndex()
{
-#if CPU(ARM64) || CPU(X86_64)
+#if CPU(ARM64) || CPU(X86_64) || CPU(RISCV64)
// store64
{
auto test = compile([=](CCallHelpers& jit) {
@@ -5877,7 +5899,7 @@
RUN(testAtomicStrongCASFill16());
#endif
-#if CPU(X86) || CPU(X86_64) || CPU(ARM64)
+#if CPU(X86) || CPU(X86_64) || CPU(ARM64) || CPU(RISCV64)
FOR_EACH_DOUBLE_CONDITION_RUN(testCompareFloat);
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes