Bug 1642610 part 3 - Transpile MathRandomResult. r=iain
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 04 Jun 2020 16:31:40 +0000
changeset 533943 e519a1393ea3b17098d5419c6943c60872e785cb
parent 533942 a58f7048e7f4dd707b529566aada4109f76a91c6
child 533944 897c90b9b4c19c55f5d5abebbd0e169fda018802
push id37480
push userncsoregi@mozilla.com
push dateThu, 04 Jun 2020 22:00:12 +0000
treeherdermozilla-central@e33aea19d0c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersiain
bugs1642610
milestone79.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 1642610 part 3 - Transpile MathRandomResult. r=iain Differential Revision: https://phabricator.services.mozilla.com/D77802
js/src/jit/CacheIROps.yaml
js/src/jit/WarpCacheIRTranspiler.cpp
--- a/js/src/jit/CacheIROps.yaml
+++ b/js/src/jit/CacheIROps.yaml
@@ -714,17 +714,17 @@
   transpile: true
   args:
     input: NumberId
 
 # Because Baseline stub code is shared by all realms in the Zone, this
 # instruction loads a pointer to the RNG from a stub field.
 - name: MathRandomResult
   shared: false
-  transpile: false
+  transpile: true
   args:
     rng: RawPointerField
 
 - name: MathFloorToInt32Result
   shared: true
   transpile: true
   args:
     input: NumberId
--- a/js/src/jit/WarpCacheIRTranspiler.cpp
+++ b/js/src/jit/WarpCacheIRTranspiler.cpp
@@ -88,16 +88,19 @@ class MOZ_RAII WarpCacheIRTranspiler : p
     return reinterpret_cast<const JSClass*>(readStubWord(offset));
   }
   JSString* stringStubField(uint32_t offset) {
     return reinterpret_cast<JSString*>(readStubWord(offset));
   }
   JSObject* objectStubField(uint32_t offset) {
     return reinterpret_cast<JSObject*>(readStubWord(offset));
   }
+  const void* rawPointerField(uint32_t offset) {
+    return reinterpret_cast<const void*>(readStubWord(offset));
+  }
   int32_t int32StubField(uint32_t offset) {
     return static_cast<int32_t>(readStubWord(offset));
   }
   uint32_t uint32StubField(uint32_t offset) {
     return static_cast<uint32_t>(readStubWord(offset));
   }
 
   MOZ_MUST_USE bool emitGuardTo(ValOperandId inputId, MIRType type);
@@ -1037,16 +1040,31 @@ bool WarpCacheIRTranspiler::emitCompareO
 }
 
 bool WarpCacheIRTranspiler::emitCompareStringResult(JSOp op,
                                                     StringOperandId lhsId,
                                                     StringOperandId rhsId) {
   return emitCompareResult(op, lhsId, rhsId, MCompare::Compare_String);
 }
 
+bool WarpCacheIRTranspiler::emitMathRandomResult(uint32_t rngOffset) {
+#ifdef DEBUG
+  // CodeGenerator uses CompileRealm::addressOfRandomNumberGenerator. Assert it
+  // matches the RNG pointer stored in the stub field.
+  const void* rng = rawPointerField(rngOffset);
+  MOZ_ASSERT(rng == mirGen().realm->addressOfRandomNumberGenerator());
+#endif
+
+  auto* ins = MRandom::New(alloc());
+  add(ins);
+
+  pushResult(ins);
+  return true;
+}
+
 bool WarpCacheIRTranspiler::emitMathAbsInt32Result(Int32OperandId inputId) {
   MDefinition* input = getOperand(inputId);
 
   auto* ins = MAbs::New(alloc(), input, MIRType::Int32);
   add(ins);
 
   pushResult(ins);
   return true;