Title: [287466] trunk/Source/_javascript_Core
Revision
287466
Author
commit-qu...@webkit.org
Date
2021-12-28 01:31:17 -0800 (Tue, 28 Dec 2021)

Log Message

[RISCV64] Add MacroAssemblerRISCV64 operations with patchable elements
https://bugs.webkit.org/show_bug.cgi?id=234635

Patch by Zan Dobersek <zdober...@igalia.com> on 2021-12-28
Reviewed by Yusuke Suzuki.

Add MacroAssemblerRISCV64 implementations for operations that generate
patchable code sections. This covers moves, stores and branches.

For moves and stores of pointer values, the patchable section is
achieved by generating a immediate loader instruction sequence with all
the placeholder instructions (nops) included.

Some methods that had their noop implementations provided until now have
been removed since they are not necessary anymore.

* assembler/MacroAssemblerRISCV64.h:
(JSC::MacroAssemblerRISCV64::moveWithPatch):
(JSC::MacroAssemblerRISCV64::storePtrWithPatch):
(JSC::MacroAssemblerRISCV64::branch32WithPatch):
(JSC::MacroAssemblerRISCV64::branchPtrWithPatch):
(JSC::MacroAssemblerRISCV64::patchableBranch64):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (287465 => 287466)


--- trunk/Source/_javascript_Core/ChangeLog	2021-12-28 09:06:36 UTC (rev 287465)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-12-28 09:31:17 UTC (rev 287466)
@@ -1,5 +1,29 @@
 2021-12-28  Zan Dobersek  <zdober...@igalia.com>
 
+        [RISCV64] Add MacroAssemblerRISCV64 operations with patchable elements
+        https://bugs.webkit.org/show_bug.cgi?id=234635
+
+        Reviewed by Yusuke Suzuki.
+
+        Add MacroAssemblerRISCV64 implementations for operations that generate
+        patchable code sections. This covers moves, stores and branches.
+
+        For moves and stores of pointer values, the patchable section is
+        achieved by generating a immediate loader instruction sequence with all
+        the placeholder instructions (nops) included.
+
+        Some methods that had their noop implementations provided until now have
+        been removed since they are not necessary anymore.
+
+        * assembler/MacroAssemblerRISCV64.h:
+        (JSC::MacroAssemblerRISCV64::moveWithPatch):
+        (JSC::MacroAssemblerRISCV64::storePtrWithPatch):
+        (JSC::MacroAssemblerRISCV64::branch32WithPatch):
+        (JSC::MacroAssemblerRISCV64::branchPtrWithPatch):
+        (JSC::MacroAssemblerRISCV64::patchableBranch64):
+
+2021-12-28  Zan Dobersek  <zdober...@igalia.com>
+
         [RISCV64] Enable signal-based VM traps for CPU(RISCV64)
         https://bugs.webkit.org/show_bug.cgi?id=234719
 

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerRISCV64.h (287465 => 287466)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerRISCV64.h	2021-12-28 09:06:36 UTC (rev 287465)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerRISCV64.h	2021-12-28 09:31:17 UTC (rev 287466)
@@ -1033,11 +1033,6 @@
         store32(src2, Address(dest, offset.m_value + 4));
     }
 
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(load64WithAddressOffsetPatch, DataLabel32);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(load64WithCompactAddressOffsetPatch, DataLabelCompact);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(store64WithAddressOffsetPatch, DataLabel32);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(storePtrWithPatch, DataLabelPtr);
-
     void zeroExtend8To32(RegisterID src, RegisterID dest)
     {
         m_assembler.slliInsn<56>(dest, src);
@@ -1933,16 +1928,73 @@
 
     MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(branchPtr, Jump);
 
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(moveWithPatch, DataLabel32);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(moveWithPatch, DataLabelPtr);
+    DataLabel32 moveWithPatch(TrustedImm32 imm, RegisterID dest)
+    {
+        RISCV64Assembler::ImmediateLoader imml(RISCV64Assembler::ImmediateLoader::Placeholder, imm.m_value);
 
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(branch32WithPatch, Jump);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(branchPtrWithPatch, Jump);
+        DataLabel32 label(this);
+        imml.moveInto(m_assembler, dest);
+        return label;
+    }
 
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(patchableBranch8, PatchableJump);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(patchableBranch32, PatchableJump);
-    MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(patchableBranch64, PatchableJump);
+    DataLabelPtr moveWithPatch(TrustedImmPtr imm, RegisterID dest)
+    {
+        RISCV64Assembler::ImmediateLoader imml(RISCV64Assembler::ImmediateLoader::Placeholder, int64_t(imm.asIntptr()));
 
+        DataLabelPtr label(this);
+        imml.moveInto(m_assembler, dest);
+        return label;
+    }
+
+    DataLabelPtr storePtrWithPatch(TrustedImmPtr initialValue, Address address)
+    {
+        auto temp = temps<Data, Memory>();
+        RISCV64Assembler::ImmediateLoader imml(RISCV64Assembler::ImmediateLoader::Placeholder, int64_t(initialValue.asIntptr()));
+        DataLabelPtr label(this);
+        imml.moveInto(m_assembler, temp.data());
+
+        auto resolution = resolveAddress(address, temp.memory());
+        m_assembler.sdInsn(resolution.base, temp.data(), Imm::S(resolution.offset));
+        return label;
+    }
+
+    DataLabelPtr storePtrWithPatch(Address address)
+    {
+        return storePtrWithPatch(TrustedImmPtr(nullptr), address);
+    }
+
+    Jump branch32WithPatch(RelationalCondition cond, Address address, DataLabel32& dataLabel, TrustedImm32 initialRightValue = TrustedImm32(0))
+    {
+        auto temp = temps<Data, Memory>();
+        auto resolution = resolveAddress(address, temp.memory());
+        m_assembler.lwInsn(temp.memory(), resolution.base, Imm::I(resolution.offset));
+
+        dataLabel = moveWithPatch(initialRightValue, temp.data());
+        return makeBranch(cond, temp.memory(), temp.data());
+    }
+
+    Jump branchPtrWithPatch(RelationalCondition cond, Address address, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(nullptr))
+    {
+        auto temp = temps<Data, Memory>();
+        auto resolution = resolveAddress(address, temp.memory());
+        m_assembler.ldInsn(temp.memory(), resolution.base, Imm::I(resolution.offset));
+
+        dataLabel = moveWithPatch(initialRightValue, temp.data());
+        return makeBranch(cond, temp.memory(), temp.data());
+    }
+
+    Jump branchPtrWithPatch(RelationalCondition cond, RegisterID lhs, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(nullptr))
+    {
+        auto temp = temps<Data>();
+        dataLabel = moveWithPatch(initialRightValue, temp.data());
+        return makeBranch(cond, lhs, temp.data());
+    }
+
+    PatchableJump patchableBranch64(RelationalCondition cond, RegisterID left, RegisterID right)
+    {
+        return PatchableJump(branch64(cond, left, right));
+    }
+
     MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(branchFloat, Jump);
     MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(branchDouble, Jump);
     MACRO_ASSEMBLER_RISCV64_TEMPLATED_NOOP_METHOD_WITH_RETURN(branchDoubleNonZero, Jump);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to