03.04.20 18:13, joannah nanjekye пише:
From my CS theory, a control flow graph models a program flow and one
of its main characteristics is it has one entry and exit point. IIRC,
CPython’s compilation process involves generation of a control flow graph.
Contrary to peephole optimizations, optimizations on the control flow
graph are more global allowing us to have complex and global
optimizations like branch and checkpoint eliminations etc.
I have seen several implementations of control flow optimizations. The
one I am familiar with is the V8 control flow optimizer.
I tried to investigate this for one of my directed courses last fall but
I want to know if there are people who have been thinking about this for
CPython and what their thoughts are.
I implemented the CFG optimizer, but the problem was that it removed
bytecode which served a marker for the lineno setter in the frame
object. The lineno setter checked if it valid to jump to the specified
instruction by counting instructions specific to some sybtax
constructions. And if you have unconditional break, continue or return
in the with or try block, the code for normal leaving the block was
removed, and the lineno setter was not able to determine when we jump in
or out of the block.
Until we radically change the algorithm of the lineno setter it is hard
to implement a true CFG optimizer. The peepholer contains special
exceptions for such codes, but the CFG optimizer is more aggressive.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/TIJ3B2H4KLQZMBTAGN754YHTUGXY3J5F/
Code of Conduct: http://python.org/psf/codeofconduct/