Ver Fonte

fix assert, remove OpHelperCheck flag

Michael Holman há 10 anos atrás
pai
commit
594705ed01

+ 1 - 1
lib/Backend/DbCheckPostLower.cpp

@@ -9,7 +9,7 @@
 void
 DbCheckPostLower::Check()
 {
-    bool doOpHelperCheck = (Js::Configuration::Global.flags.CheckOpHelpers && !this->func->isPostLayout);
+    bool doOpHelperCheck = !this->func->isPostLayout;
     bool isInHelperBlock = false;
 
     FOREACH_INSTR_IN_FUNC_EDITING(instr, instrNext, this->func)

+ 29 - 33
lib/Backend/LowerMDShared.cpp

@@ -8669,6 +8669,10 @@ void LowererMD::GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMeth
             //
             // if(round)
             // {
+            //     
+            {}
+            //      
+            //      
             // /* N.B.: the following CMPs are lowered to COMISDs, whose results can only be >, <, or =.
             //    In fact, only ">" can be used if NaN has not been handled.
             // */
@@ -8683,24 +8687,21 @@ void LowererMD::GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMeth
             //     if (shouldCheckNegZero) {
             //         CMP roundedFloat, 0
             //         JA $setZero
-            //         JE $negZeroTest
-            //         J $bailout
+            //         JP $skipRoundSd (NaN)
+            //       $negZeroTest [Helper]:
+            //         JNE $bailoutLabel
+            //         isNegZero(src)
+            //         JE $bailoutLabel
+            //         J $skipRoundSd
             //     } else {
             //         CMP roundedFloat, 0
-            //         JL $bailout
-            //         J $setZero
-            //     }
+            //         JNE $setZero
+            //         J $skipRoundSd (0 or NaN)
+            //      }
             // $ltNegHalf:
             //     CMP roundedFloat, NegTwoToFraction
             //     JA $addHalfToRoundSrc
             //     J $skipRoundSd
-            //     if (shouldCheckNegZero) {
-            // $negZeroTest:
-            //         if isNegZero(roundedFloat):
-            //             J $bailout
-            //         else
-            //             J $skipRoundSd
-            //     }
             // $setZero:
             //     MOV roundedFloat, 0
             //     J $skipRoundSd
@@ -8789,7 +8790,6 @@ void LowererMD::GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMeth
                 IR::LabelInstr * ltHalf = IR::LabelInstr::New(Js::OpCode::Label, this->m_func);
                 IR::LabelInstr * setZero = IR::LabelInstr::New(Js::OpCode::Label, this->m_func);
                 IR::LabelInstr * ltNegHalf = IR::LabelInstr::New(Js::OpCode::Label, this->m_func);
-                IR::LabelInstr * negZeroTest = IR::LabelInstr::New(Js::OpCode::Label, this->m_func, /*helperLabel*/ true);
 
                 IR::Opnd * pointFive;
                 IR::Opnd * twoToFraction;
@@ -8830,18 +8830,26 @@ void LowererMD::GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMeth
                     // CMP roundedFloat, 0
                     // JA $setZero
                     this->m_lowerer->InsertCompareBranch(roundedFloat, zero, Js::OpCode::BrGt_A, setZero, instr);
-                    // JEQ $negZeroTest
-                    this->m_lowerer->InsertBranch(Js::OpCode::BrEq_A, negZeroTest, instr);
-                    // J $bailoutLabel
-                    this->m_lowerer->InsertBranch(Js::OpCode::Br, bailoutLabel, instr);
+                    // JP $skipRoundSd (NaN)
+                    this->m_lowerer->InsertBranch(Js::OpCode::JP, skipRoundSd, instr);
+                    // remaining branches lead to helper call or bailout, so move them to helper path as well
+                    m_lowerer->InsertLabel(true, instr);
+                    // JNE $bailoutLabel
+                    this->m_lowerer->InsertBranch(Js::OpCode::BrNeq_A, bailoutLabel, instr);
+                    IR::Opnd* isNegZero = IsOpndNegZero(src, instr);
+                    // if isNegZero(src) J $bailoutLabel
+                    this->m_lowerer->InsertTestBranch(isNegZero, isNegZero, Js::OpCode::BrNeq_A, bailoutLabel, instr);
+                    // else J $skipRoundSd
+                    this->m_lowerer->InsertBranch(Js::OpCode::Br, skipRoundSd, instr);
+                    negZeroCheckDone = true;
                 }
                 else
                 {
                     // CMP roundedFloat, 0
-                    // JL $bailoutLabel
-                    this->m_lowerer->InsertCompareBranch(zero, roundedFloat, Js::OpCode::BrLt_A, bailoutLabel, instr);
-                    // J $setZero
-                    this->m_lowerer->InsertBranch(Js::OpCode::Br, setZero, instr);
+                    // JNE $setZero // REVIEW: is it legal to set 0, or should we still ROUNDSD?
+                    this->m_lowerer->InsertCompareBranch(roundedFloat, zero, Js::OpCode::BrNeq_A, setZero, instr, true);
+                    // J $skipRoundSd (0 or NaN)
+                    this->m_lowerer->InsertBranch(Js::OpCode::Br, skipRoundSd, instr);
                 }
                 // $ltNegHalf:
                 instr->InsertBefore(ltNegHalf);
@@ -8851,18 +8859,6 @@ void LowererMD::GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMeth
                 // J $skipRoundSd
                 this->m_lowerer->InsertBranch(Js::OpCode::Br, skipRoundSd, instr);
 
-                if (instr->ShouldCheckForNegativeZero())
-                {
-                    // $negZeroTest:
-                    instr->InsertBefore(negZeroTest);
-                    IR::Opnd* isNegZero = IsOpndNegZero(src, instr);
-                    // if isNegZero(src) J $bailoutLabel
-                    this->m_lowerer->InsertTestBranch(isNegZero, isNegZero, Js::OpCode::BrNeq_A, bailoutLabel, instr);
-                    // else J $skipRoundSd
-                    this->m_lowerer->InsertBranch(Js::OpCode::Br, skipRoundSd, instr);
-                    negZeroCheckDone = true;
-                }
-
                 // $setZero:
                 instr->InsertBefore(setZero);
                 if (src->IsFloat64())

+ 0 - 1
lib/common/ConfigFlagsList.h

@@ -793,7 +793,6 @@ FLAGNR(Boolean, CheckEmitBufferPermissions, "Check JIT code buffers at commit an
 FLAGR (Boolean, CheckMemoryLeak       , "Check for heap memory leak", false)
 FLAGR (String,  DumpOnLeak            , "Create a dump on failed memory leak check", nullptr)
 #endif
-FLAGNR(Boolean, CheckOpHelpers        , "Verify opHelper labels in the JIT are set properly", false)
 FLAGNR(Boolean, CloneInlinedPolymorphicCaches, "Clones polymorphic inline caches in inlined functions", DEFAULT_CONFIG_CloneInlinedPolymorphicCaches)
 FLAGNR(Boolean, ConcurrentRuntime     , "Enable Concurrent GC and background JIT when creating runtime", DEFAULT_CONFIG_ConcurrentRuntime)
 FLAGNR(Boolean, Console               , "Create console window in GUI app", false)