-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(patches): apply the LuaJIT ARM64 LDP/STP fusion fix from LuaJIT (…
…#11537) upstream LuaJIT/LuaJIT@b8c6ccd KAG-2473 (cherry picked from commit b0ca424)
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
message: "Fix incorrect LuaJIT LDP/STP fusion on ARM64 which may sometimes cause incorrect logic" | ||
type: dependency | ||
scope: Core | ||
prs: | ||
jiras: | ||
- "KAG-2473" |
46 changes: 46 additions & 0 deletions
46
build/openresty/patches/LuaJIT-2.1-20220411_06_ldp_stp_fusion.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
From b8c6ccd50c61b7a2df5123ddc5a85ac7d089542b Mon Sep 17 00:00:00 2001 | ||
From: Mike Pall <mike> | ||
Date: Sat, 9 Sep 2023 18:01:37 +0200 | ||
Subject: [PATCH] ARM64: Fix LDP/STP fusion (again). | ||
|
||
Reported and analyzed by Zhongwei Yao. Fix by Peter Cawley. #1075 | ||
--- | ||
src/lj_emit_arm64.h | 17 +++++++++++++---- | ||
1 file changed, 13 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/bundle/LuaJIT-2.1-20220411/src/lj_emit_arm64.h b/bundle/LuaJIT-2.1-20220411/src/lj_emit_arm64.h | ||
index d4c542557..9161c9582 100644 | ||
--- a/bundle/LuaJIT-2.1-20220411/src/lj_emit_arm64.h | ||
+++ b/bundle/LuaJIT-2.1-20220411/src/lj_emit_arm64.h | ||
@@ -113,6 +113,17 @@ static int emit_checkofs(A64Ins ai, int64_t ofs) | ||
} | ||
} | ||
|
||
+static LJ_AINLINE uint32_t emit_lso_pair_candidate(A64Ins ai, int ofs, int sc) | ||
+{ | ||
+ if (ofs >= 0) { | ||
+ return ai | A64F_U12(ofs>>sc); /* Subsequent lj_ror checks ofs. */ | ||
+ } else if (ofs >= -256) { | ||
+ return (ai^A64I_LS_U) | A64F_S9(ofs & 0x1ff); | ||
+ } else { | ||
+ return A64F_D(31); /* Will mismatch prev. */ | ||
+ } | ||
+} | ||
+ | ||
static void emit_lso(ASMState *as, A64Ins ai, Reg rd, Reg rn, int64_t ofs) | ||
{ | ||
int ot = emit_checkofs(ai, ofs), sc = (ai >> 30) & 3; | ||
@@ -124,11 +135,9 @@ static void emit_lso(ASMState *as, A64Ins ai, Reg rd, Reg rn, int64_t ofs) | ||
uint32_t prev = *as->mcp & ~A64F_D(31); | ||
int ofsm = ofs - (1<<sc), ofsp = ofs + (1<<sc); | ||
A64Ins aip; | ||
- if (prev == (ai | A64F_N(rn) | A64F_U12(ofsm>>sc)) || | ||
- prev == ((ai^A64I_LS_U) | A64F_N(rn) | A64F_S9(ofsm&0x1ff))) { | ||
+ if (prev == emit_lso_pair_candidate(ai | A64F_N(rn), ofsm, sc)) { | ||
aip = (A64F_A(rd) | A64F_D(*as->mcp & 31)); | ||
- } else if (prev == (ai | A64F_N(rn) | A64F_U12(ofsp>>sc)) || | ||
- prev == ((ai^A64I_LS_U) | A64F_N(rn) | A64F_S9(ofsp&0x1ff))) { | ||
+ } else if (prev == emit_lso_pair_candidate(ai | A64F_N(rn), ofsp, sc)) { | ||
aip = (A64F_D(rd) | A64F_A(*as->mcp & 31)); | ||
ofsm = ofs; | ||
} else { |