Browse Source

BailOnNoProfile improvements

Rajat Dua 9 years ago
parent
commit
7a7ae6290f
2 changed files with 7 additions and 12 deletions
  1. 6 12
      lib/Backend/BackwardPass.cpp
  2. 1 0
      lib/Runtime/Language/ValueType.cpp

+ 6 - 12
lib/Backend/BackwardPass.cpp

@@ -7055,7 +7055,7 @@ BackwardPass::ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block)
         curInstr = curInstr->m_prev;
     }
 
-    // Didn't get to the top of the block, delete this BailOnNoProfile...
+    // Didn't get to the top of the block, delete this BailOnNoProfile.
     if (!curInstr->IsLabelInstr())
     {
         block->RemoveInstr(instr);
@@ -7094,7 +7094,6 @@ BackwardPass::ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block)
     instr->Unlink();
 
     // Now try to move this up the flowgraph to the predecessor blocks
-    bool curBlockNeedsBail = false;
     FOREACH_PREDECESSOR_BLOCK(pred, block)
     {
         bool hoistBailToPred = true;
@@ -7132,15 +7131,11 @@ BackwardPass::ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block)
                     // We already have one, we don't need a second.
                     instrCopy->Free();
                 }
-                else if (predInstr->AsBranchInstr()->m_isSwitchBr)
+                else if (!predInstr->AsBranchInstr()->m_isSwitchBr)
                 {
                     // Don't put a bailout in the middle of a switch dispatch sequence.
                     // The bytecode offsets are not in order, and it would lead to incorrect
                     // bailout info.
-                    curBlockNeedsBail = true;
-                }
-                else
-                {
                     instrCopy->m_func = predInstr->m_func;
                     predInstr->InsertBefore(instrCopy);
                 }
@@ -7160,13 +7155,12 @@ BackwardPass::ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block)
                 }
             }
         }
-        else
-        {
-            curBlockNeedsBail = true;
-        }
     } NEXT_PREDECESSOR_BLOCK;
 
-    if (curBlockNeedsBail)
+    // If we have a BailOnNoProfile in the first block, there must have been at least one path out of this block that always throws.
+    // Don't bother keeping the bailout in the first block as there are some issues in restoring the ArgIn bytecode registers on bailout
+    // and throw case should be rare enough that it won't matter for perf.
+    if (block->GetBlockNum() != 0)
     {
         curInstr->AsLabelInstr()->isOpHelper = true;
 #if DBG

+ 1 - 0
lib/Runtime/Language/ValueType.cpp

@@ -1270,6 +1270,7 @@ void ValueType::InitializeTypeIdToBitsMap()
     TypeIdToBits[TypeIds_SIMDUint8x16      ] = GetObject(ObjectType::Simd128Int8x16).bits;
     TypeIdToBits[TypeIds_SIMDFloat64x2     ] = GetObject(ObjectType::Simd128Float64x2).bits;
 
+    TypeIdToBits[TypeIds_HostDispatch      ] = ValueType::UninitializedObject.bits;
 
     VirtualTypeIdToBits[TypeIds_Int8Array] = GetObject(ObjectType::Int8VirtualArray).bits;
     VirtualTypeIdToBits[TypeIds_Uint8Array] = GetObject(ObjectType::Uint8VirtualArray).bits;