Bug 1526959 - ARM64 Simulator: Clobber volatile registers on VM function calls. r=sstangl
authorNicolas B. Pierron <nicolas.b.pierron@nbp.name>
Fri, 15 Feb 2019 14:29:43 +0000
changeset 459543 4c7b508eb10d6743cc53c0b798a62569aa492cf5
parent 459542 ac36d71cc3170523b35ba018b46e82e416579689
child 459544 e90244ffbb1318d6984328408bb6ab33f9477427
push id111964
push usercsabou@mozilla.com
push dateFri, 15 Feb 2019 18:54:44 +0000
treeherdermozilla-inbound@db3c4f905082 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs1526959
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526959 - ARM64 Simulator: Clobber volatile registers on VM function calls. r=sstangl Differential Revision: https://phabricator.services.mozilla.com/D19363
js/src/jit/arm64/Architecture-arm64.h
js/src/jit/arm64/vixl/MozSimulator-vixl.cpp
--- a/js/src/jit/arm64/Architecture-arm64.h
+++ b/js/src/jit/arm64/Architecture-arm64.h
@@ -180,19 +180,19 @@ class Registers {
       (1 << Registers::x3) | (1 << Registers::x4) | (1 << Registers::x5) |
       (1 << Registers::x6) | (1 << Registers::x7) | (1 << Registers::x8);
 
   static const SetType VolatileMask =
       (1 << Registers::x0) | (1 << Registers::x1) | (1 << Registers::x2) |
       (1 << Registers::x3) | (1 << Registers::x4) | (1 << Registers::x5) |
       (1 << Registers::x6) | (1 << Registers::x7) | (1 << Registers::x8) |
       (1 << Registers::x9) | (1 << Registers::x10) | (1 << Registers::x11) |
-      (1 << Registers::x11) | (1 << Registers::x12) | (1 << Registers::x13) |
-      (1 << Registers::x14) | (1 << Registers::x14) | (1 << Registers::x15) |
-      (1 << Registers::x16) | (1 << Registers::x17) | (1 << Registers::x18);
+      (1 << Registers::x12) | (1 << Registers::x13) | (1 << Registers::x14) |
+      (1 << Registers::x15) | (1 << Registers::x16) | (1 << Registers::x17) |
+      (1 << Registers::x18);
 
   static const SetType NonVolatileMask =
       (1 << Registers::x19) | (1 << Registers::x20) | (1 << Registers::x21) |
       (1 << Registers::x22) | (1 << Registers::x23) | (1 << Registers::x24) |
       (1 << Registers::x25) | (1 << Registers::x26) | (1 << Registers::x27) |
       (1 << Registers::x28) | (1 << Registers::x29) | (1 << Registers::x30);
 
   static const SetType SingleByteRegs = VolatileMask | NonVolatileMask;
--- a/js/src/jit/arm64/vixl/MozSimulator-vixl.cpp
+++ b/js/src/jit/arm64/vixl/MozSimulator-vixl.cpp
@@ -678,17 +678,22 @@ Simulator::VisitCallRedirection(const In
       setFP64Result(ret);
       break;
     }
 
     default:
       MOZ_CRASH("Unknown function type.");
   }
 
-  // TODO: Nuke the volatile registers.
+  // Nuke the volatile registers. x0-x7 are used as result registers, but except
+  // for x0, none are used in the above signatures.
+  for (int i = 1; i <= 18; i++) {
+    // Code feed 1 bad data
+    set_xreg(i, int64_t(0xc0defeed1badda7a));
+  }
 
   // Assert that callee-saved registers are unchanged.
   VIXL_ASSERT(xreg(19) == x19);
   VIXL_ASSERT(xreg(20) == x20);
   VIXL_ASSERT(xreg(21) == x21);
   VIXL_ASSERT(xreg(22) == x22);
   VIXL_ASSERT(xreg(23) == x23);
   VIXL_ASSERT(xreg(24) == x24);