9fd4340ffec33e38349acac8e06d50e58253ec5b
[buildroot.git] /
1 From 903a79a1efff18fc7cc50db09a3fe5d768adc9a8 Mon 19 Mar 2018 09:58:06 +0100
2 From: Lars T Hansen <lhansen@mozilla.com>
3 Date: Fri, 23 Mar 2018 22:01:33 +0000
4 Subject: [PATCH] save and restore non-volatile x28 on ARM64 for generated unboxed object constructor
5
6 Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1375074
7
8 Upsream-status: Applied
9 See: https://hg.mozilla.org/mozilla-central/rev/800abe66894d
10
11 Signed-off-by: Lars T Hansen <lhansen@mozilla.com>
12 Signed-off-by: Adam Duskett <aduskett@gmail.com>
13 ---
14 js/src/vm/UnboxedObject.cpp | 30 ++++++++++++++++++++++++++----
15 1 file changed, 26 insertions(+), 4 deletions(-)
16
17 diff --git a/js/src/vm/UnboxedObject.cpp b/js/src/vm/UnboxedObject.cpp
18 index 35ca20d7405f..1c20a1093d13 100644
19 --- a/js/src/vm/UnboxedObject.cpp
20 +++ b/js/src/vm/UnboxedObject.cpp
21 @@ -86,9 +86,16 @@ static const uintptr_t CLEAR_CONSTRUCTOR_CODE_TOKEN = 0x1;
22 #endif
23
24 #ifdef JS_CODEGEN_ARM64
25 - // ARM64 communicates stack address via sp, but uses a pseudo-sp for
26 - // addressing.
27 - masm.initStackPtr();
28 + // ARM64 communicates stack address via sp, but uses a pseudo-sp (PSP) for
29 + // addressing. The register we use for PSP may however also be used by
30 + // calling code, and it is nonvolatile, so save it. Do this as a special
31 + // case first because the generic save/restore code needs the PSP to be
32 + // initialized already.
33 + MOZ_ASSERT(PseudoStackPointer64.Is(masm.GetStackPointer64()));
34 + masm.Str(PseudoStackPointer64, vixl::MemOperand(sp, -16, vixl::PreIndex));
35 +
36 + // Initialize the PSP from the SP.
37 + masm.initStackPtr();
38 #endif
39
40 MOZ_ASSERT(propertiesReg.volatile_());
41 @@ -239,7 +246,22 @@ static const uintptr_t CLEAR_CONSTRUCTOR_CODE_TOKEN = 0x1;
42 if (ScratchDoubleReg.volatile_()) masm.pop(ScratchDoubleReg);
43 masm.PopRegsInMask(savedNonVolatileRegisters);
44
45 - masm.abiret();
46 +#ifdef JS_CODEGEN_ARM64
47 + // Now restore the value that was in the PSP register on entry, and return.
48 +
49 + // Obtain the correct SP from the PSP.
50 + masm.Mov(sp, PseudoStackPointer64);
51 +
52 + // Restore the saved value of the PSP register, this value is whatever the
53 + // caller had saved in it, not any actual SP value, and it must not be
54 + // overwritten subsequently.
55 + masm.Ldr(PseudoStackPointer64, vixl::MemOperand(sp, 16, vixl::PostIndex));
56 +
57 + // Perform a plain Ret(), as abiret() will move SP <- PSP and that is wrong.
58 + masm.Ret(vixl::lr);
59 +#else
60 + masm.abiret();
61 +#endif
62
63 masm.bind(&failureStoreOther);
64
65 --
66 2.23.0