|
|
dc9548 |
# HG changeset patch
|
|
|
dc9548 |
# User Lars T Hansen <lhansen@mozilla.com>
|
|
|
dc9548 |
# Date 1521449886 -3600
|
|
|
dc9548 |
# Node ID 903a79a1efff18fc7cc50db09a3fe5d768adc9a8
|
|
|
dc9548 |
# Parent 4d2955a9ca7e30ca4c3af9c214ccc77fb2fe7fb8
|
|
|
dc9548 |
Bug 1445907 - Save x28 before clobbering it in the regex compiler. r=sstangl
|
|
|
dc9548 |
|
|
|
dc9548 |
Origin: upstream
|
|
|
dc9548 |
Applied-upstream: 61, commit: https://hg.mozilla.org/mozilla-central/rev/903a79a1efff
|
|
|
dc9548 |
---
|
|
|
dc9548 |
diff --git a/js/src/irregexp/NativeRegExpMacroAssembler.cpp b/js/src/irregexp/NativeRegExpMacroAssembler.cpp
|
|
|
dc9548 |
--- a/js/src/irregexp/NativeRegExpMacroAssembler.cpp
|
|
|
dc9548 |
+++ b/js/src/irregexp/NativeRegExpMacroAssembler.cpp
|
|
|
dc9548 |
@@ -118,17 +118,25 @@ NativeRegExpMacroAssembler::GenerateCode
|
|
|
dc9548 |
|
|
|
dc9548 |
Label return_temp0;
|
|
|
dc9548 |
|
|
|
dc9548 |
// Finalize code - write the entry point code now we know how many
|
|
|
dc9548 |
// registers we need.
|
|
|
dc9548 |
masm.bind(&entry_label_);
|
|
|
dc9548 |
|
|
|
dc9548 |
#ifdef JS_CODEGEN_ARM64
|
|
|
dc9548 |
- // ARM64 communicates stack address via sp, but uses a pseudo-sp for addressing.
|
|
|
dc9548 |
+ // ARM64 communicates stack address via SP, but uses a pseudo-sp (PSP) for
|
|
|
dc9548 |
+ // addressing. The register we use for PSP may however also be used by
|
|
|
dc9548 |
+ // calling code, and it is nonvolatile, so save it. Do this as a special
|
|
|
dc9548 |
+ // case first because the generic save/restore code needs the PSP to be
|
|
|
dc9548 |
+ // initialized already.
|
|
|
dc9548 |
+ MOZ_ASSERT(PseudoStackPointer64.Is(masm.GetStackPointer64()));
|
|
|
dc9548 |
+ masm.Str(PseudoStackPointer64, vixl::MemOperand(sp, -16, vixl::PreIndex));
|
|
|
dc9548 |
+
|
|
|
dc9548 |
+ // Initialize the PSP from the SP.
|
|
|
dc9548 |
masm.initStackPtr();
|
|
|
dc9548 |
#endif
|
|
|
dc9548 |
|
|
|
dc9548 |
// Push non-volatile registers which might be modified by jitcode.
|
|
|
dc9548 |
size_t pushedNonVolatileRegisters = 0;
|
|
|
dc9548 |
for (GeneralRegisterForwardIterator iter(savedNonVolatileRegisters); iter.more(); ++iter) {
|
|
|
dc9548 |
masm.Push(*iter);
|
|
|
dc9548 |
pushedNonVolatileRegisters++;
|
|
|
dc9548 |
@@ -416,17 +424,32 @@ NativeRegExpMacroAssembler::GenerateCode
|
|
|
dc9548 |
masm.pop(temp0);
|
|
|
dc9548 |
masm.movePtr(temp0, StackPointer);
|
|
|
dc9548 |
#endif
|
|
|
dc9548 |
|
|
|
dc9548 |
// Restore non-volatile registers which were saved on entry.
|
|
|
dc9548 |
for (GeneralRegisterBackwardIterator iter(savedNonVolatileRegisters); iter.more(); ++iter)
|
|
|
dc9548 |
masm.Pop(*iter);
|
|
|
dc9548 |
|
|
|
dc9548 |
+#ifdef JS_CODEGEN_ARM64
|
|
|
dc9548 |
+ // Now restore the value that was in the PSP register on entry, and return.
|
|
|
dc9548 |
+
|
|
|
dc9548 |
+ // Obtain the correct SP from the PSP.
|
|
|
dc9548 |
+ masm.Mov(sp, PseudoStackPointer64);
|
|
|
dc9548 |
+
|
|
|
dc9548 |
+ // Restore the saved value of the PSP register, this value is whatever the
|
|
|
dc9548 |
+ // caller had saved in it, not any actual SP value, and it must not be
|
|
|
dc9548 |
+ // overwritten subsequently.
|
|
|
dc9548 |
+ masm.Ldr(PseudoStackPointer64, vixl::MemOperand(sp, 16, vixl::PostIndex));
|
|
|
dc9548 |
+
|
|
|
dc9548 |
+ // Perform a plain Ret(), as abiret() will move SP <- PSP and that is wrong.
|
|
|
dc9548 |
+ masm.Ret(vixl::lr);
|
|
|
dc9548 |
+#else
|
|
|
dc9548 |
masm.abiret();
|
|
|
dc9548 |
+#endif
|
|
|
dc9548 |
|
|
|
dc9548 |
// Backtrack code (branch target for conditional backtracks).
|
|
|
dc9548 |
if (backtrack_label_.used()) {
|
|
|
dc9548 |
masm.bind(&backtrack_label_);
|
|
|
dc9548 |
Backtrack();
|
|
|
dc9548 |
}
|
|
|
dc9548 |
|
|
|
dc9548 |
// Backtrack stack overflow code.
|
|
|
dc9548 |
diff --git a/js/src/jit-test/tests/regexp/bug1445907.js b/js/src/jit-test/tests/regexp/bug1445907.js
|
|
|
dc9548 |
new file mode 100644
|
|
|
dc9548 |
--- /dev/null
|
|
|
dc9548 |
+++ b/js/src/jit-test/tests/regexp/bug1445907.js
|
|
|
dc9548 |
@@ -0,0 +1,15 @@
|
|
|
dc9548 |
+// On ARM64, we failed to save x28 properly when generating code for the regexp
|
|
|
dc9548 |
+// matcher.
|
|
|
dc9548 |
+//
|
|
|
dc9548 |
+// There's wasm and Debugger code here because the combination forces the use of
|
|
|
dc9548 |
+// x28 and exposes the bug when running on the simulator.
|
|
|
dc9548 |
+
|
|
|
dc9548 |
+if (!wasmIsSupported())
|
|
|
dc9548 |
+ quit();
|
|
|
dc9548 |
+
|
|
|
dc9548 |
+var g = newGlobal('');
|
|
|
dc9548 |
+var dbg = new Debugger(g);
|
|
|
dc9548 |
+g.eval(`var m = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func (export "test")))')))`);
|
|
|
dc9548 |
+var re = /./;
|
|
|
dc9548 |
+dbg.onEnterFrame = function(frame) { re.exec("x") };
|
|
|
dc9548 |
+result = g.eval("m.exports.test()");
|
|
|
dc9548 |
|
|
|
dc9548 |
--
|
|
|
dc9548 |
2.21.0
|
|
|
dc9548 |
|