Bug 869532 - Eliminate unnecessary NaN checks and emit less redundant code. r=me
authorDan Gohman <sunfish@google.com>
Wed, 08 May 2013 16:38:39 -0700
changeset 138091 f6b920f5e96c048539e2fcbab44a22079b339dd5
parent 138090 b262e6be083309762433eee44bdc7d67c37c20b6
child 138092 c1ee14175d13d0a1b67fc91d88ea01fa508ece92
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs869532
milestone23.0a1
Bug 869532 - Eliminate unnecessary NaN checks and emit less redundant code. r=me
js/src/ion/shared/BaselineIC-x86-shared.cpp
--- a/js/src/ion/shared/BaselineIC-x86-shared.cpp
+++ b/js/src/ion/shared/BaselineIC-x86-shared.cpp
@@ -11,37 +11,35 @@
 #include "ion/IonLinker.h"
 
 using namespace js;
 using namespace js::ion;
 
 bool
 ICCompare_Double::Compiler::generateStubCode(MacroAssembler &masm)
 {
-    Label failure, isNaN;
+    Label failure, notNaN;
     masm.ensureDouble(R0, FloatReg0, &failure);
     masm.ensureDouble(R1, FloatReg1, &failure);
 
     Register dest = R0.scratchReg();
 
     Assembler::DoubleCondition cond = JSOpToDoubleCondition(op);
     masm.compareDouble(cond, FloatReg0, FloatReg1);
     masm.setCC(Assembler::ConditionFromDoubleCondition(cond), dest);
     masm.movzxbl(dest, dest);
 
-    // Check for NaN.
-    masm.j(Assembler::Parity, &isNaN);
+    // Check for NaN, if needed.
+    Assembler::NaNCond nanCond = Assembler::NaNCondFromDoubleCondition(cond);
+    if (nanCond != Assembler::NaN_Unexpected) {
+      masm.j(Assembler::NoParity, &notNaN);
+      masm.mov(Imm32(nanCond == Assembler::NaN_IsTrue), dest);
+      masm.bind(&notNaN);
+    }
 
     masm.tagValue(JSVAL_TYPE_BOOLEAN, dest, R0);
     EmitReturnFromIC(masm);
 
-    Assembler::NaNCond nanCond = Assembler::NaNCondFromDoubleCondition(cond);
-    JS_ASSERT(nanCond == Assembler::NaN_IsTrue || nanCond == Assembler::NaN_IsFalse);
-
-    masm.bind(&isNaN);
-    masm.moveValue(BooleanValue(nanCond == Assembler::NaN_IsTrue), R0);
-    EmitReturnFromIC(masm);
-
     // Failure case - jump to next stub
     masm.bind(&failure);
     EmitStubGuardFailure(masm);
     return true;
 }