Closed
Description
The compiler has several CFG traversal functions, which repeat some code with minor variations.
- the stack is sometimes allocated with PyObject_Malloc and sometimes with PyMem_Malloc
- the size of the stack is sometimes calculated from the b_list list and sometimes from the b_next list (and in one case a potentially stale value from the assembler is used).
I suggest to refactor as follows:
- always use PyMem_Malloc
- always count using the b_next list (the difference is that by using b_list links we count also some unreachable empty blocks, which we won't traverse through anyway, so we over-allocate the stack a bit).
- refactor the whole thing into a function that also zeroes the b_visited field, and use it consistently.