Skip to content

Commit 5579b4c

Browse files
committed
test
1 parent 62ebccc commit 5579b4c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Zend/Optimizer/zend_cfg.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,23 @@ static void zend_mark_reachable(zend_op *opcodes, zend_cfg *cfg, zend_basic_bloc
2828
{
2929
zend_basic_block *blocks = cfg->blocks;
3030

31-
{
32-
while (1) {
31+
zend_worklist work;
32+
ALLOCA_FLAG(list_use_heap)
33+
ZEND_WORKLIST_ALLOCA(&work, cfg->blocks_count, list_use_heap);
34+
35+
zend_worklist_push(&work, b - cfg->blocks);
36+
37+
while (zend_worklist_len(&work)) {
38+
b = cfg->blocks + zend_worklist_pop(&work);
39+
40+
bool finished = false;
41+
while (!finished) {
3342
int i;
3443

3544
b->flags |= ZEND_BB_REACHABLE;
3645
if (b->successors_count == 0) {
3746
b->flags |= ZEND_BB_EXIT;
38-
return;
47+
break;
3948
}
4049

4150
for (i = 0; i < b->successors_count; i++) {
@@ -90,20 +99,23 @@ static void zend_mark_reachable(zend_op *opcodes, zend_cfg *cfg, zend_basic_bloc
9099
if (i == b->successors_count - 1) {
91100
/* Tail call optimization */
92101
if (succ->flags & ZEND_BB_REACHABLE) {
93-
return;
102+
finished = true;
103+
break;
94104
}
95105

96106
b = succ;
97107
break;
98108
} else {
99109
/* Recursively check reachability */
100110
if (!(succ->flags & ZEND_BB_REACHABLE)) {
101-
zend_mark_reachable(opcodes, cfg, succ);
111+
zend_worklist_push(&work, succ - cfg->blocks);
102112
}
103113
}
104114
}
105115
}
106116
}
117+
118+
ZEND_WORKLIST_FREE_ALLOCA(&work, list_use_heap);
107119
}
108120
/* }}} */
109121

0 commit comments

Comments
 (0)