[neon/qt/qtwebengine/Neon/release_jammy] debian: Backport v8 patch to port the latest RegExpMacroAssembler changes to mips64el.

Dmitry Shachnev null at kde.org
Wed Aug 21 09:44:48 BST 2024


Git commit d9db2b426073edee39d8d5d8e7eb4efbb6b92f70 by Dmitry Shachnev.
Committed on 03/07/2024 at 07:45.
Pushed by jriddell into branch 'Neon/release_jammy'.

Backport v8 patch to port the latest RegExpMacroAssembler changes to mips64el.

M  +3    -0    debian/changelog
A  +128  -0    debian/patches/mips64el-v8-regexp.patch
M  +1    -0    debian/patches/series

https://invent.kde.org/neon/qt/qtwebengine/-/commit/d9db2b426073edee39d8d5d8e7eb4efbb6b92f70

diff --git a/debian/changelog b/debian/changelog
index 55f3038..600ba69 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
 qtwebengine-opensource-src (5.15.17+dfsg-2) UNRELEASED; urgency=medium
 
+  [ Dmitry Shachnev ]
+  * Backport v8 patch to port the latest RegExpMacroAssembler changes to
+    mips64el.
 
  -- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>  Wed, 03 Jul 2024 10:36:48 +0300
 
diff --git a/debian/patches/mips64el-v8-regexp.patch b/debian/patches/mips64el-v8-regexp.patch
new file mode 100644
index 0000000..da8cbc9
--- /dev/null
+++ b/debian/patches/mips64el-v8-regexp.patch
@@ -0,0 +1,128 @@
+Description: fix stack check in native code when interrupt was requested
+Origin: upstream v8, https://github.com/v8/v8/commit/1ec3c714bf75f01e
+Last-Update: 2024-07-03
+
+--- a/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.cc
++++ b/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.cc
+@@ -698,6 +698,8 @@ Handle<HeapObject> RegExpMacroAssemblerM
+ 
+     ExternalReference stack_limit =
+         ExternalReference::address_of_jslimit(masm_->isolate());
++    Operand extra_space_for_variables(num_registers_ * kPointerSize);
++
+     __ li(a0, Operand(stack_limit));
+     __ Ld(a0, MemOperand(a0));
+     __ Dsubu(a0, sp, a0);
+@@ -705,14 +707,14 @@ Handle<HeapObject> RegExpMacroAssemblerM
+     __ Branch(&stack_limit_hit, le, a0, Operand(zero_reg));
+     // Check if there is room for the variable number of registers above
+     // the stack limit.
+-    __ Branch(&stack_ok, hs, a0, Operand(num_registers_ * kPointerSize));
++    __ Branch(&stack_ok, hs, a0, extra_space_for_variables);
+     // Exit with OutOfMemory exception. There is not enough space on the stack
+     // for our working registers.
+     __ li(v0, Operand(EXCEPTION));
+     __ jmp(&return_v0);
+ 
+     __ bind(&stack_limit_hit);
+-    CallCheckStackGuardState(a0);
++    CallCheckStackGuardState(a0, extra_space_for_variables);
+     // If returned value is non-zero, we exit with the returned value as result.
+     __ Branch(&return_v0, ne, v0, Operand(zero_reg));
+ 
+@@ -1122,7 +1124,8 @@ bool RegExpMacroAssemblerMIPS::CanReadUn
+ 
+ // Private methods:
+ 
+-void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) {
++void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch,
++                                                        Operand extra_space) {
+   DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins());
+   DCHECK(!masm_->options().isolate_independent_code);
+ 
+@@ -1135,6 +1138,9 @@ void RegExpMacroAssemblerMIPS::CallCheck
+   __ And(sp, sp, Operand(-stack_alignment));
+   __ Sd(scratch, MemOperand(sp));
+ 
++  // Extra space for variables to consider in stack check.
++  __ li(a3, extra_space);
++  // RegExp code frame pointer.
+   __ mov(a2, frame_pointer());
+   // Code of self.
+   __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE);
+@@ -1143,16 +1149,6 @@ void RegExpMacroAssemblerMIPS::CallCheck
+   DCHECK(IsAligned(stack_alignment, kPointerSize));
+   __ Dsubu(sp, sp, Operand(stack_alignment));
+ 
+-  // The stack pointer now points to cell where the return address will be
+-  // written. Arguments are in registers, meaning we treat the return address as
+-  // argument 5. Since DirectCEntry will handle allocating space for the C
+-  // argument slots, we don't need to care about that here. This is how the
+-  // stack will look (sp meaning the value of sp at this moment):
+-  // [sp + 3] - empty slot if needed for alignment.
+-  // [sp + 2] - saved sp.
+-  // [sp + 1] - second word reserved for return value.
+-  // [sp + 0] - first word reserved for return value.
+-
+   // a0 will point to the return address, placed by DirectCEntry.
+   __ mov(a0, sp);
+ 
+@@ -1166,17 +1162,6 @@ void RegExpMacroAssemblerMIPS::CallCheck
+   __ li(kScratchReg, Operand(entry, RelocInfo::OFF_HEAP_TARGET));
+   __ Call(kScratchReg);
+ 
+-  // DirectCEntry allocated space for the C argument slots so we have to
+-  // drop them with the return address from the stack with loading saved sp.
+-  // At this point stack must look:
+-  // [sp + 7] - empty slot if needed for alignment.
+-  // [sp + 6] - saved sp.
+-  // [sp + 5] - second word reserved for return value.
+-  // [sp + 4] - first word reserved for return value.
+-  // [sp + 3] - C argument slot.
+-  // [sp + 2] - C argument slot.
+-  // [sp + 1] - C argument slot.
+-  // [sp + 0] - C argument slot.
+   __ Ld(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize));
+ 
+   __ li(code_pointer(), Operand(masm_->CodeObject()));
+@@ -1197,7 +1182,8 @@ static T* frame_entry_address(Address re
+ 
+ int64_t RegExpMacroAssemblerMIPS::CheckStackGuardState(Address* return_address,
+                                                        Address raw_code,
+-                                                       Address re_frame) {
++                                                       Address re_frame,
++                                                       uintptr_t extra_space) {
+   Code re_code = Code::cast(Object(raw_code));
+   return NativeRegExpMacroAssembler::CheckStackGuardState(
+       frame_entry<Isolate*>(re_frame, kIsolate),
+@@ -1207,7 +1193,8 @@ int64_t RegExpMacroAssemblerMIPS::CheckS
+       return_address, re_code,
+       frame_entry_address<Address>(re_frame, kInputString),
+       frame_entry_address<const byte*>(re_frame, kInputStart),
+-      frame_entry_address<const byte*>(re_frame, kInputEnd));
++      frame_entry_address<const byte*>(re_frame, kInputEnd),
++      extra_space);
+ }
+ 
+ 
+--- a/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.h
++++ b/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.h
+@@ -90,7 +90,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssem
+   // returning.
+   // {raw_code} is an Address because this is called via ExternalReference.
+   static int64_t CheckStackGuardState(Address* return_address, Address raw_code,
+-                                      Address re_frame);
++                                      Address re_frame, uintptr_t extra_space);
+ 
+   void print_regexp_frame_constants();
+ 
+@@ -140,7 +140,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssem
+ 
+ 
+   // Generate a call to CheckStackGuardState.
+-  void CallCheckStackGuardState(Register scratch);
++  void CallCheckStackGuardState(Register scratch,
++                                Operand extra_space = Operand(0));
+ 
+   // The ebp-relative location of a regexp register.
+   MemOperand register_location(int register_index);
diff --git a/debian/patches/series b/debian/patches/series
index cb14ee2..31eb382 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -24,3 +24,4 @@ pipewire-0.3.patch
 fix-example-pro-files.patch
 build-with-c++17.patch
 ninja-1.12.patch
+mips64el-v8-regexp.patch



More information about the Neon-commits mailing list