@@ -720,7 +720,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
720
720
this ->func ->GetDebugNumberSet (debugStringBuffer),
721
721
block->GetBlockNum (), blockSucc->GetBlockNum ());
722
722
723
- auto fixupFrom = [block, blockSucc, this ](Bucket<AddPropertyCacheBucket> &bucket)
723
+ auto fixupFrom = [block, blockSucc, upwardExposedUses, this ](Bucket<AddPropertyCacheBucket> &bucket)
724
724
{
725
725
AddPropertyCacheBucket *fromData = &bucket.element ;
726
726
if (fromData->GetInitialType () == nullptr ||
@@ -729,10 +729,10 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
729
729
return ;
730
730
}
731
731
732
- this ->InsertTypeTransitionsAtPriorSuccessors (block, blockSucc, bucket.value , fromData);
732
+ this ->InsertTypeTransitionsAtPriorSuccessors (block, blockSucc, bucket.value , fromData, upwardExposedUses );
733
733
};
734
734
735
- auto fixupTo = [blockSucc, this ](Bucket<AddPropertyCacheBucket> &bucket)
735
+ auto fixupTo = [blockSucc, upwardExposedUses, this ](Bucket<AddPropertyCacheBucket> &bucket)
736
736
{
737
737
AddPropertyCacheBucket *toData = &bucket.element ;
738
738
if (toData->GetInitialType () == nullptr ||
@@ -741,7 +741,7 @@ BackwardPass::MergeSuccBlocksInfo(BasicBlock * block)
741
741
return ;
742
742
}
743
743
744
- this ->InsertTypeTransitionAtBlock (blockSucc, bucket.value , toData);
744
+ this ->InsertTypeTransitionAtBlock (blockSucc, bucket.value , toData, upwardExposedUses );
745
745
};
746
746
747
747
if (blockSucc->stackSymToFinalType != nullptr )
@@ -4614,7 +4614,7 @@ BackwardPass::ProcessNewScObject(IR::Instr* instr)
4614
4614
Assert (pBucket->GetInitialType () == ctorCache->GetType ());
4615
4615
if (!this ->IsPrePass ())
4616
4616
{
4617
- this ->InsertTypeTransition (instr->m_next , objSym, pBucket);
4617
+ this ->InsertTypeTransition (instr->m_next , objSym, pBucket, block-> upwardExposedUses );
4618
4618
}
4619
4619
#if DBG
4620
4620
pBucket->deadStoreUnavailableInitialType = pBucket->GetInitialType ();
@@ -5192,7 +5192,7 @@ BackwardPass::ProcessPropertySymOpndUse(IR::PropertySymOpnd * opnd)
5192
5192
pBucket->GetFinalType () != nullptr &&
5193
5193
pBucket->GetFinalType () != pBucket->GetInitialType ())
5194
5194
{
5195
- this ->InsertTypeTransition (this ->currentInstr ->m_next , baseSym, pBucket);
5195
+ this ->InsertTypeTransition (this ->currentInstr ->m_next , baseSym, pBucket, block-> upwardExposedUses );
5196
5196
pBucket->SetFinalType (pBucket->GetInitialType ());
5197
5197
}
5198
5198
}
@@ -5211,9 +5211,6 @@ BackwardPass::ProcessPropertySymOpndUse(IR::PropertySymOpnd * opnd)
5211
5211
void
5212
5212
BackwardPass::TrackObjTypeSpecProperties (IR::PropertySymOpnd *opnd, BasicBlock *block)
5213
5213
{
5214
- StackSym *auxSlotPtrSym = nullptr ;
5215
- bool auxSlotPtrUpwardExposed = false ;
5216
-
5217
5214
Assert (tag == Js::DeadStorePhase);
5218
5215
Assert (opnd->IsTypeCheckSeqCandidate ());
5219
5216
@@ -5280,7 +5277,6 @@ BackwardPass::TrackObjTypeSpecProperties(IR::PropertySymOpnd *opnd, BasicBlock *
5280
5277
#endif
5281
5278
5282
5279
bucket->AddToGuardedPropertyOps (opnd->GetObjTypeSpecFldId ());
5283
- auxSlotPtrUpwardExposed = PHASE_ON (Js::ReuseAuxSlotPtrPhase, this ->func ) && opnd->UsesAuxSlot () && !opnd->IsLoadedFromProto () && opnd->IsTypeChecked ();
5284
5280
5285
5281
if (opnd->NeedsMonoCheck ())
5286
5282
{
@@ -5327,12 +5323,6 @@ BackwardPass::TrackObjTypeSpecProperties(IR::PropertySymOpnd *opnd, BasicBlock *
5327
5323
bucket->SetGuardedPropertyOps (nullptr );
5328
5324
JitAdelete (this ->tempAlloc , guardedPropertyOps);
5329
5325
block->stackSymToGuardedProperties ->Clear (objSym->m_id );
5330
- auxSlotPtrSym = opnd->GetAuxSlotPtrSym ();
5331
- if (auxSlotPtrSym)
5332
- {
5333
- this ->currentBlock ->upwardExposedUses ->Clear (auxSlotPtrSym->m_id );
5334
- }
5335
- auxSlotPtrUpwardExposed = false ;
5336
5326
}
5337
5327
}
5338
5328
#if DBG
@@ -5351,11 +5341,25 @@ BackwardPass::TrackObjTypeSpecProperties(IR::PropertySymOpnd *opnd, BasicBlock *
5351
5341
opnd->SetGuardedPropOp (opnd->GetObjTypeSpecFldId ());
5352
5342
}
5353
5343
5354
- if (auxSlotPtrUpwardExposed )
5344
+ if (opnd-> UsesAuxSlot () && opnd-> IsTypeCheckSeqParticipant () && !opnd-> HasTypeMismatch () && !opnd-> IsLoadedFromProto () )
5355
5345
{
5356
- // This is an upward-exposed use of the aux slot pointer.
5357
- auxSlotPtrSym = opnd->EnsureAuxSlotPtrSym (this ->func );
5358
- this ->currentBlock ->upwardExposedUses ->Set (auxSlotPtrSym->m_id );
5346
+ bool auxSlotPtrUpwardExposed = false ;
5347
+ StackSym *auxSlotPtrSym = opnd->GetAuxSlotPtrSym ();
5348
+ if (opnd->IsAuxSlotPtrSymAvailable ())
5349
+ {
5350
+ // This is an upward-exposed use of the aux slot pointer.
5351
+ Assert (auxSlotPtrSym);
5352
+ auxSlotPtrUpwardExposed = this ->currentBlock ->upwardExposedUses ->TestAndSet (auxSlotPtrSym->m_id );
5353
+ }
5354
+ else if (auxSlotPtrSym != nullptr )
5355
+ {
5356
+ // The aux slot pointer is not upward-exposed at this point.
5357
+ auxSlotPtrUpwardExposed = this ->currentBlock ->upwardExposedUses ->TestAndClear (auxSlotPtrSym->m_id );
5358
+ }
5359
+ if (!this ->IsPrePass () && auxSlotPtrUpwardExposed)
5360
+ {
5361
+ opnd->SetProducesAuxSlotPtr (true );
5362
+ }
5359
5363
}
5360
5364
}
5361
5365
@@ -5611,16 +5615,18 @@ BackwardPass::TrackAddPropertyTypes(IR::PropertySymOpnd *opnd, BasicBlock *block
5611
5615
}
5612
5616
5613
5617
void
5614
- BackwardPass::InsertTypeTransition (IR::Instr *instrInsertBefore, int symId, AddPropertyCacheBucket *data)
5618
+ BackwardPass::InsertTypeTransition (IR::Instr *instrInsertBefore, int symId, AddPropertyCacheBucket *data, BVSparse<JitArenaAllocator>* upwardExposedUses )
5615
5619
{
5616
5620
StackSym *objSym = this ->func ->m_symTable ->FindStackSym (symId);
5617
5621
Assert (objSym);
5618
- this ->InsertTypeTransition (instrInsertBefore, objSym, data);
5622
+ this ->InsertTypeTransition (instrInsertBefore, objSym, data, upwardExposedUses );
5619
5623
}
5620
5624
5621
5625
void
5622
- BackwardPass::InsertTypeTransition (IR::Instr *instrInsertBefore, StackSym *objSym, AddPropertyCacheBucket *data)
5626
+ BackwardPass::InsertTypeTransition (IR::Instr *instrInsertBefore, StackSym *objSym, AddPropertyCacheBucket *data, BVSparse<JitArenaAllocator>* upwardExposedUses )
5623
5627
{
5628
+ Assert (!this ->IsPrePass ());
5629
+
5624
5630
IR::RegOpnd *baseOpnd = IR::RegOpnd::New (objSym, TyMachReg, this ->func );
5625
5631
baseOpnd->SetIsJITOptimizedReg (true );
5626
5632
@@ -5637,7 +5643,7 @@ BackwardPass::InsertTypeTransition(IR::Instr *instrInsertBefore, StackSym *objSy
5637
5643
IR::Instr *adjustTypeInstr =
5638
5644
IR::Instr::New (Js::OpCode::AdjustObjType, finalTypeOpnd, baseOpnd, initialTypeOpnd, this ->func );
5639
5645
5640
- if (this -> currentBlock -> upwardExposedUses )
5646
+ if (upwardExposedUses)
5641
5647
{
5642
5648
// If this type change causes a slot adjustment, the aux slot pointer (if any) will be reloaded here, so take it out of upwardExposedUses.
5643
5649
int oldCount;
@@ -5651,7 +5657,10 @@ BackwardPass::InsertTypeTransition(IR::Instr *instrInsertBefore, StackSym *objSy
5651
5657
StackSym *auxSlotPtrSym = baseOpnd->m_sym ->GetAuxSlotPtrSym ();
5652
5658
if (auxSlotPtrSym)
5653
5659
{
5654
- this ->currentBlock ->upwardExposedUses ->Clear (auxSlotPtrSym->m_id );
5660
+ if (upwardExposedUses->Test (auxSlotPtrSym->m_id ))
5661
+ {
5662
+ adjustTypeInstr->m_opcode = Js::OpCode::AdjustObjTypeReloadAuxSlotPtr;
5663
+ }
5655
5664
}
5656
5665
}
5657
5666
}
@@ -5660,7 +5669,7 @@ BackwardPass::InsertTypeTransition(IR::Instr *instrInsertBefore, StackSym *objSy
5660
5669
}
5661
5670
5662
5671
void
5663
- BackwardPass::InsertTypeTransitionAfterInstr (IR::Instr *instr, int symId, AddPropertyCacheBucket *data)
5672
+ BackwardPass::InsertTypeTransitionAfterInstr (IR::Instr *instr, int symId, AddPropertyCacheBucket *data, BVSparse<JitArenaAllocator>* upwardExposedUses )
5664
5673
{
5665
5674
if (!this ->IsPrePass ())
5666
5675
{
@@ -5669,11 +5678,11 @@ BackwardPass::InsertTypeTransitionAfterInstr(IR::Instr *instr, int symId, AddPro
5669
5678
{
5670
5679
// The instr with the bailout is something like a branch that may not fall through.
5671
5680
// Insert the transitions instead at the beginning of each successor block.
5672
- this ->InsertTypeTransitionsAtPriorSuccessors (this ->currentBlock , nullptr , symId, data);
5681
+ this ->InsertTypeTransitionsAtPriorSuccessors (this ->currentBlock , nullptr , symId, data, upwardExposedUses );
5673
5682
}
5674
5683
else
5675
5684
{
5676
- this ->InsertTypeTransition (instr->m_next , symId, data);
5685
+ this ->InsertTypeTransition (instr->m_next , symId, data, upwardExposedUses );
5677
5686
}
5678
5687
}
5679
5688
// Note: we could probably clear this entry out of the table, but I don't know
@@ -5682,7 +5691,7 @@ BackwardPass::InsertTypeTransitionAfterInstr(IR::Instr *instr, int symId, AddPro
5682
5691
}
5683
5692
5684
5693
void
5685
- BackwardPass::InsertTypeTransitionAtBlock (BasicBlock *block, int symId, AddPropertyCacheBucket *data)
5694
+ BackwardPass::InsertTypeTransitionAtBlock (BasicBlock *block, int symId, AddPropertyCacheBucket *data, BVSparse<JitArenaAllocator>* upwardExposedUses )
5686
5695
{
5687
5696
bool inserted = false ;
5688
5697
FOREACH_INSTR_IN_BLOCK (instr, block)
@@ -5705,7 +5714,7 @@ BackwardPass::InsertTypeTransitionAtBlock(BasicBlock *block, int symId, AddPrope
5705
5714
}
5706
5715
else
5707
5716
{
5708
- this ->InsertTypeTransition (instr, symId, data);
5717
+ this ->InsertTypeTransition (instr, symId, data, upwardExposedUses );
5709
5718
inserted = true ;
5710
5719
break ;
5711
5720
}
@@ -5715,7 +5724,7 @@ BackwardPass::InsertTypeTransitionAtBlock(BasicBlock *block, int symId, AddPrope
5715
5724
if (!inserted)
5716
5725
{
5717
5726
Assert (block->GetLastInstr ()->m_next );
5718
- this ->InsertTypeTransition (block->GetLastInstr ()->m_next , symId, data);
5727
+ this ->InsertTypeTransition (block->GetLastInstr ()->m_next , symId, data, upwardExposedUses );
5719
5728
}
5720
5729
}
5721
5730
@@ -5724,7 +5733,8 @@ BackwardPass::InsertTypeTransitionsAtPriorSuccessors(
5724
5733
BasicBlock *block,
5725
5734
BasicBlock *blockSucc,
5726
5735
int symId,
5727
- AddPropertyCacheBucket *data)
5736
+ AddPropertyCacheBucket *data,
5737
+ BVSparse<JitArenaAllocator>* upwardExposedUses)
5728
5738
{
5729
5739
// For each successor of block prior to blockSucc, adjust the type.
5730
5740
FOREACH_SUCCESSOR_BLOCK (blockFix, block)
@@ -5734,7 +5744,7 @@ BackwardPass::InsertTypeTransitionsAtPriorSuccessors(
5734
5744
return ;
5735
5745
}
5736
5746
5737
- this ->InsertTypeTransitionAtBlock (blockFix, symId, data);
5747
+ this ->InsertTypeTransitionAtBlock (blockFix, symId, data, upwardExposedUses );
5738
5748
}
5739
5749
NEXT_SUCCESSOR_BLOCK;
5740
5750
}
@@ -5752,7 +5762,7 @@ BackwardPass::InsertTypeTransitionsAtPotentialKills()
5752
5762
// Also do this for ctor cache updates, to avoid putting a type in the ctor cache that extends past
5753
5763
// the end of the ctor that the cache covers.
5754
5764
this ->ForEachAddPropertyCacheBucket ([&](int symId, AddPropertyCacheBucket *data)->bool {
5755
- this ->InsertTypeTransitionAfterInstr (instr, symId, data);
5765
+ this ->InsertTypeTransitionAfterInstr (instr, symId, data, this -> currentBlock -> upwardExposedUses );
5756
5766
return false ;
5757
5767
});
5758
5768
}
@@ -5778,7 +5788,7 @@ BackwardPass::InsertTypeTransitionsAtPotentialKills()
5778
5788
if (this ->TransitionUndoesObjectHeaderInlining (data))
5779
5789
{
5780
5790
// We're transitioning from inlined to non-inlined, so we can't push it up any farther.
5781
- this ->InsertTypeTransitionAfterInstr (instr, symId, data);
5791
+ this ->InsertTypeTransitionAfterInstr (instr, symId, data, this -> currentBlock -> upwardExposedUses );
5782
5792
}
5783
5793
return false ;
5784
5794
});
0 commit comments