summaryrefslogtreecommitdiffstats
path: root/libs/wpewebkit/patches/136-JavaScriptCore-IPInt-enable-validation-on-RISCV64.patch
blob: 257e32291097d90c70836e2dcb3e355384c21bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From dbcd5544fb81262c7135f68b5e44dcccd602d847 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Wed, 23 Sep 2026 14:33:27 +0100
Subject: [PATCH] JavaScriptCore: enable IPInt opcode validation on RISCV64

IPInt::initialize() and verifyInitialization() only build their opcode
dispatch tables for ARM64, X86_64 and ARMv7, and abort on anything else.
With the IPInt RISCV64 port the offlineasm entry points do exist, so add
CPU(RISCV64) to the three guards.

Replace the RELEASE_ASSERT_NOT_REACHED() in the fallback branch with a
plain return. LLInt::initialize() calls initialize() unconditionally, and
on an architecture without the dispatch table there is simply nothing to
validate; Options::useWasmIPInt is forced false there, so the
uninitialised base pointers are never read at run time.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 Source/JavaScriptCore/llint/InPlaceInterpreter.cpp | 12 +++++++++---
 Source/JavaScriptCore/llint/InPlaceInterpreter.h   |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

--- a/Source/JavaScriptCore/llint/InPlaceInterpreter.cpp
+++ b/Source/JavaScriptCore/llint/InPlaceInterpreter.cpp
@@ -77,7 +77,7 @@ do { \
 
 void initialize()
 {
-#if !ENABLE(C_LOOP) && (CPU(ADDRESS64) && (CPU(ARM64) || CPU(X86_64)))
+#if !ENABLE(C_LOOP) && (CPU(ADDRESS64) && (CPU(ARM64) || CPU(X86_64) || CPU(RISCV64)))
 
 #define INIT_IPINT_BASE_POINTER(basePointerName, targetAddress) \
     g_opcodeConfig.basePointerName = removeCodePtrTag(reinterpret_cast<void*>(targetAddress));
@@ -95,13 +95,19 @@ void initialize()
     FOR_EACH_IPINT_MINT_RETURN_OPCODE(VALIDATE_IPINT_MINT_RETURN_OPCODE);
     FOR_EACH_IPINT_UINT_OPCODE(VALIDATE_IPINT_UINT_OPCODE);
 #else
-    RELEASE_ASSERT_NOT_REACHED("IPInt only supports ARM64 and X86_64 (for now).");
+    // No IPInt opcode dispatch table on this architecture: offlineasm
+    // does not emit the ipint_*_validate entry points outside the guard
+    // above, so there is nothing to validate. LLInt::initialize() calls
+    // us unconditionally; just return. Options::useWasmIPInt is forced
+    // false on such architectures (see Options.cpp), so the
+    // (uninitialised) g_opcodeConfig dispatch base pointers are never
+    // read at run time.
 #endif
 }
 
 void verifyInitialization()
 {
-#if !ENABLE(C_LOOP) && (CPU(ADDRESS64) && (CPU(ARM64) || CPU(X86_64)))
+#if !ENABLE(C_LOOP) && (CPU(ADDRESS64) && (CPU(ARM64) || CPU(X86_64) || CPU(RISCV64)))
 
 #define VERIFY_IPINT_BASE_POINTER(basePointerName, targetAddress) \
     RELEASE_ASSERT(g_opcodeConfig.basePointerName == removeCodePtrTag(reinterpret_cast<void*>(targetAddress)));
--- a/Source/JavaScriptCore/llint/InPlaceInterpreter.h
+++ b/Source/JavaScriptCore/llint/InPlaceInterpreter.h
@@ -783,7 +783,7 @@ extern "C" void SYSV_ABI ipint_entry();
     m(0x11, uint_stack_vector) \
     m(0x12, uint_ret) \
 
-#if !ENABLE(C_LOOP) && (CPU(ADDRESS64) && (CPU(ARM64) || CPU(X86_64)))
+#if !ENABLE(C_LOOP) && (CPU(ADDRESS64) && (CPU(ARM64) || CPU(X86_64) || CPU(RISCV64)))
 FOR_EACH_IPINT_OPCODE(IPINT_VALIDATE_DEFINE_FUNCTION);
 FOR_EACH_IPINT_GC_OPCODE(IPINT_VALIDATE_DEFINE_FUNCTION);
 FOR_EACH_IPINT_CONVERSION_OPCODE(IPINT_VALIDATE_DEFINE_FUNCTION);