2
0
Эх сурвалжийг харах

Make sure typeIDsWithFinalType BV's are cleaned up during the Dead Store pass

Paul Leathers 5 жил өмнө
parent
commit
5510d8f524

+ 23 - 12
lib/Backend/BackwardPass.cpp

@@ -251,6 +251,7 @@ BackwardPass::CleanupBackwardPassInfoInFlowGraph()
         block->noImplicitCallJsArrayHeadSegmentSymUses = nullptr;
         block->noImplicitCallArrayLengthSymUses = nullptr;
         block->couldRemoveNegZeroBailoutForDef = nullptr;
+        block->typeIDsWithFinalType = nullptr;
 
         if (block->loop != nullptr)
         {
@@ -486,6 +487,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
     BVSparse<JitArenaAllocator> * slotDeadStoreCandidates = nullptr;
     BVSparse<JitArenaAllocator> * byteCodeUpwardExposedUsed = nullptr;
     BVSparse<JitArenaAllocator> * couldRemoveNegZeroBailoutForDef = nullptr;
+    BVSparse<JitArenaAllocator> * typeIDsWithFinalType = nullptr;
 #if DBG
     uint byteCodeLocalsCount = func->GetJITFunctionBody()->GetLocalsCount();
     StackSym ** byteCodeRestoreSyms = nullptr;
@@ -935,7 +937,20 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
                         blockSucc->couldRemoveNegZeroBailoutForDef = nullptr;
                     }
                 }
-                this->CombineTypeIDsWithFinalType(block, blockSucc);
+
+                if (blockSucc->typeIDsWithFinalType != nullptr)
+                {
+                    if (typeIDsWithFinalType == nullptr)
+                    {
+                        typeIDsWithFinalType = JitAnew(this->tempAlloc, BVSparse<JitArenaAllocator>, this->tempAlloc);
+                    }
+                    typeIDsWithFinalType->Or(blockSucc->typeIDsWithFinalType);
+                    if (deleteData)
+                    {
+                        JitAdelete(this->tempAlloc, blockSucc->typeIDsWithFinalType);
+                        blockSucc->typeIDsWithFinalType = nullptr;
+                    }
+                }
             }
 
             if (blockSucc->noImplicitCallUses != nullptr)
@@ -1143,6 +1158,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
             Assert(block->noImplicitCallJsArrayHeadSegmentSymUses == nullptr);
             Assert(block->noImplicitCallArrayLengthSymUses == nullptr);
             Assert(block->couldRemoveNegZeroBailoutForDef == nullptr);
+            Assert(block->typeIDsWithFinalType == nullptr);
         }
         else
         {
@@ -1198,6 +1214,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
     block->noImplicitCallJsArrayHeadSegmentSymUses = noImplicitCallJsArrayHeadSegmentSymUses;
     block->noImplicitCallArrayLengthSymUses = noImplicitCallArrayLengthSymUses;
     block->couldRemoveNegZeroBailoutForDef = couldRemoveNegZeroBailoutForDef;
+    block->typeIDsWithFinalType = typeIDsWithFinalType;
 }
 
 ObjTypeGuardBucket
@@ -1367,6 +1384,11 @@ BackwardPass::DeleteBlockData(BasicBlock * block)
         JitAdelete(this->tempAlloc, block->couldRemoveNegZeroBailoutForDef);
         block->couldRemoveNegZeroBailoutForDef = nullptr;
     }
+    if (block->typeIDsWithFinalType != nullptr)
+    {
+        JitAdelete(this->tempAlloc, block->typeIDsWithFinalType);
+        block->typeIDsWithFinalType = nullptr;
+    }
 }
 
 void
@@ -5965,17 +5987,6 @@ BackwardPass::HasTypeIDWithFinalType(BasicBlock *block) const
     return block->typeIDsWithFinalType != nullptr && !block->typeIDsWithFinalType->IsEmpty();
 }
 
-void
-BackwardPass::CombineTypeIDsWithFinalType(BasicBlock *block, BasicBlock *blockSucc)
-{
-    BVSparse<JitArenaAllocator> *bvSucc = blockSucc->typeIDsWithFinalType;
-    if (bvSucc != nullptr && !bvSucc->IsEmpty())
-    {
-        BVSparse<JitArenaAllocator> *bv = block->EnsureTypeIDsWithFinalType(this->tempAlloc);
-        bv->Or(bvSucc);
-    }
-}
-
 bool
 BackwardPass::TransitionUndoesObjectHeaderInlining(AddPropertyCacheBucket *data) const
 {

+ 0 - 1
lib/Backend/BackwardPass.h

@@ -152,7 +152,6 @@ private:
     void SetTypeIDWithFinalType(int symId, BasicBlock *block);
     void ClearTypeIDWithFinalType(int symId, BasicBlock *block);
     bool HasTypeIDWithFinalType(BasicBlock *block) const;
-    void CombineTypeIDsWithFinalType(BasicBlock *block, BasicBlock *blockSucc);
 
     template<class Fn> void ForEachAddPropertyCacheBucket(Fn fn);
     static ObjTypeGuardBucket MergeGuardedProperties(ObjTypeGuardBucket bucket1, ObjTypeGuardBucket bucket2);