@@ -1153,11 +1153,10 @@ Instr::UnlinkBailOutInfo()
11531153 return bailOutInfo;
11541154}
11551155
1156- bool
1157- Instr::ReplaceBailOutInfo (BailOutInfo *newBailOutInfo)
1156+ void
1157+ Instr::ReplaceBailOutInfo (BailOutInfo *newBailOutInfo, BasicBlock * block )
11581158{
11591159 BailOutInfo *oldBailOutInfo = nullptr ;
1160- bool deleteOld = false ;
11611160
11621161#if DBG
11631162 newBailOutInfo->wasCopied = true ;
@@ -1187,12 +1186,17 @@ Instr::ReplaceBailOutInfo(BailOutInfo *newBailOutInfo)
11871186 if (oldBailOutInfo->bailOutInstr == this )
11881187 {
11891188 JitArenaAllocator * alloc = this ->m_func ->m_alloc ;
1189+ // If the oldBailOutInfo's captured values were cached on the globopt-block-data,
1190+ // make a deep copy of the lists in the captured values on the block data.
1191+ if (block && block->globOptData .capturedValuesCandidate == &oldBailOutInfo->capturedValues )
1192+ {
1193+ block->globOptData .capturedValuesCandidate = oldBailOutInfo->capturedValues .Clone (block->globOptData .GetGlobOptAllocator ());
1194+ }
11901195 oldBailOutInfo->Clear (alloc);
11911196 JitAdelete (alloc, oldBailOutInfo);
1192- deleteOld = true ;
11931197 }
11941198
1195- return deleteOld ;
1199+ return ;
11961200}
11971201
11981202IR::Instr *Instr::ShareBailOut ()
@@ -3145,7 +3149,7 @@ Instr::ConvertToBailOutInstr(BailOutInfo * bailOutInfo, IR::BailOutKind kind, bo
31453149 this ->SetBailOutKind_NoAssert (kind);
31463150
31473151 // Clear old (aux) info and set to the new bailOutInfo.
3148- this ->ReplaceBailOutInfo (bailOutInfo);
3152+ this ->ReplaceBailOutInfo (bailOutInfo, nullptr );
31493153 bailOutInfo->bailOutInstr = this ;
31503154 this ->hasBailOutInfo = true ;
31513155
0 commit comments