@@ -196,6 +196,7 @@ FlowGraph::Build(void)
196
196
BasicBlock * currBlock = nullptr ;
197
197
BasicBlock * nextBlock = nullptr ;
198
198
bool hasCall = false ;
199
+ bool hasYield = false ;
199
200
200
201
FOREACH_INSTR_IN_FUNC_BACKWARD_EDITING (instr, instrPrev, func)
201
202
{
@@ -208,7 +209,9 @@ FlowGraph::Build(void)
208
209
nextBlock = currBlock;
209
210
currBlock = this ->AddBlock (instr->m_next , currLastInstr, nextBlock);
210
211
currBlock->hasCall = hasCall;
212
+ currBlock->hasYield = hasYield;
211
213
hasCall = false ;
214
+ hasYield = false ;
212
215
}
213
216
214
217
currLastInstr = instr;
@@ -243,7 +246,9 @@ FlowGraph::Build(void)
243
246
nextBlock = currBlock;
244
247
currBlock = this ->AddBlock (instr, currLastInstr, nextBlock);
245
248
currBlock->hasCall = hasCall;
249
+ currBlock->hasYield = hasYield;
246
250
hasCall = false ;
251
+ hasYield = false ;
247
252
currLastInstr = nullptr ;
248
253
}
249
254
@@ -350,6 +355,11 @@ FlowGraph::Build(void)
350
355
break ;
351
356
}
352
357
358
+ if (instr->m_opcode == Js::OpCode::Yield)
359
+ {
360
+ hasYield = true ;
361
+ }
362
+
353
363
if (OpCodeAttr::UseAllFields (instr->m_opcode ))
354
364
{
355
365
// UseAllFields opcode are call instruction or opcode that would call.
@@ -1400,6 +1410,10 @@ FlowGraph::WalkLoopBlocks(BasicBlock *block, Loop *loop, JitArenaAllocator *temp
1400
1410
{
1401
1411
loop->SetHasCall ();
1402
1412
}
1413
+ if (pred->loop ->hasYield )
1414
+ {
1415
+ loop->SetHasYield ();
1416
+ }
1403
1417
loop->SetImplicitCallFlags (pred->loop ->GetImplicitCallFlags ());
1404
1418
}
1405
1419
// Add pred to loop bit vector
@@ -1430,6 +1444,10 @@ FlowGraph::AddBlockToLoop(BasicBlock *block, Loop *loop)
1430
1444
{
1431
1445
loop->SetHasCall ();
1432
1446
}
1447
+ if (block->hasYield )
1448
+ {
1449
+ loop->SetHasYield ();
1450
+ }
1433
1451
}
1434
1452
1435
1453
// /----------------------------------------------------------------------------
@@ -3500,6 +3518,29 @@ Loop::SetHasCall()
3500
3518
while (current != nullptr );
3501
3519
}
3502
3520
3521
+ void
3522
+ Loop::SetHasYield ()
3523
+ {
3524
+ Loop* current = this ;
3525
+ do
3526
+ {
3527
+ if (current->hasYield )
3528
+ {
3529
+ #if DBG
3530
+ current = current->parent ;
3531
+ while (current)
3532
+ {
3533
+ Assert (current->hasYield );
3534
+ current = current->parent ;
3535
+ }
3536
+ #endif
3537
+ break ;
3538
+ }
3539
+ current->hasYield = true ;
3540
+ current = current->parent ;
3541
+ } while (current != nullptr );
3542
+ }
3543
+
3503
3544
void
3504
3545
Loop::SetImplicitCallFlags (Js::ImplicitCallFlags newFlags)
3505
3546
{
@@ -3570,7 +3611,7 @@ Loop::CanHoistInvariants() const
3570
3611
return false ;
3571
3612
}
3572
3613
3573
- return true ;
3614
+ return ! this -> hasYield ;
3574
3615
}
3575
3616
3576
3617
IR::LabelInstr *
0 commit comments