Bug 1635958 - Warp: Transpile GuardToBoolean. r=jandem
authorTom Schuster <evilpies@gmail.com>
Thu, 07 May 2020 12:11:24 +0000
changeset 528662 f9356df325cd5df64ef952636b788db27fbfd19f
parent 528661 acfb082720cf8f2ec92cef61d7c9814abb0f2901
child 528663 f1ade1bd06137a8e1e055cb87bf81df5314a7473
push id37392
push userapavel@mozilla.com
push dateThu, 07 May 2020 21:43:47 +0000
treeherdermozilla-central@f9356df325cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1635958
milestone78.0a1
first release with
nightly linux32
f9356df325cd / 78.0a1 / 20200507214347 / files
nightly linux64
f9356df325cd / 78.0a1 / 20200507214347 / files
nightly mac
f9356df325cd / 78.0a1 / 20200507214347 / files
nightly win32
f9356df325cd / 78.0a1 / 20200507214347 / files
nightly win64
f9356df325cd / 78.0a1 / 20200507214347 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1635958 - Warp: Transpile GuardToBoolean. r=jandem This gives us comparisons between {int, boolean} x {int, boolean}. Differential Revision: https://phabricator.services.mozilla.com/D74147
js/src/jit/CacheIROps.yaml
js/src/jit/WarpCacheIRTranspiler.cpp
--- a/js/src/jit/CacheIROps.yaml
+++ b/js/src/jit/CacheIROps.yaml
@@ -83,17 +83,17 @@
 - name: GuardIsUndefined
   shared: true
   transpile: false
   args:
     input: ValId
 
 - name: GuardToBoolean
   shared: true
-  transpile: false
+  transpile: true
   args:
     input: ValId
     result: Int32Id
 
 - name: GuardToString
   shared: true
   transpile: true
   custom_writer: true
--- a/js/src/jit/WarpCacheIRTranspiler.cpp
+++ b/js/src/jit/WarpCacheIRTranspiler.cpp
@@ -251,16 +251,37 @@ bool WarpCacheIRTranspiler::emitGuardTo(
 bool WarpCacheIRTranspiler::emitGuardToObject(ValOperandId inputId) {
   return emitGuardTo(inputId, MIRType::Object);
 }
 
 bool WarpCacheIRTranspiler::emitGuardToString(ValOperandId inputId) {
   return emitGuardTo(inputId, MIRType::String);
 }
 
+bool WarpCacheIRTranspiler::emitGuardToBoolean(ValOperandId inputId,
+                                               Int32OperandId resultId) {
+  MDefinition* input = getOperand(inputId);
+
+  MDefinition* boolean;
+  if (input->type() == MIRType::Boolean) {
+    boolean = input;
+  } else {
+    auto* unbox =
+        MUnbox::New(alloc(), input, MIRType::Boolean, MUnbox::Fallible);
+    add(unbox);
+    boolean = unbox;
+  }
+
+  // This is actually a no-op, but still required to get the correct type.
+  auto* ins = MToIntegerInt32::New(alloc(), boolean);
+  add(ins);
+
+  return defineOperand(resultId, ins);
+}
+
 bool WarpCacheIRTranspiler::emitGuardToInt32(ValOperandId inputId,
                                              Int32OperandId resultId) {
   MDefinition* input = getOperand(inputId);
   if (input->type() == MIRType::Int32) {
     return defineOperand(resultId, input);
   }
 
   auto* ins = MUnbox::New(alloc(), input, MIRType::Int32, MUnbox::Fallible);