Skip to content

Commit eaf65e9

Browse files
kxxtluyahan
andcommitted
upgpatch: nodejs
Apply the fix patch for v8 JIT issues. The patch from nodejs/node#47399 won't apply to node 19.8.1 so we need to store it in our repo. Co-authored-by: Lu Yahan <yahan@iscas.ac.cn>
1 parent e8c0784 commit eaf65e9

2 files changed

Lines changed: 114 additions & 1 deletion

File tree

nodejs/nodejs-v8-jit-fix.patch

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
From 55aa24940b2c05374539f61eff98db48cc209e23 Mon Sep 17 00:00:00 2001
2+
From: Lu Yahan <yahan@iscas.ac.cn>
3+
Date: Mon, 3 Apr 2023 19:48:27 +0800
4+
Subject: [PATCH] fix node
5+
6+
---
7+
deps/v8/src/codegen/riscv/macro-assembler-riscv.cc | 8 ++++++--
8+
deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.cc | 8 ++++----
9+
deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.h | 4 ++--
10+
3 files changed, 12 insertions(+), 8 deletions(-)
11+
12+
diff --git a/deps/v8/src/codegen/riscv/macro-assembler-riscv.cc b/deps/v8/src/codegen/riscv/macro-assembler-riscv.cc
13+
index 4f4b443c51..02ad494565 100644
14+
--- a/deps/v8/src/codegen/riscv/macro-assembler-riscv.cc
15+
+++ b/deps/v8/src/codegen/riscv/macro-assembler-riscv.cc
16+
@@ -3950,8 +3950,12 @@ bool TurboAssembler::BranchShortHelper(int32_t offset, Label* L, Condition cond,
17+
BlockTrampolinePoolScope block_trampoline_pool(this);
18+
Register scratch = no_reg;
19+
if (!rt.is_reg()) {
20+
- scratch = temps.Acquire();
21+
- li(scratch, rt);
22+
+ if (rt.immediate() == 0) {
23+
+ scratch = zero_reg;
24+
+ } else {
25+
+ scratch = temps.Acquire();
26+
+ li(scratch, rt);
27+
+ }
28+
} else {
29+
scratch = rt.rm();
30+
}
31+
diff --git a/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.cc b/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.cc
32+
index 93da768d86..5fb284fee7 100644
33+
--- a/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.cc
34+
+++ b/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.cc
35+
@@ -24,7 +24,7 @@ namespace internal {
36+
* - s5 : Currently loaded character. Must be loaded using
37+
* LoadCurrentCharacter before using any of the dispatch methods.
38+
* - s6 : Points to tip of backtrack stack
39+
- * - s7 : End of input (points to byte after last character in input).
40+
+ * - s8 : End of input (points to byte after last character in input).
41+
* - fp : Frame pointer. Used to access arguments, local variables and
42+
* RegExp registers.
43+
* - sp : Points to tip of C stack.
44+
@@ -38,7 +38,7 @@ namespace internal {
45+
* --- sp when called ---
46+
* - fp[72] ra Return from RegExp code (ra). kReturnAddress
47+
* - fp[64] s9, old-fp Old fp, callee saved(s9).
48+
- * - fp[0..63] fp..s7 Callee-saved registers fp..s7.
49+
+ * - fp[0..63] fp..s11 Callee-saved registers fp..s11.
50+
* --- frame pointer ----
51+
* - fp[-8] Isolate* isolate (address of the current isolate) kIsolate
52+
* - fp[-16] direct_call (1 = direct call from JS, 0 = from runtime) kDirectCall
53+
@@ -673,7 +673,7 @@ Handle<HeapObject> RegExpMacroAssemblerRISCV::GetCode(Handle<String> source) {
54+
// TODO(plind): we save fp..s11, but ONLY use s3 here - use the regs
55+
// or dont save.
56+
RegList registers_to_retain = {fp, s1, s2, s3, s4,
57+
- s5, s6, s7, s8 /*, s9, s10, s11*/};
58+
+ s5, s6, s7, s8, s9, s10, s11};
59+
DCHECK(registers_to_retain.Count() == kNumCalleeRegsToRetain);
60+
61+
// The remaining arguments are passed in registers, e.g.by calling the code
62+
@@ -713,7 +713,7 @@ Handle<HeapObject> RegExpMacroAssemblerRISCV::GetCode(Handle<String> source) {
63+
64+
// Initialize backtrack stack pointer. It must not be clobbered from here
65+
// on. Note the backtrack_stackpointer is callee-saved.
66+
- static_assert(backtrack_stackpointer() == s7);
67+
+ static_assert(backtrack_stackpointer() == s8);
68+
LoadRegExpStackPointerFromMemory(backtrack_stackpointer());
69+
// Store the regexp base pointer - we'll later restore it / write it to
70+
// memory when returning from this irregexp code object.
71+
diff --git a/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.h b/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.h
72+
index 2352af8a17..826657f6b1 100644
73+
--- a/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.h
74+
+++ b/deps/v8/src/regexp/riscv/regexp-macro-assembler-riscv.h
75+
@@ -105,7 +105,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerRISCV
76+
// Return address (stored from link register, read into pc on return).
77+
78+
// This 9 is 8 s-regs (s1..s8) plus fp.
79+
- static const int kNumCalleeRegsToRetain = 9;
80+
+ static const int kNumCalleeRegsToRetain = 12;
81+
static const int kReturnAddress =
82+
kStoredRegisters + kNumCalleeRegsToRetain * kSystemPointerSize;
83+
84+
@@ -170,7 +170,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerRISCV
85+
86+
// The register containing the backtrack stack top. Provides a meaningful
87+
// name to the register.
88+
- static constexpr Register backtrack_stackpointer() { return s7; }
89+
+ static constexpr Register backtrack_stackpointer() { return s8; }
90+
91+
// Register holding pointer to the current code object.
92+
static constexpr Register code_pointer() { return s1; }
93+
--
94+
2.25.1
95+

nodejs/riscv64.patch

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
--- PKGBUILD
22
+++ PKGBUILD
3-
@@ -40,12 +40,13 @@ build() {
3+
@@ -19,8 +19,15 @@ options=(!lto)
4+
depends=('brotli' 'openssl' 'zlib' 'icu' 'libuv' 'libnghttp2' 'c-ares') # 'http-parser' 'v8')
5+
makedepends=('git' 'python' 'procps-ng')
6+
optdepends=('npm: nodejs package manager')
7+
-source=("git+https://github.com/nodejs/node.git#commit=$_commit")
8+
-sha512sums=('SKIP')
9+
+source=("git+https://github.com/nodejs/node.git#commit=$_commit"
10+
+ "nodejs-v8-jit-fix.patch")
11+
+sha512sums=('SKIP'
12+
+ 'fb4fa53b99e69ab7ae9c7d1483bb73169e2adba36edfc4e76e2edbcce7f054d17580405977d02e34f712696be7770d3dfde01501b507f92383c6e44ec899c74f')
13+
+
14+
+prepare() {
15+
+ cd node
16+
+ patch -Np1 -i ../nodejs-v8-jit-fix.patch
17+
+}
18+
19+
build() {
20+
cd node
21+
@@ -40,12 +47,13 @@ build() {
422
# --shared-v8
523
# --shared-http-parser
624

0 commit comments

Comments
 (0)