0008-save-and-restore-non-volatile-x28-on-ARM64-for-generated-unboxed-obje.patch 2.5 KB

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