Bug 1574415 - Part 6: Use ScratchTagScope for CacheIRCompiler::emitGuardToInt32Index. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 07 Oct 2019 11:57:54 +0000
changeset 496558 1cc3c2eee37ec2c9cd23d6327b8d8f6ca51dccf3
parent 496557 f3b48a00be455786162394ad78a8d044349af958
child 496559 c24cec7a2424857b38d5b3e1024c0526fdb03d65
push id97326
push userarchaeopteryx@coole-files.de
push dateMon, 07 Oct 2019 16:46:32 +0000
treeherderautoland@144ebbca6844 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1574415
milestone71.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 1574415 - Part 6: Use ScratchTagScope for CacheIRCompiler::emitGuardToInt32Index. r=jandem Similar to emitGuardToInt32ModUint32 and emitGuardToUint8Clamped, ScratchTagScope can be used in emitGuardToInt32Index to avoid splitting the tag two times. The next part will move this code into a shared helper function. Differential Revision: https://phabricator.services.mozilla.com/D47754
js/src/jit/CacheIRCompiler.cpp
--- a/js/src/jit/CacheIRCompiler.cpp
+++ b/js/src/jit/CacheIRCompiler.cpp
@@ -1540,32 +1540,42 @@ bool CacheIRCompiler::emitGuardToInt32In
 
   ValueOperand input = allocator.useValueRegister(masm, inputId);
 
   FailurePath* failure;
   if (!addFailurePath(&failure)) {
     return false;
   }
 
-  Label notInt32, done;
-  masm.branchTestInt32(Assembler::NotEqual, input, &notInt32);
-  masm.unboxInt32(input, output);
-  masm.jump(&done);
-
-  masm.bind(&notInt32);
-
-  masm.branchTestDouble(Assembler::NotEqual, input, failure->label());
+  Label done;
 
   {
-    AutoScratchFloatRegister floatReg(this, failure);
-
-    masm.unboxDouble(input, floatReg);
-
-    // ToPropertyKey(-0.0) is "0", so we can truncate -0.0 to 0 here.
-    masm.convertDoubleToInt32(floatReg, output, floatReg.failure(), false);
+    ScratchTagScope tag(masm, input);
+    masm.splitTagForTest(input, tag);
+
+    Label notInt32;
+    masm.branchTestInt32(Assembler::NotEqual, tag, &notInt32);
+    {
+      ScratchTagScopeRelease _(&tag);
+
+      masm.unboxInt32(input, output);
+      masm.jump(&done);
+    }
+    masm.bind(&notInt32);
+
+    masm.branchTestDouble(Assembler::NotEqual, tag, failure->label());
+    {
+      ScratchTagScopeRelease _(&tag);
+      AutoScratchFloatRegister floatReg(this, failure);
+
+      masm.unboxDouble(input, floatReg);
+
+      // ToPropertyKey(-0.0) is "0", so we can truncate -0.0 to 0 here.
+      masm.convertDoubleToInt32(floatReg, output, floatReg.failure(), false);
+    }
   }
 
   masm.bind(&done);
   return true;
 }
 
 bool CacheIRCompiler::emitGuardToInt32ModUint32() {
   JitSpew(JitSpew_Codegen, __FUNCTION__);